🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

Plotly js - Constrain x-axis room range

I’d like to be able to update a Plotly candlestick graph with new plots as the information becomes available.

The issue I have is that whenever a new candlestick is added, the graph ‘zooms’ out so that it shows every candle stick that has ever been added. Instead, I want the graph to start panning once a certain number of candlestick have been added.

I have a working example of this here:


Many thanks.

Adding something like

Plotly.relayout(gd, 'xaxis.range', [/* new range */])

after your extendTraces should do the trick.

Thanks for the suggestion.

I’ve tried it, but now I get noting at all :confused:

Update jsfiddle: https://jsfiddle.net/o9z8uzx8/4/