title: HighCharts populate Pie Chart with data from SQL Database
body: <p>I'm new to web design and am trying to populate a highcharts pie chart with data from SQL Database using C#.  I have done it sucessfully for a Bar Chart but am having trouble with a pie chart.  Basically i have a table tblReport1 that contains 2 fields CustomerType and TotalOrders</p>
  
  <p>I can get it to bring in the values but i can't get my slices to rename to the data in CustomerType field.  I have tried a couple of suggestions on this forum but can't get them to work.  Below is my code any suggestions would be grateful.</p>
  
  <pre><code>private void Report1()
  {
      dsSeries = BindData();
  
      if (dsSeries == null) return;
  
      foreach (DataRow dr in dsSeries.Tables[0].Rows)
      {
          hidXCategories11.Add(dr["CustomerType"]);
      }
  
      foreach (DataRow dr1 in dsSeries.Tables[0].Rows)
      {
          hidValues11.Add(Convert.ToInt32(dr1["TotalOrders"]));
          yValues = hidValues11.ToArray(typeof(object)) as object[];
      }
  
  
      DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
      .InitChart(new Chart { PlotShadow = false })
      .SetTitle(new Title { Text = "Orders by Customer Type" })
      .SetTooltip(new Tooltip { Formatter = "function() { return '&lt;b&gt;'+ this.point.name +'&lt;/b&gt;: '+ this.y +' Orders'; }" })
      .SetPlotOptions(new PlotOptions
      {
          Pie = new PlotOptionsPie
          {
              ShowInLegend = true,
              AllowPointSelect = true,
              DataLabels = new PlotOptionsPieDataLabels
              {
                  Formatter = "function() { return '&lt;b&gt;'+ this.point.name +'&lt;/b&gt;: '+ this.y; }"
              }
          }
      })
  
      .SetSeries(new[]
         {
                 new Series { Type = ChartTypes.Pie, Name = "help!", Data = new Data(yValues) }
         });
  
  
  
      ltrChart.Text = chart.ToHtmlString();
  
  }
  </code></pre>