2016-01-22 55 views
-1

我搜索了很多关于在C#中创建饼图的主题。现在我从工具箱拖出一个图表,我打算创建一个饼图。如何用C#.NET创建饼图

UssagePieChart.Series["CPU"].ChartType = SeriesChartType.Pie; 
UssagePieChart.Series["RAM"].ChartType = SeriesChartType.Pie; 

我有2号

int _xValue = Int32.Parse(dataGridView1.Rows[0].Cells[1].Value.ToString()); 
int _yValue = Int32.Parse(dataGridView1.Rows[0].Cells[2].Value.ToString()); 

我可以结合两个数字到每个系列饼图CPU(_xValue)和RAM(_yValue)的?

谢谢。

+0

您是否要求提供类似于您正在使用的任何图表控件的文档中找到的示例? *你有没有检查过文件? –

+0

这是用于winforms,wpf,asp还是其他? –

+0

我正在使用winform先生 – Ryan

回答

1

你的HTML应该是这个样子: -

<asp:Chart ID="xxyyzz" runat="server" ImageType="Jpeg"> 
     <Series> 
      <asp:Series Name="xx" YValueType="Int32" 
       ChartType="Pie" ChartArea="Default" Legend="yyy" 
       ToolTip="whatever your wanna do"> 
      </asp:Series> 
     </Series> 
     <ChartAreas> 
      <asp:ChartArea Name="Default"> 
       <Area3DStyle Enable3D="True" /> 
      </asp:ChartArea> 
     </ChartAreas> 
     <Legends> 
      <asp:Legend Name="yyy"> 
      </asp:Legend> 
     </Legends> 
    </asp:Chart> 

查找什么系列,ChartAreas传说做。

虽然你可以在C#侧像处理两个值: -

// key, value pair by creating a dictionary of your x and y. 
xxyyzz.Series["xx"].Points.DataBindXY(dictionaryArray.Keys, dictionaryArray.Values); 
xxyyzz.Series["xx"]["PieLabelStyle"] = "Outside"; 

基本上在哪里,你需要创建一个键,值词典对CPU和内存的值。希望这给你一些方向。剩下的就在你身上。

+0

我会尽力做到这一点。 TKS – Ryan