JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://rawgit.com/masayuki0812/c3/master/c3.js"></script>
<link rel="stylesheet" href="https://rawgit.com/masayuki0812/c3/master/c3.css">
<div id="chart"></div>
JavaScript
var chart = c3.generate({
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250, -250],
],
type: 'bar'
}
});
// select the x axis
d3.select(chart.element).select('.' + c3.chart.internal.fn.CLASS.axisX).transition()
// and translate it to the y = 0 position
.attr('transform', "translate(" + 0 + "," + chart.internal.y(0) + ")")
setTimeout(function () {
chart.load({
columns: [
['data1', 30, 200, 100, 400, 150, 250, -150],
],
unload: ['data1'],
done: function () {
// select the x axis
d3.select(chart.element).select('.' + c3.chart.internal.fn.CLASS.axisX).transition()
// and translate it to the y = 0 position
.attr('transform', "translate(" + 0 + "," + chart.internal.y(0) + ")")
}
});
}, 1000);