Stacked Chart with Percentage on every dataPoint - CanvasJS JavaScript Charts
Stacked Chart with Percentage on every dataPoint - CanvasJS JavaScript Charts
by canvasjs
HTML
<script src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>
<br/><!-- Just so that JSFiddle's Result label doesn't overlap the Chart -->
<div id="chartContainer" style="height: 360px; width: 100%;"></div>
JavaScript
var chart = new CanvasJS.Chart("chartContainer",
{
title:{
text: "Stacked Chart with Percent in every stack"
},
toolTip:{
content: "#percent%"
},
data: [
{
indexLabel: "#percent%",
type: "stackedColumn",
dataPoints: [
{ x: new Date(2012, 01, 1), y: 71 },
{ x: new Date(2012, 02, 1), y: 55},
{ x: new Date(2012, 03, 1), y: 50 },
{ x: new Date(2012, 04, 1), y: 65 },
{ x: new Date(2012, 05, 1), y: 95 }
]
},
{
indexLabel: "#percent%",
type: "stackedColumn",
dataPoints: [
{ x: new Date(2012, 01, 1), y: 71 },
{ x: new Date(2012, 02, 1), y: 55},
{ x: new Date(2012, 03, 1), y: 50 },
{ x: new Date(2012, 04, 1), y: 65 },
{ x: new Date(2012, 05, 1), y: 95 }
]
},
{
indexLabel: "#percent%",
type: "stackedColumn",
dataPoints: [
{ x: new Date(2012, 01, 1), y: 71 },
{ x: new Date(2012, 02, 1), y: 55},
{ x: new Date(2012, 03, 1), y: 50 },
{ x: new Date(2012, 04, 1), y: 65 },
{ x: new Date(2012, 05, 1), y: 95 }
]
},
{
indexLabel: "#percent%",
type: "stackedColumn",
dataPoints: [
{ x: new Date(2012, 01, 1), y: 61 },
{ x: new Date(2012, 02, 1), y: 75},
{ x: new Date(2012, 03, 1), y: 80 },
{ x: new Date(2012, 04, 1), y: 85 },
{ x: new Date(2012, 05, 1), y: 105 }
]
},
{
indexLabel: "#percent%",
type: "stackedColumn",
dataPoints: [
{ x: new Date(2012, 01, 1), y: 20 },
{ x: new Date(2012, 02, 1), y: 35},
{ x: new Date(2012, 03, 1), y: 30 },
{ x: new Date(2012, 04, 1), y: 45 },
{ x: new Date(2012, 05, 1), y: 25 }
]
}
]
});
chart.render();