Get value data hidden on C3js

I use chart plugins from c3js.org as follows:

data: {
    x : 'x',
    columns: [['data1',10,20,30],['data2',40,28,10]]
    type: 'bar',
    hide: ["hide1","hide2"],
    onclick: function(d,i){
                console.log(d);
    },
    labels: true
},

Is there a way to get the value from the data hidden above?

Thank you and sorry for my poor English.

+2
source share
2 answers

Are you trying to hide the data or get the value of the hide array from the click event? If the latter, in the onclick event, you can use:

this.data.shown()

to get an array of displayed data objects.

+1
source

If you are looking for an array of hidden values, you can separate all the values ​​and the values ​​shown. Using lodash difference (or you can write your own), it looks something like this:

var allVals = chart.data();
var shownVals = chart.data.shown();
var diff = _.differenceBy(allVals, shownVals, 'id');
0
source

Source: https://habr.com/ru/post/1569390/


All Articles