Data Visualization
(
3160717 )
Practical and Source Codes
<!DOCTYPE HTML>
<html>
<head>
<title>Showing the data as a Simple Bar Chart</title>
<meta charset="utf-8">
<meta name="author" content="SidPro" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="description" content="Showing the sales data of Facecream as a Simple Bar chart" />
<meta name="keywords" content="Single,Bar,Chart,Single Bar Chart,Line" />
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/canvasjs.min.js"></script>
</head>
<body>
<h2>Showing the data as a Simple Bar Chart</h2>
<div id="chartContainer" style="height: 600px; width: 100%;"></div>
</body>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
title: {
text: "the sales data of Facecream"
},
axisX: {
title: "Month",
},
axisY: {
title: "Sales Unit",
},
theme: "dark1", //"light1", "light2", "dark1", "dark2"
data: [
{
// Change type to "column", "doughnut", "line", "splineArea", etc.
type: "column",
dataPoints: [
{ label: "Jan", y: 2500 },
{ label: "Feb", y: 2630 },
{ label: "Mar", y: 2140 },
{ label: "Apr", y: 3400 },
{ label: "May", y: 3600 },
{ label: "Jun", y: 2760 },
{ label: "Jul", y: 2980 },
{ label: "Aug", y: 3700 },
{ label: "Sep", y: 3540 },
{ label: "Oct", y: 1990 },
{ label: "Nov", y: 2340 },
{ label: "Dec", y: 2900 }
]
}
]
});
chart.render();
}
</script>
</html>
<!DOCTYPE HTML>
<html>
<head>
<title>Multi Bar Chart</title>
<meta charset="utf-8">
<meta name="author" content="SidPro" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<meta name="description" content="Showing the sales data of Facecream as a Simple Bar chart" />
<meta name="keywords" content="Multiple,Bar,Chart,Multiple Bar Chart,Line" />
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/canvasjs.min.js"></script>
</head>
<body>
<h2>Showing the data as a Multiple Bar Chart</h2>
<div id="chartContainer" style="height: 600px; width: 100%;"></div>
</body>
<script type="text/javascript">
window.onload = function () {
var chart = new CanvasJS.Chart("chartContainer", {
animationEnabled: true,
title: {
text: "Salse of Facewash vs Facecream"
},
theme: "dark1", //"light1", "light2", "dark1", "dark2"
axisY: {
title: "Facewash Salse (Unit/Month)",
titleFontColor: "#6d78ad",
lineColor: "#6d78ad",
labelFontColor: "#6d78ad",
tickColor: "#6d78ad"
},
axisY2: {
title: "Facecream Salse (Unit/Month)",
titleFontColor: "#51cda0",
lineColor: "#51cda0",
labelFontColor: "#51cda0",
tickColor: "#51cda0"
},
toolTip: {
shared: true
},
legend: {
cursor: "pointer",
itemclick: toggleDataSeries
},
data: [{
type: "column",
color: "#6d78ad",
name: "Facewash Salse (Unit/Month)",
legendText: "Facewash",
showInLegend: true,
dataPoints: [
{ label: "Jan", y: 1200 },
{ label: "Feb", y: 2100 },
{ label: "Mar", y: 3550 },
{ label: "Apr", y: 1870 },
{ label: "May", y: 1560 },
{ label: "Jun", y: 1890 },
{ label: "Jul", y: 1780 },
{ label: "Aug", y: 2860 },
{ label: "Sep", y: 2100 },
{ label: "Oct", y: 2300 },
{ label: "Nov", y: 2400 },
{ label: "Dec", y: 1800 }
]
},
{
type: "column",
color: "#51cda0",
name: "Facecream Salse (Unit/Month)",
legendText: "Facecream",
axisYType: "secondary",
showInLegend: true,
dataPoints: [
{ label: "Jan", y: 2500 },
{ label: "Feb", y: 2630 },
{ label: "Mar", y: 2140 },
{ label: "Apr", y: 3400 },
{ label: "May", y: 3600 },
{ label: "Jun", y: 2760 },
{ label: "Jul", y: 2980 },
{ label: "Aug", y: 3700 },
{ label: "Sep", y: 3540 },
{ label: "Oct", y: 1990 },
{ label: "Nov", y: 2340 },
{ label: "Dec", y: 2900 }
]
}]
});
chart.render();
function toggleDataSeries(e) {
if (typeof (e.dataSeries.visible) === "undefined" || e.dataSeries.visible) {
e.dataSeries.visible = false;
}
else {
e.dataSeries.visible = true;
}
chart.render();
}
}
</script>
</html>
Go Back
No comments:
Post a Comment