How to bind data to chart in winforms and refresh

2019-02-22 02:29发布

问题:

I tried to bind chart to generatedSequence of type List<float>. How to update chart control after binding?

I tried this but with no luck:

chart1.DataSource = new BindingList<float>(chartSequence);
chart1.DataBind();

chart1.Update();

回答1:

Don't forget set DataSource property of Series in chart property.

Set XValueMember and YValueMembers from code:

chart1.Series.First().XValueMember = "X";
chart1.Series.First().YValueMembers = "Y";

Tutorial: Creating a Basic Chart