title: Javascript, using Highcharts to display a chart of rankings with JSON Data
body: <p>I am trying to use javascript Highcharts to display a chart of rankings from JSON data.  I can't seem to get the chart to display.</p>
  
  <p>This is the javascript code:</p>
  
  <pre><code>$(document).ready(function() {
  var options = {
      chart: {
              renderTo: 'drawing',
              zoomType: 'x',
              width: 900,
              height: 222
      },
      exporting: {
          enabled:true      
      },
      title: {
          text: url+' - '+keyword
      },
      credits: {
          text: '****',
          href: 'http://***/'
      },
      xAxis: {
          type: 'datetime',
          dateTimeLabelFormats: {
              day: '%b %e '   
          }
      },
      yAxis: [{
          //min: 1,
          allowDecimals: false,
          reversed: true,
          ///: .2,
          //maxPadding: .2,
  
          title: {
              text: 'Rankings'
          }
      },],
  
      tooltip: {
          crosshairs: true,
          shared: true
      },
      series: [{}]
  };  
  
  var url =  "http://*******/chart.php";
      $.getJSON(url,  function(data) {
  
          $.each(data, function(arrayID,group) {
              $.each(group.data, function(id,val) {
              arg = val[0].replace(/Date.UTC\((.*?)\)/, '$1').split(',');
              var timestamp = Date.UTC.apply( null , arg );
              date=new Date(timestamp);
              data[arrayID].data[id][0] = timestamp;
              });
          });
  
          options.series[0].data = data;
          var chart = new Highcharts.Chart(options);
      });                          
  });
  </code></pre>
  
  <p>Our PHP Script gives us this JSON:</p>
  
  <pre><code>[{"name":"Google Rank","data":[["Date.UTC(2013,04,05)","23"],["Date.UTC(2013,04,04)","23"],["Date.UTC(2013,04,03)","22"],["Date.UTC(2013,04,02)","24"],["Date.UTC(2013,04,01)","26"],["Date.UTC(2013,03,31)","24"],["Date.UTC(2013,03,30)","24"],["Date.UTC(2013,03,29)","25"],["Date.UTC(2013,03,28)","25"],["Date.UTC(2013,03,27)","25"],["Date.UTC(2013,03,26)","26"],["Date.UTC(2013,03,25)","25"],["Date.UTC(2013,03,24)","24"],["Date.UTC(2013,03,23)","-"],["Date.UTC(2013,03,22)","10"],["Date.UTC(2013,03,21)","10"],["Date.UTC(2013,03,20)","10"],["Date.UTC(2013,03,19)","10"],["Date.UTC(2013,03,18)","10"],["Date.UTC(2013,03,17)","10"],["Date.UTC(2013,03,16)","9"],["Date.UTC(2013,03,15)","9"],["Date.UTC(2013,03,14)","9"],["Date.UTC(2013,03,13)","9"],["Date.UTC(2013,03,12)","9"]],"visible":"true","pointInterval":"86400000","showInLegend":"false"},{"name":"Bing Rank","data":["Date.UTC(2013,2,9)",9],"visible":"true","pointInterval":"86400000","showInLegend":"false"}]
  </code></pre>
  
  <p>Note the JSON data represents numbers as strings which could be a problem.</p>
  
  <p>PHP Code which generates the JSON data:</p>
  
  <pre><code>$googledata = array();
  while($gkdata = mysql_fetch_assoc($keywordquery)){
      $explodedate = explode("-", $gkdata['date']);
      $year = $explodedate[0];
      $month = $explodedate[1];
      $day = $explodedate[2];    
      $googledata[] = array(
          "".$year.",".$month.",".$day."",  
          $gkdata['grank']     //$gkdata['grank'] should be a number, but is sometimes a dash so it's cast to an accommodating datatype: string.
      );
  }
  
  $chartdata = array(
      array(
          "name" =&gt; 'Google Rank',
          "data" =&gt; $googledata,
          "visible" =&gt; 'true',
          "pointInterval" =&gt; '86400000',
          "showInLegend" =&gt; 'false',
      ),
      array(
          "name" =&gt; 'Bing Rank',
          "data" =&gt; array(
              'Date.UTC(2013,2,9)', 
              9
          ),
          "visible" =&gt; 'true',
          "pointInterval" =&gt; '86400000',
          "showInLegend" =&gt; 'false',
      )
  );
  </code></pre>
  
  <p>The Highcharts won't display anything other than the chart itself with no data.  The <code>Date.UTC(2013,03,12)</code> is supposed to go on the X-Axis &amp; the number next to it is supposed to be the rank number.  Can anyone see what is wrong?</p>