title: How do I pass a simple JSON array to jQuery then Flot?
body: <p>I've been Googling for a while trying to find a solution to my problem, but everything I've found which comes close is too complicated!</p>
  
  <p>I have a working Flot pie chart. It receives a JSON array from Django in this format:</p>
  
  <p><code>[0, 3, 5, 6, 7]</code></p>
  
  <p>The array represents the number of instances of each series (i.e. 0 instances of Series 1, 3 instances of Series 2 etc etc).</p>
  
  <p>That array is then shown in a simple Flot Pie Chart using this code (<code>theData</code> is the array above):</p>
  
  <pre><code>function loadTotalChart(theData) {
    $.plot($("#total-pie-chart"), theData ,
    {
      series: {
          pie: { 
              show: true
      }
          },
  label: {
      show:true
  },
  legend: {
      show: false
      },
  grid: {
      hoverable: true,
      }
     });
    }
  </code></pre>
  
  <p>The problem is that the labels are undefined in the array, so my pie chart shows "Undefined: 30%" or similar for each series. </p>
  
  <p>What I'm trying to do is add labels for each series: the labels are the same for every instance of the chart.</p>
  
  <p>How can I take the JSON array, add labels and then pass that to Flot??</p>
  
  <p>Thanks very much!</p>
  
  <p>EDIT:</p>
  
  <p>Thanks to <a href="https://stackoverflow.com/users/983969/liam-mccann">Liam McCann</a>, I now have this code to plot the chart only if there is data:</p>
  
  <pre><code>function checkJsons(otherJson,newJson)
  {
  for (var key in otherJson) {if(otherJson[key] != newJson[key]) {return false;}}
  return true;
  }
  
  function loadWeekChart(theData)
  {
  var blankData = [0, 0, 0, 0, 0];
  if(checkJsons(blankData,theData)){$('#week-pie-chart').empty().append('Nothing to show yet');} 
  
  else { $.plot($("#week-pie-chart"), theData ,
      {
          series: {
              pie: { 
                  show: true
              }
          }
      }); }
   } 
  </code></pre>