问题
I'am using chart plugins from c3js.org like this:
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 value from data hidden above?
Thanks before, and sorry for bad my english.
回答1:
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 the array of shown data objects.
回答2:
If you're looking for an array of the hidden values, you can do a difference of all the values and the shown values. Using lodash's 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');
来源:https://stackoverflow.com/questions/27187814/get-value-data-hidden-on-c3js