c3js / c3js/c3

Hide property does not work in load function, breaks after unload function

Open
#1,338 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
1.4k
Avg merge
6d 16h
Merged PRs (30d)
1

Description

I have different data sets that need to be loaded dynamically on the same chart depending on which filters a user selects, but some data needs to be hidden when it first loads in

This does not work:

```
var chart = c3.generate({
data: {
columns: [],
}
});

chart.load({
columns: [
['data1', 30, 20, 50, 40, 60, 50],
['data2', 200, 130, 90, 240, 130, 220],
],
hide: ['data2']
});
```

Curiously, this does work:

```
var chart = c3.generate({
data: {
columns: [],
hide: ['data2']
},
});

chart.load({
columns: [
['data1', 30, 20, 50, 40, 60, 50],
['data2', 200, 130, 90, 240, 130, 220],
],
});
```

But it is not an acceptable workaround because if the data is unloaded then loaded again, the toggle is in the wrong state:

```
var chart = c3.generate({
data: {
columns: [],
hide: ['data2']
},
});

chart.load({
columns: [
['data1', 30, 20, 50, 40, 60, 50],
['data2', 200, 130, 90, 240, 130, 220],
],
});

chart.load({
columns: [
['data3', 300, 200, 160, 400, 250, 250]
],
unload: ['data1', 'data2']
});

chart.load({
columns: [
['data1', 30, 20, 50, 40, 60, 50],
['data2', 200, 130, 90, 240, 130, 220],
],
unload: ['data3']
});
```

It would be ideal if `hide` could be passed in `load`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.