|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/css/c3.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div id="chart"></div>
|
|
|
|
|
|
|
|
<script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
|
|
|
|
<script src="/js/c3.js"></script>
|
|
|
|
<script>
|
|
|
|
var chart = c3.generate({
|
|
|
|
bindto: '#chart',
|
|
|
|
data: {
|
|
|
|
xs : {
|
|
|
|
'data1': 'x1',
|
|
|
|
'data2': 'x2',
|
|
|
|
},
|
|
|
|
columns: [
|
|
|
|
['x1', 100, 120, 130, 200, 240, 500],
|
|
|
|
['x2', 150, 220, 230, 400, 540, 600, 800],
|
|
|
|
['data1', 30, 200, 100, 400, 150, 250],
|
|
|
|
['data2', 130, 100, 300, 200, 250, 350, 100],
|
|
|
|
],
|
|
|
|
selection: {
|
|
|
|
enabled: true
|
|
|
|
},
|
|
|
|
onclick: function (d) { console.log("onclick", d); },
|
|
|
|
onmouseover: function (d) { console.log("onmouseover", d); },
|
|
|
|
onmouseout: function (d) { console.log("onmouseout", d); }
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
chart.load({
|
|
|
|
columns: [
|
|
|
|
['data1', 100, 210, 150, null, 200, 150],
|
|
|
|
['data2', 200, 310, 50, 400, 120, 250, 10],
|
|
|
|
]
|
|
|
|
});
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
chart.load({
|
|
|
|
columns: [
|
|
|
|
['x2', 150, 220, 230, 400, 540, 600, 800],
|
|
|
|
['data2', 200, 310, 50, 400, 120, 250, 10],
|
|
|
|
['data3', 300, 410, 350, 600, 420, 550, 310],
|
|
|
|
],
|
|
|
|
xs: {
|
|
|
|
data3: 'x2'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}, 2000);
|
|
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
chart.xs({
|
|
|
|
'data1': [200, 210, 350, 400, 600, 750],
|
|
|
|
'data2': [200, 210, 350, 400, 550, 750, 900]
|
|
|
|
});
|
|
|
|
}, 3000);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|