55 lines
1.3 KiB
HTML
Executable File
55 lines
1.3 KiB
HTML
Executable File
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<script>
|
|
window.onload = function () {
|
|
|
|
var chart = new CanvasJS.Chart("chartContainer", {
|
|
theme: "dark2",
|
|
exportFileName: "Doughnut Chart",
|
|
exportEnabled: true,
|
|
animationEnabled: true,
|
|
title:{
|
|
text: "Monthly Expense"
|
|
},
|
|
legend:{
|
|
cursor: "pointer",
|
|
itemclick: explodePie
|
|
},
|
|
data: [{
|
|
type: "doughnut",
|
|
innerRadius: 90,
|
|
showInLegend: true,
|
|
toolTipContent: "<b>{name}</b>: ${y} (#percent%)",
|
|
indexLabel: "{name} - #percent%",
|
|
dataPoints: [
|
|
{ y: 450, name: "Food" },
|
|
{ y: 120, name: "Insurance" },
|
|
{ y: 300, name: "Travelling" },
|
|
{ y: 800, name: "Housing" },
|
|
{ y: 150, name: "Education" },
|
|
{ y: 150, name: "Shopping"},
|
|
{ y: 250, name: "Others" }
|
|
]
|
|
}]
|
|
});
|
|
chart.render();
|
|
|
|
function explodePie (e) {
|
|
if(typeof (e.dataSeries.dataPoints[e.dataPointIndex].exploded) === "undefined" || !e.dataSeries.dataPoints[e.dataPointIndex].exploded) {
|
|
e.dataSeries.dataPoints[e.dataPointIndex].exploded = true;
|
|
} else {
|
|
e.dataSeries.dataPoints[e.dataPointIndex].exploded = false;
|
|
}
|
|
e.chart.render();
|
|
}
|
|
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<div id="chartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
|
|
<script src="../../canvasjs.min.js"></script>
|
|
</body>
|
|
</html> |