I have the following json data
var json= {
"PFTs_likely_to_change": [
[16]
],
"PFTs_likely_to_remain_unchanged": [
[2]
]
}
This data is coming through url
var data=$.getJSON('{% url "PFTpercentChange" %}');
then I parse the json data
var json = JSON.parse(data);
Now I want to create column chart using highcharts.The code is
$(document).ready(function() {
$("#container").dialog({
autoOpen: false,
width: 600,
height: 500
});
$("#btnclick").click(function() {
$("#container").dialog("open");
//var json = JSON.parse(data);
var json = {
"PFTs_likely_to_change": [
[16]
],
"PFTs_likely_to_remain_unchanged": [
[2]
]
};
//var chart1; // globally available
chart1 = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column' // change with your choice
},
title: {
text: 'Change in Plant Functional Types'
},
xAxis: {
categories: ['Change in Plant Functional Types']
// Should be replace with JSON
},
yAxis: {
title: {
text: 'Percentage(%)'
}
},
series: [{ //Should be replace with JSON
name: 'PFTs likely to change',
data: [88]
}, {
name: 'PFTs likely to remain unchanged',
data: [12]
}]
});
});
});
How can I do this dynamically?
$.getJSONreturns anjqXHRobject. You're trying toJSON.parsethat object and it's working?