Stacking of column in stackedColumn chart with same X values - CanvasJS JavaScript Charts
Stacking of column in stackedColumn chart with same X values - 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: "Stacking of dataPoints with same X values"
},
data: [
{
type: "stackedColumn",
dataPoints: [
{x: new Date("2017-03-10"), y:600},
{x: new Date("2017-04-06"), y:504}, //<--first column in April
{x: new Date("2017-05-03"), y:504}, //<--first column in May
{x: new Date("2017-06-05"), y:504},
{x: new Date("2017-08-07"), y:714},
{x: new Date("2017-09-04"), y:714},
{x: new Date("2017-10-02"), y:504},
{x: new Date("2017-11-06"), y:504},
{x: new Date("2017-12-04"), y:540}
]
},
{
type: "stackedColumn",
dataPoints: [
{x: new Date("2017-04-06"), y:600}, //<--second column in April which is stacked!
{x: new Date("2017-05-03"), y:504}, //<--second column in May
]
}
]
});
chart.render();