@app.callback(Output('graph', 'extendData'), [Input('interval', 'n_intervals')],
[State("graph", "figure")])
def update_data(n_intervals, existing):
# work directly with existing['data'][0] and determine
# if you need to append to it or modify its [-1] entry here
return [
{
"x": [existing["data"][0]["x"]],
"open": [existing["data"][0]["open"]],
"high": [existing["data"][0]["high"] ],
"low": [existing["data"][0]["low"]],
"close": [existing["data"][0]["close"]]
},
[0],
len(existing["data"][0]["open"])
]
How would I go about extending a second trace for a Scatter plot?
As the Scatter trace only has ‘x’ and a ‘y’ elements and the main Candlestick trace does not have a ‘y’ and has a bunch of candlestick elements that the Scatter lacks, how would I go about extending both traces?
Have tried sending empy lists for the missing atributes but that does not work
I don’t think this is currently supported. The extendData uses Plotly.extendTraces from the js library and it checks internally if each trace being update has all the keys in the update object. This is where it is done, in case you are wondering.
Has this issue been solved in more recent versions? I think it’s really useful to have.
I’m facing the same issue trying to update candlestick trace and volume bars at the same time… !
Hi @hassan, @sfvasfdvsdfvdsv
Take a look at this fork of the plotly Graph component, it has a better extendData function that allow to generate new traces and mix multiple trace type. It also add a prependData function to the graph.