Get Value Data Hidden On C3js

陌路散爱 提交于 2019-12-11 02:04:15

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!