Open DemoreXTess opened 1 year ago
The issue could be related to this -> https://tradingview.github.io/lightweight-charts/docs/migrations/from-v3-to-v4#scalemargins-option-has-been-removed-from-series-options
You could use price_scale
and overlay_price_scales
option while defining Chart. See below example. This is working. But it is a chart level setting and could be an issue when you want to control scale margin for multiple overlay series chart.
sp500_2000_2001_chart = Chart(
width = 1360,
height = 500,
time_scale=TimeScaleOptions(
seconds_visible=True,
time_visible=True),
price_scale=PriceScaleOptions(scale_margins=PriceScaleMargins(top=0.1,bottom=0.4)),
overlay_price_scales=OverlayPriceScaleOptions(scale_margins=PriceScaleMargins(top=0.7,bottom=0))
)
sp500_2000_2001_chart.mark_candlestick(data=sp500_2000_2001)
#sp500_2000_2001_chart.mark_line(data=sp500_2000_2001.eval('value = close'), name = 'test', LineWidth=2)
sp500_2000_2001_chart.mark_histogram(series_name='Volume',data=sp500_2000_2001.eval('value = volume'),priceScaleId='',priceFormat={'type':'volume'})
Alternatively, I tried to fix this by making some code changes. you can download my code using this command -> pip install -U git+https://github.com/zlpatel/pytvlwcharts.git@patch-1
The only caveat is that you always need to pass price_scale
parameter even though you don't want to set anything. I am still trying to figure out how to improve that so that we don't have to pass that parameter but meanwhile you can just set it to an empty object of PriceScaleMargins()
like I did in the below example.
sp500_2000_2001_chart = Chart(
width = 1360,
height = 500,
time_scale=TimeScaleOptions(
seconds_visible=True,
time_visible=True)
#price_scale=PriceScaleOptions(scale_margins=PriceScaleMargins(top=0.1,bottom=0.4)),
#overlay_price_scales=OverlayPriceScaleOptions(scale_margins=PriceScaleMargins(top=0.7,bottom=0))
)
sp500_2000_2001_chart.mark_candlestick(series_name='ohlc',data=sp500_2000_2001, price_scale = PriceScaleOptions()) #scale_margins=PriceScaleMargins(top=0.1,bottom=0.4)))
sp500_2000_2001_chart.mark_line(data=sp500_2000_2001.eval('value = close'), price_scale = PriceScaleOptions(scale_margins=PriceScaleMargins(top=0.1,bottom=0.4)), name = 'test', LineWidth=0.5)
sp500_2000_2001_chart.mark_histogram(series_name='Volume',data=sp500_2000_2001.eval('value = volume'), price_scale = PriceScaleOptions(scale_margins=PriceScaleMargins(top=0.9,bottom=0)),priceScaleId='',priceFormat={'type':'volume'})
I made a basic candlestick chart with volume parameter but my volume histogram heights are huge. I tried to put them much lower places with bigger percentage values such as .9 from top but nothing changed. I need quick help please