I drew bar chart using basic bar chart sample codes. But I wanna draw bar chart with various colors.
I used stack option and It works. But num value cannot be used like next codes.
Can't I use num value like '1' in X: "1" or '1':15.7 ?
It occurs errors like attacted file.
Please tell me how to make codes. ^^
<script>
function createChart() {
var chartData = [
{ X: "1" , '1':15.7, '2': 0, '3': 0, '4': 0, '5':0},
{ X: "2" , '2':16.7, '1': 0, '3': 0, '4': 0, '5':0},
{ X: "3" , '3':20, '1': 0, '2': 0, '4': 0, '5':0},
{ X: "4" , '4':23.5, '1': 0, '2': 0, '3': 0, '5':0},
{ X: "5" , '5':26.6, '1': 0, '2': 0, '3': 0, '4':0}
];
$("#chart").kendoChart({
dataSource: {
data: chartData
},
theme: $(document).data("kendoSkin") || "default",
title: {
text: "Internet Users"
},
legend: {
position: "bottom"
},
seriesDefaults: {
type: "column",
stack: true
},
series:
[
{ field:"1", name: "1", color:"red" },
{ field:"2", name: "2" },
{ field:"3", name: "3" },
{ field:"4", name: "4" },
{ field:"5", name: "5" }
],
valueAxis: {
labels: {
format: "{0}%"
}
},
categoryAxis: {
field:'X'
},
tooltip: {
visible: true,
format: "{0}%"
}
});
}
$(document).ready(function() {
setTimeout(function() {
createChart();
// Initialize the chart with a delay to make sure
// the initial animation is visible
}, 400);
$(document).bind("kendo:skinChange", function(e) {
createChart();
});
});
</script>