-
-
Notifications
You must be signed in to change notification settings - Fork 33
Closed
Description
After removing a series, in the AreaChart.svelte component, an error is throw here:
const stackData = stack()
.keys(seriesKeys) // <-- the removed series is still in seriesKeys
.value((d, key) => {
const s = series.find((d) => d.key === key)!; // <-- no result here
const value = accessor(s.value ?? y ?? s.key)(d as any); // s.value then crashes
return value;
})There seems to be an async issue between the series and the data. I.e. I update both of them at the same time in my code, but when I add logs, I can see that, for example, when I add a new series:
seriesKeysdoes not contain the new series yet- the data has the right values
- then, the same code is called immediately, this time with
seriesKeysbeing correctly updated
This is harmless when adding a new series, but this crashes when removing a series.
I patched the library to transform this line of code:
- const seriesKeys = seriesState.visibleSeries.map((s) => s.key);
+ const seriesKeys = seriesState.visibleSeries.map((s) => s.key).filter(key => _chartData.some(data => key in data));
To make sure there is "extra" series keys that with no data associated.
Metadata
Metadata
Assignees
Labels
No labels