c3 - JSON data with timeseries and date filter
Display only the first of the month
HTML
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/c3/0.4.6/c3.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/c3/0.4.6/c3.js"></script>
<div id="chart"></div>
JavaScript
var chart = c3.generate({
bindto: '#chart',
data: {
json: [
{"_id":1417600089156,"a":6,"b":10,"c":6,"d":20},
{"_id":1407600089156,"a":4,"b":0,"c":4,"d":9},
{"_id":1397600089156,"a":30,"b":25,"c":20,"d":15}
],
keys: {
x:'_id',
value: ['a', 'b','c','d'],
}
},
axis : {
x : {
type : 'timeseries',
culling: false,
tick: {
format: function(time){
console.log('time '+time);
var dat = new Date(time);
var _months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"];
var month = dat.getMonth();
return _months[month];
}
}
}
}
});