2

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.

whoan
  • 8,143
  • 4
  • 39
  • 48
Syafrizal
  • 23
  • 4
  • Could you clarify your question? The ["hide1", "hide2"] should probably be ["data1", "data2"] if you want to hide those data columns. – Willy G Dec 02 '14 at 13:51
  • The ["hide1","hide2"] like this ["a","b"] not data1 or data2. It's imposible to get value a or b. – Syafrizal Dec 07 '14 at 12:30
  • Syafrizal, I just saw a solution - http://stackoverflow.com/questions/27700379/hide-some-graphic-elements-c3js-without-unloading-data/27701278#27701278 - that may help you. – JasTonAChair Dec 30 '14 at 08:00

2 Answers2

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.

Sean
  • 14,359
  • 13
  • 74
  • 124
0

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');
Andrew
  • 2,368
  • 1
  • 23
  • 30