As you can see in output I am getting decimal values in y axis. These are number of downloads it cant be 1.5.
I tried giving min value but unable to get the result.
Also on mouse over in grid I am always getting value zero 0(Above microsoft in image). Can I have my custom text there?
function draw_tech_chart(){
var chart = c3.generate({
bindto: "#tech_chart",
data: {
columns: [['Microsoft', 5],['WebApplicationDevelopment', 2],['OpenSource', 2],['Content Management ', 2],['Open Source Middleware', 1],],
type : 'bar',
onclick: function (d, i) { console.log("onclick", d, i); },
onmouseover: function (d, i) { console.log("onmouseover", d, i); },
onmouseout: function (d, i) { console.log("onmouseout", d, i); }
},size: {
height: 250
}
});
Just format the y ticks to not display the labels
var chart = c3.generate({
bindto: "#tech_chart",
...
axis: {
y: {
tick: {
format: function (d) {
return (parseInt(d) == d) ? d : null;
}
}
}
}
});
Alternatively, you could also loop through the values, find the max and set the y tick values manually to integers or integer multiples from 0 to max+ (see http://c3js.org/reference.html#axis-y-tick-value)
Fiddle - http://jsfiddle.net/ovvywb5j/
You just need to manually compute the values on Y axis. You could also format the title of tooltip:
axis: {
y: {
tick : {values: [0,1,2,3,4,5]}
}
}, tooltip: {
format: {
title: function (d) { return 'Custom text'; },
}
}
Fiddle: http://jsfiddle.net/yymcjhgv/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With