//Update the DataTable with new Data and Rebind to the chart private void updateChart() { recordTable.Rows.Add(updateCount, float.Parse(lblIdleTime.Text), float.Parse(lblDiskTime.Text) * 10, float.Parse(lblAvgDiskQ.Text) * 100, float.Parse(lblAvgTrans.Text) * 1000); try { HDchart.DataBind(); } catch (NullReferenceException ex) { //Occurs on forced exit } }
//Initialize the chart settings and the DataTable private void setTableChart() { recordTable.Columns.Add("Count", typeof(int)); recordTable.Columns.Add("Idle Time", typeof(float)); recordTable.Columns.Add("Disk Time", typeof(float)); recordTable.Columns.Add("Avg Disk Queue", typeof(float)); recordTable.Columns.Add("Avg Transfer Req", typeof(float)); HDchart.Series.Add("% Disk Idle Time (1)"); HDchart.Series["% Disk Idle Time (1)"].ChartType = SeriesChartType.Line; HDchart.Series["% Disk Idle Time (1)"].XValueMember = "Count"; HDchart.Series["% Disk Idle Time (1)"].YValueMembers = "Idle Time"; HDchart.Series.Add("% Disk Time (10)"); HDchart.Series["% Disk Time (10)"].ChartType = SeriesChartType.Line; HDchart.Series["% Disk Time (10)"].XValueMember = "Count"; HDchart.Series["% Disk Time (10)"].YValueMembers = "Disk Time"; HDchart.Series.Add("Avg. Disk Queue (100)"); HDchart.Series["Avg. Disk Queue (100)"].ChartType = SeriesChartType.Line; HDchart.Series["Avg. Disk Queue (100)"].XValueMember = "Count"; HDchart.Series["Avg. Disk Queue (100)"].YValueMembers = "Avg Disk Queue"; HDchart.Series.Add("Avg. Transfer Req (1000)"); HDchart.Series["Avg. Transfer Req (1000)"].ChartType = SeriesChartType.Line; HDchart.Series["Avg. Transfer Req (1000)"].XValueMember = "Count"; HDchart.Series["Avg. Transfer Req (1000)"].YValueMembers = "Avg Transfer Req"; HDchart.ChartAreas[0].AxisY.Maximum = 100; HDchart.ChartAreas[0].AxisX.Minimum = 0; HDchart.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Seconds; HDchart.ChartAreas[0].CursorX.IsUserEnabled = true; HDchart.ChartAreas[0].CursorX.AutoScroll = true; HDchart.DataSource = recordTable; HDchart.DataBind(); }