MSDN charts changing point values realtime?

后端 未结 4 479
感动是毒
感动是毒 2020-12-18 08:08

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 manuall

相关标签:
4条回答
  • 2020-12-18 08:17

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

    0 讨论(0)
  • 2020-12-18 08:30

    DataTable dtChartDataSource = Input from your 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 the x axis data and Y axis values to the Column chart.

    Hope its helps

    0 讨论(0)
  • 2020-12-18 08:34

    I've just found out that SetValueY() does not update the maximum interval in the Y axis. Therefore, if your current maximum is 0, it will not show anything higher than 0.

    0 讨论(0)
  • 2020-12-18 08:37

    I do this:

        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 讨论(0)
提交回复
热议问题