lightweight-charts
lightweight-charts copied to clipboard
Option to limit price scale range
I have a a set of baseline series that are always positive and I'd like to be able to zoom in on a narrow price range but don't want to allow the price scale to get into negative territory.
The ideal solution would be to have minimum
and maximum
options on the price scale that act like fixLeftEdge
and fixRightEdge
except that they are specified with a constant value instead of being based on the range of the data.
When the chart is automatically adjusting the price scale min and max range values, this is called autoScale
and what it is doing is automatically adjusting the scale to ensure that all the data fits within the chart.
You can disable autoScale
on the Price scale with: https://tradingview.github.io/lightweight-charts/docs/api/interfaces/PriceScaleOptions#autoscale
You could also use the autoscaleInfoProvider
option (which can be applied to any series via the series options) which allows to you customise the scaling. So if you used autoscaleInfoProvider
on all the series, and made it return the minimum and maximum values which you would prefer then you could achieve the desired effect.
- https://tradingview.github.io/lightweight-charts/docs/api/interfaces/SeriesOptionsCommon#autoscaleinfoprovider
@SlicedSilver Thanks for the idea. My feature request might not have been clear enough that the limit is about how far the user can adjust the scale (by dragging on the axis or chart area). The autoscale settings don't limit this, so I don't think it will help in this case.
You are correct. AutoScaleInfo won't help for that case. I'll mark the issue as a feature request.
Solution?