unloading data is not unloading the corresponding x axis (xs items)
- Dominant language
- JavaScript
- Stars
- 9.3k
- Forks
- 1.4k
- Avg merge
- 6d 16h
- Merged PRs (30d)
- 1
Description
While using `chart.load` with `unload` set to `true`, the library is only removing the `data.targets` (and not their associated `xs`).
The `c3_chart_internal_fn.unload` method is filtering only `$$.data.targets` and not `$$.data.xs`
This is causing trouble when loading new data with x-axis not specified (in which case the library is trying to use the old values of `xKey` in combination with xs from other targets `$$.getOtherTargetXs()`).
To reproduce the problem, load and unload data with and without x-axis specified in below sequence:
```
chart.load({
columns: [
['data1', 0],
['data2', 0]
],
unload: true
});
chart.load({ json: someData, type: 'line', keys: {value:['series1','series2'], x:'x'}, unload: true });
chart.load({ json: someData, type: 'line', keys: {value:['series1','series2'], }, unload: true });
```
Note the `x` not specified in the last line, but the library will try to fetch it from data1 and data2 (since their xs is still around).
The problem is, `$$.config.data_x` is retaining its old value (when the `keys.x` is not undefined). Thus there is no way to force 'reset x axis' (like the case where a default one is provided with sequence numbers).
In interactive chart building, users try to select and unselect different x-axis options. In those cases this kind of scenario becomes very difficult to handle and gives incorrect results.
Contributor guide
Assessment
This issue has not been assessed yet.