The demonstration provided below shows the numeric representation of the month part in a date string, ranging from 1 to 12. This data is then applied to the values on the x-axis.
- Is there a way to display the months as text instead, such as: Jan, Feb, Mar, etc.? (Even if this requires hardcoding the text, I have been unable to find a suitable format for text or string).
At present, the documentation for C3 is quite limited and my attempts to achieve this modification have proven fruitless.
var chart = c3.generate({
bindto: '#chart',
data: {
x: 'x',
columns: [
['x', '2013-01-01', '2013-02-01', '2013-03-01', '2013-04-01', '2013-05-01', '2013-06-01', '2013-07-01', '2013-08-01', '2013-09-01', '2013-10-01', '2013-11-01', '2013-12-01'],
['2014', 130, 120, 150, 140, 160, 150, 130, 120, 150, 140, 160, 150]
],
type: 'bar'
},
axis: {
x: {
type: 'timeseries',
tick: {
format: function (x) { return (x.getMonth() + 1); }
}
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.11/d3.min.js"></script>
<script src="http://gopeter.de/misc/c3/c3.js"></script>
<div id="chart"></div>