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