簡體   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