Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I want to use MSDN charts to represent realtime data i'm getting from a telnet application. For testing purpose i have added a button to alter the chart manually. I manually made the chart and it has 0 to 5 points on the X axis with values different values on the X. The series is named by it's default "Series1".

I tried the following:

chart1.Series["Series1"].Points.ElementAt(0).SetValueY(40); //Nothing happens

chart1.Series["Series1"].Points.ElementAt(1).SetValueXY(1, 20); //Nothing happens

chart1.Series["Series1"].Points[0].SetValueY(40); //Nothing happens

chart1.Series["Series1"].Points.ElementAt(1).YValues.SetValue(10, 0); //Nothing happens

chart1.Series["Series1"].Points.Clear(); //Removes all points like it should.

So how do i change datapoint entries on runtime?

-EDIT- If i modify a point using chart1.Series["Series1"].Points.ElementAt(0).SetValueY(40); and add a point after this with chart1.Series["Series1"].Points.AddXY(1, 40); the modified point does snap into it's modified place. The conclusion is that modifying does change the points Y value but the graph does not get refreshed. The function AddXY() seems to autorefresh. I cannot seem to find a way to call Refresh() manually.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
472 views
Welcome To Ask or Share your Answers For Others

1 Answer

Call chart1.Refresh() after changing the value; it will force a redraw of the chart, picking up the new values.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share

548k questions

547k answers

4 comments

86.3k users

...