繁体   English   中英

C#中的图表控件

[英]Chart control in C#

图表不显示,没有任何错误。 谁能建议我为什么我的图表没有显示以及这里出了什么问题。

Chart1.Titles.Add("Case");
Chart1.DataSource = dt;
Series s = new Series();
s.XValueMember = Convert.ToString(x);
s.YValueMembers = Convert.ToString(y);
Chart1.DataBind();

您在这里缺少的是将您新创建的系列添加到图表系列集合中。

Chart1.Titles.Add("Case");
Chart1.DataSource = dt;
Series s = new Series();
s.XValueMember = Convert.ToString(x);
s.YValueMembers = Convert.ToString(y);
//one line that you're missing
Chart1.Series.Add(s);
Chart1.DataBind();

首先,您应该设置图表属性。

步骤1:转到图表属性,然后单击系列。

在此处输入图片说明

步骤2:更改系列的名称。 在这里,我将名称设置为Case。 我们也可以更改ChartType

在此处输入图片说明

更改您的代码,如下所示:

    chart1.DataSource = ds;  
    //set the member of the chart data source used to data bind to the X-values of the series  
    chart1.Series["Case"].XValueMember = Convert.ToString(x);  
    //set the member columns of the chart data source used to data bind to the X-values of the series  
    chart1.Series["Case"].YValueMembers = Convert.ToString(y);  
    chart1.Titles.Add("Case"); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM