Thursday, 12 September 2013

Parsing ALL Highcharts Options from JSON

Parsing ALL Highcharts Options from JSON

I am currently wanting to specify all Highcharts chart options via a JSON
file. I've seen plenty of examples on how to pull just the data series
from JSON and understand that.
Here is an example of some chart options that I would like to convert to JSON
var optionsChart2 = {
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: 'Year End Rating: Distribution'
},
xAxis: {
categories: [
'Ineffective',
'Inconsistent',
'Proficient',
'Advanced',
'Exceptional'
]
},
yAxis: {
min: 0,
title: {
text: 'Percentage'
}
},
series: [{data: 25,50,65,32,78}]
};
What is the best JSON format for that (for the purpose of pulling in via
AJAX and then parsing back into options)?
I've seen the following code for parsing just the data:
$.getJSON('data.json', function(data) {
options.series[0].data = data;
var chart = new Highcharts.Chart(options);
});
How would I then use the new version of the JSON file (as above)?
I'm sorry if this is too vague. I'm relatively new to this and need some
help!

No comments:

Post a Comment