Hi All,
I have a bar chart which has month's in the category axis and 2 metrics in the other axis. The problem which I am facing is that the month data are not aggregating.
Here is the code which have.From this,it is clear that am getting extra "Jan" at the category axis which don't want.I want that value to be aggregated in the same "Jan" which is present first. How can achieve this?
Kindly help me fix this.
<!DOCTYPE html>
<html>
<head>
<base href="http://demos.telerik.com/kendo-ui/bar-charts/index">
<style>html { font-size: 14px; font-family: Arial, Helvetica, sans-serif; }</style>
<title></title>
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.1028/styles/kendo.common.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.1028/styles/kendo.moonlight.min.css" />
<link rel="stylesheet" href="//kendo.cdn.telerik.com/2016.3.1028/styles/kendo.moonlight.mobile.min.css" />
<script src="//kendo.cdn.telerik.com/2016.3.1028/js/jquery.min.js"></script>
<script src="//kendo.cdn.telerik.com/2016.3.1028/js/kendo.all.min.js"></script>
</head>
<body>
<div id="example">
<div class="demo-section0 k-content wide">
<div>
<button id="show_col1" class="k-button" clicked="true" > Total Visits</button>
<button id="hide_col1" class="k-button">Unique Visitors</button>
</div>
<div id="tabstrip">
<ul>
<li class="k-state-active">Quarterly</li>
<li>Monthly</li>
<li>Weekly</li>
</ul>
<div class="demo-section k-content wide">
<div id="chart"></div>
</div>
<div class="demo-section2 k-content wide">
<div id="chart2"></div>
</div>
<div> Weekly Content</div>
</div>
</div>
<script>
function createChart() {
$("#chart").kendoChart({
title: {
text: "Site Visitors Stats \n /thousands/"
},
legend: {
visible: false
},
seriesDefaults: {
type: "bar"
},
series: [{
name: "Total Visits",
data: [250000, 324000],
}, {
name: "Unique visitors",
data: [235000, 298000]
}],
valueAxis: {
max: 350000,
line: {
visible: false
},
minorGridLines: {
visible: true
},
labels: {
rotation: "auto"
}
},
categoryAxis: {
categories: ["Q1", "Q2", "Q3", "Q4"],
majorGridLines: {
visible: false
}
},
tooltip: {
visible: true,
template: "#= series.name #: #= value #"
}
});
$("#show_col1").on("click", function() {
var chart = $("#chart").data("kendoChart");
chart.options.series[1].visible = false;
chart.options.series[0].visible = true;
chart.refresh();
});
$("#hide_col1").on("click", function() {
var chart = $("#chart").data("kendoChart");
chart.options.series[0].visible = false
chart.options.series[1].visible = true;
chart.refresh();
});
}
function createChart2() {
$("#chart2").kendoChart({
title: {
text: "Site Visitors Stats \n /thousands/"
},
legend: {
visible: false
},
seriesDefaults: {
type: "bar"
},
series: [{
name: "Total Visits",
data: [56000, 63000, 74000, 91000, 117000, 138000,10000],
}, {
name: "Unique visitors",
data: [52000, 34000, 23000, 48000, 67000, 83000,10000]
}],
valueAxis: {
max: 140000,
line: {
visible: false
},
minorGridLines: {
visible: true
},
labels: {
rotation: "auto"
}
},
categoryAxis: {
categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun","Jan"],
majorGridLines: {
visible: false
}
},
tooltip: {
visible: true,
template: "#= series.name #: #= value #"
}
});
$("#show_col1").on("click", function() {
var chart = $("#chart2").data("kendoChart");
chart.options.series[1].visible = false;
chart.options.series[0].visible = true;
chart.refresh();
});
$("#hide_col1").on("click", function() {
var chart = $("#chart2").data("kendoChart");
chart.options.series[0].visible = false
chart.options.series[1].visible = true;
chart.refresh();
});
}
$(document).ready(function() {
$("#tabstrip").kendoTabStrip({
animation: {
open: {
effects: "fadeIn"
}
}
});
});
$(document).ready(createChart2);
$(document).bind("kendo:skinChange", createChart2);
$(document).ready(createChart);
$(document).bind("kendo:skinChange", createChart);
</script>
</div>
</body>
</html>
Thanks,
Lakshman