I know this name seems a little strange, I could not explain it better.
This is what I need. I have this javascript function, and I need to pass the data as a string variable:
var chart; function drawChart() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, series: [{ type: 'pie', name: 'Browser share', data: [ ['Firefox', 45.0], ['IE', 26.8], { name: 'Chrome', y: 12.8, sliced: true, selected: true }, ['Safari', 8.5], ['Opera', 6.2], ['Others', 0.7] ] }] }); }
I need to pass this data as a parameter to my function
[['Firefox', 45.0], ['IE', 26.8], {name: "Chrome", y: 12.8, sliced: true, selected: true}, ['Safari', 8.5], ['Opera ', 6.2], [' Other ', 0.7]]
How can i do this?
I want it to look something like this
var chart; function drawChart(dataString) { chart = new Highcharts.Chart({ chart: { renderTo: 'container', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, title: { text: 'Browser market shares at a specific website, 2010' }, tooltip: { pointFormat: '{series.name}: <b>{point.percentage}%</b>', percentageDecimals: 1 }, plotOptions: { pie: { allowPointSelect: true, cursor: 'pointer', dataLabels: { enabled: true, color: '#000000', connectorColor: '#000000', formatter: function() { return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %'; } } } }, series: [{ type: 'pie', name: 'Browser share', data: dataString }] }); }
I tried @ moonwave99 solution:
var browsers = [ ['Firefox', 45.0], ['IE', 26.8], { name: 'Chrome', y: 12.8, sliced: true, selected: true }, ['Safari', 8.5], ['Opera', 6.2], ['Others', 0.7] ];
and
........... series: [{ type: 'pie', name: 'Browser share', data: JSON.stringify(browsers) }] ............
And my result is this:

Solution : http://jsfiddle.net/USzVy/1/
var browsers = [ ['Firefox', 45.0], ['IE', 26.8], { name: 'Chrome', y: 12.8, sliced: true, selected: true }, ['Safari', 8.5], ['Opera', 6.2], ['Others', 0.7] ]; function drawChart() { var data_str = JSON.stringify(browsers); var options ={ chart: { renderTo: 'container', plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false }, series: [{ type: 'pie', name: 'Browser share', data: JSON.parse(data_str) }] } chart = new Highcharts.Chart(options); }
thanks