You must be logged in to post your query.
Home › Forums › Chart Support › Stacked Column Wrong Label X
Tagged: Label Josn, stacked column
Hello I have Code Like this
var jsonData = { "Kontrak": [ {"total": "48","kdcab": "JKT"}, {"total": "33","kdcab": "BKL"}, {"total": "25","kdcab": "PK4A"} ], "Tetap": [ {"total": "165","kdcab": "JKT"}, {"total": "127","kdcab": "BKL"}, {"total": "52","kdcab": "PK4A"} ], "Honorer": [ {"total": "2","kdcab": "JKT"} ], "RUPS": [ {"total": "13","kdcab": "JKT"} ], "Kontrak Project": [ {"total": "1","kdcab": "JKT"} ], "Percobaan": [ {"total": "1","kdcab": "PK4A"} ], "MITRA": [ {"total": "7","kdcab": "PK4A"} ] }; var dataPoints = []; for (var key in jsonData) { var data = jsonData[key]; var series = { type: "stackedColumn", showInLegend: true, name: key, dataPoints: [] }; for (var i = 0; i < data.length; i++) { series.dataPoints.push({ label: data[i].kdcab, y: parseInt(data[i].total) }); } dataPoints.push(series); } // Create the chart var chart = new CanvasJS.Chart("chartContainer", { animationEnabled: true, title: { text: "Stacked Column Chart" }, axisY: { title: "Total" }, toolTip: { shared: true }, data: dataPoints }); chart.render();
But its Wrong Label and value ? JKT Not available in X label ? How to solve it
@danura,
In case of Stacked Charts, datapoints across multiple dataseries are aligned based on x-values and not the labels. Passing x-value along with label should work fine in this case. Please take a look at this JSFiddle for an example.
— Ananya Deka Team CanvasJS
You must be logged in to reply to this topic. Login/Register