Plotly js - Constrain x-axis room range


#1

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:

https://jsfiddle.net/o9z8uzx8/

Many thanks.


#2

Adding something like

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

after your extendTraces should do the trick.


#3

Thanks for the suggestion.

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

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