How to create stacked bar chart using C3 for string data? -


i trying created stacked bar chart using c3 chart. facing problem trying plot graph string values. data looks

var data1=["country", "denmark", "india"] var data2=["value", 1, 1] var x=["item",'item1','item2]  c3.generate({              data: {                 x:'item',          columns:[[data1],[data2]],                  type: 'bar' ,         groups: [             ['data1', 'data2']         ]     },); 

i want display values using tooltip functionality of c3-chart.is there way make bar chart independent of y-axis?

thanks

if understand correctly, this: http://jsbin.com/dowogejose/1/edit?html,js,output

basically set value of 1 each country:

columns: [   ['denmark', 1],   ['india', 1] ] 

then set callback function on tooltip format value lookup:

tooltip: {   format: {     value: function(value, ratio, id, index) {       var lookup = {         'denmark': 123,         'india': 456       };       return lookup[id];     }   } } 

you store lookup value outside of tooltip callback, , generate columns array using object.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -