title: Pass Data String as parameter to a Function for HighCharts
body: <p>I know this title seems a bit odd, i couldn't explain it better.</p>
  
  <p>Here is what i need. I have this javascript function and i need to pass the data as a String variable to it:</p>
  
  <pre><code>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]
              ]
          }]
      });
  }
  </code></pre>
  
  <p>I need to pass this data as a parameter to my function</p>
  
  <blockquote>
    <p>[
                        ['Firefox',   45.0],
                        ['IE',       26.8],
                        {
                            name: 'Chrome',
                            y: 12.8,
                            sliced: true,
                            selected: true
                        },
                        ['Safari',    8.5],
                        ['Opera',     6.2],
                        ['Others',   0.7]
                    ]</p>
  </blockquote>
  
  <p>How can i do it?</p>
  
  <p>I want it to look like something like this</p>
  
  <pre><code>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}: &lt;b&gt;{point.percentage}%&lt;/b&gt;',
              percentageDecimals: 1
          },
          plotOptions: {
              pie: {
                  allowPointSelect: true,
                  cursor: 'pointer',
                  dataLabels: {
                      enabled: true,
                      color: '#000000',
                      connectorColor: '#000000',
                      formatter: function() {
                          return '&lt;b&gt;'+ this.point.name +'&lt;/b&gt;: '+ this.percentage +' %';
                      }
                  }
              }
          },
          series: [{
              type: 'pie',
              name: 'Browser share',
              data: dataString
          }]
      });
  }
  </code></pre>
  
  <p>I have tried solution by @moonwave99 :</p>
  
  <pre><code>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]
  ];
  </code></pre>
  
  <p>and </p>
  
  <pre><code>...........
          series: [{
              type: 'pie',
              name: 'Browser share',
              data:  JSON.stringify(browsers) 
          }]
  ............
  </code></pre>
  
  <p>And my outcome is this:</p>
  
  <p><img src="https://i.stack.imgur.com/Mb6e8.png" alt="enter image description here"></p>
  
  <p><strong>Solution</strong> : <a href="http://jsfiddle.net/USzVy/1/" rel="nofollow noreferrer">http://jsfiddle.net/USzVy/1/</a></p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>Thanks</p>