leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.84k stars 385 forks source link

Error when data has fever series than option.series #966

Open mulgurul opened 5 months ago

mulgurul commented 5 months ago

When using React/React wrapper, updating uPlot using the props then it is not always easy to control if data or options gets updated first.

I discovered that if the data props has fever elements than the option.series (y series), then it throws an error. It would be nice if the series with missing data was just ignored or shown without plot on graph, like an empty series. It would further be fantastic if the connection between options.series and data arrays could be connected using some kind of series key, and this was also reflected in the API. This way, if could be possible to add/del/update series dynamically by referring to the key instead of an index number which gets quite complicated managing the book-keeping of series (also including x series) when using the API from a framework like react.

Heres a repro of the problem with missing data series.

Repro

In line 159 you can in-comment the second y series data array which solves the error.

Best regards, Peter