I am trying to draw a multiline chart from a datatable, my datatable looks like that
and the chart should like that:
I tried to do it using this code but it didn't work:.
DataTable dt = GetParametertable(alternative, criterionRating);
DataSet ds = new DataSet();
ds.Tables.Add(dt);
line_chart.Series.Add("series1");
line_chart.Series["series1"].ChartType = SeriesChartType.Line;
line_chart.DataSource = dt;
You need to add multiple series and specify the YValueMembers field for each series.
line_chart.Series.Add("series1");
line_chart.Series["series1"].ChartType = SeriesChartType.Line;
line_chart.Series["series1"].YValueMembers = "Alt1";
line_chart.Series.Add("series2");
line_chart.Series["series2"].ChartType = SeriesChartType.Line;
line_chart.Series["series2"].YValueMembers= "Alt2";
line_chart.Series.Add("series3");
line_chart.Series["series3"].ChartType = SeriesChartType.Line;
line_chart.Series["series3"].YValueMembers = "Alt3";
line_chart.DataSource = dt;
Sorry, I can't comment for now so I'm gonna post this as an answer.
Have you tried calling DataBind() and Update() after assigning DataSource?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.