Bhagya Bhagya - 5 months ago 54
JSON Question

Parse json and give to category in Highcharts

I am using Highcharts and want to parse JSON and assign to categories part.

This is my chart data:

var chartData = {
"chart" :[
{name: "kolkata",categories: ["male", "female"]},
{name: "Mumbai",categories: ["male", "female"]}
]
}


I tried this:

var category = [];
var Count = chartData.chart;
for (var i=0; i< Count.length; i++) {
category.push({name : chartData.chart[i].name, categories : chartData.chart[i].categories})
}


Finally:

xAxis: {
categories: category
}


The category not coming properly on x axis. Does anybody have an idea why it's not?

Answer

For this you need to include library

include following library

<script src="http://blacklabel.github.io/grouped_categories/grouped-categories.js"></script>