Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.4 KiB

<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/c3.css">
</head>
<body>
<div id="chart1"></div>
<button onclick="load()">Load</button>
<div id="chart2"></div>
<script src="http://d3js.org/d3.v4.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script>
<script>
var chart1 = c3.generate({
bindto: '#chart1',
data: {
columns: [
generateData(100)
],
},
zoom: {
enabled: true,
initialRange: [30, 60],
onzoomstart: function (event) {
console.log("onzoomstart", event);
},
onzoomend: function (domain) {
console.log("onzoomend", domain);
},
},
subchart: { show: true }
});
var chart2 = c3.generate({
bindto: '#chart2',
data: {
columns: [
generateData(100)
],
},
axis: {
x: {
}
},
zoom: {
enabled: true,
initialRange: [30, 60],
},
});
function load() {
chart1.load({
columns: [
generateData(Math.random() * 1000)
],
});
}
function generateData(n) {
var column = ['sample'];
for (var i = 0; i < n; i++) {
column.push(Math.random() * 500);
}
return column;
}
</script>
</body>
</html>