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.
62 lines
2.2 KiB
62 lines
2.2 KiB
1 year ago
|
<html>
|
||
|
<head>
|
||
|
<link rel="stylesheet" type="text/css" href="../css/c3.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<div id="chart"></div>
|
||
|
|
||
|
<script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
|
||
|
<script src="../js/c3.js"></script>
|
||
|
<script>
|
||
|
var chart = c3.generate({
|
||
|
data: {
|
||
|
columns: [
|
||
|
// ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
|
||
|
["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3],
|
||
|
["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8],
|
||
|
["setosa", 30],
|
||
|
// ["versicolor", 40],
|
||
|
// ["virginica", 50],
|
||
|
],
|
||
|
type : 'donut',
|
||
|
onmouseover: function (d, i) { console.log("onmouseover", d, i, this); },
|
||
|
onmouseout: function (d, i) { console.log("onmouseout", d, i, this); },
|
||
|
onclick: function (d, i) { console.log("onclick", d, i, this); },
|
||
|
order: null // set null to disable sort of data. desc is the default.
|
||
|
},
|
||
|
axis: {
|
||
|
x: {
|
||
|
label: 'Sepal.Width'
|
||
|
},
|
||
|
y: {
|
||
|
label: 'Petal.Width'
|
||
|
}
|
||
|
},
|
||
|
donut: {
|
||
|
label: {
|
||
|
// format: function (d, ratio) { return ""; }
|
||
|
},
|
||
|
title: "Iris Petal Width",
|
||
|
width: 70,
|
||
|
padAngle: .1
|
||
|
}
|
||
|
});
|
||
|
|
||
|
setTimeout(function () {
|
||
|
chart.load({
|
||
|
columns: [
|
||
|
['data1', 30, 20, 50, 40, 60, 50],
|
||
|
]
|
||
|
});
|
||
|
}, 1000);
|
||
|
|
||
|
setTimeout(function () {
|
||
|
chart.unload({
|
||
|
ids: 'virginica'
|
||
|
});
|
||
|
}, 2000);
|
||
|
|
||
|
</script>
|
||
|
</body>
|
||
|
</html>
|