Do MSDN charts change point values ​​in real time?

I want to use MSDN graphics to represent the real-time data that I get from a telnet application. For testing purposes, I added a button to manually modify the chart. I manually made a chart, and it has 0 to 5 points on the X axis with the values ​​of different values ​​on X. The series is called "Series1" by default.

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 () .// Deletes all the necessary points.

So how do I change the data records in runtime?

-EDIT- If I change the point with chart1.Series["Series1"].Points.ElementAt(0).SetValueY(40);and add a point after that with chart1.Series["Series1"].Points.AddXY(1, 40);, the changed point snaps the changed place into it. The conclusion is that the change changes the value of the Y point, but the graph is not updated. The AddXY () function seems autorefresh. I cannot find a way to call Refresh () manually.

+3
source share
4 answers

Call chart1.Refresh()after changing the value; this will force the chart to be redrawn, picking up new values.

+7
source

, SetValueY() Y. , 0, 0.

+2

I'm doing it:

    public static void Refresh(this Chart chart) // update changed data
    {
        chart.Series[0].Points.AddXY(1, 1);
        chart.Update();
        chart.Series[0].Points.RemoveAt(chart.Series[0].Points.Count-1);
    }

chart1.Refresh ();

0
source

DataTable dtChartDataSource = Input from the side.

foreach (DataColumn dc in dtChartDataSource.Columns)
{
   //a series to the chart
 if (chart.Series.FindByName(dc.ColumnName) == null)
 {
      series = dc.ColumnName;
      chart.Series.Add(series);
      chart.Series[series].ChartType = SeriesChartType.Column;

    foreach (DataRow dr in dtChartDataSource.Rows)
    {
        double dataPoint = 0;
        double.TryParse(dr[dc.ColumnName].ToString(), out dataPoint);

        Yourchart.Series[seriesName].Points.AddXY("customStringsOnAxis", dataPoints);
    }
 }
}

It will add x-axis data and y-axis values ​​to the column table.

Hope this helps

0
source

All Articles