Having a go at this for a while not and gaining ground....just can't seem to bring it home to what I need it to be.
Scenario:
In memory datatable.
I have coded a new dataset and added the datatable to it.
I created a dataview and coded it to filter the data.
What I need to do is filter the data, then chart a series, then change the filter, then chart the next series. I can't get that sorted out.
To prove the filtering is working I added several other dgv's to the form and use the filtered table results as their data source. The data is being filtered correctly in each of the dgvs.
What's not working is the charting portion. As I add each new filter for the next series, only the last filtered data is actually getting drawn to the chart.
Here's that part of my code. It's in a checkbox checkchanged sub. I have several more to do. If I can get this filtering working then the rest will all fall into place without assistance.
Pic to show the filtered data in the DGV's is correct
Scenario:
In memory datatable.
I have coded a new dataset and added the datatable to it.
I created a dataview and coded it to filter the data.
What I need to do is filter the data, then chart a series, then change the filter, then chart the next series. I can't get that sorted out.
To prove the filtering is working I added several other dgv's to the form and use the filtered table results as their data source. The data is being filtered correctly in each of the dgvs.
What's not working is the charting portion. As I add each new filter for the next series, only the last filtered data is actually getting drawn to the chart.
Here's that part of my code. It's in a checkbox checkchanged sub. I have several more to do. If I can get this filtering working then the rest will all fall into place without assistance.
VB.NET:
'**********************************Captured Data Chart Setup************************************************
'load datagridview1 with data
DataGridView1.DataSource = SourceTable
If CheckBox1.Checked = True Then
With Me.Chart1.ChartAreas(0)
Chart1.DataSource = SourceTable
.AxisX.Interval = 0.1
.AxisY.Interval = 15
.AxisX.IsLabelAutoFit = True
.AxisX.LabelAutoFitStyle = DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont
.AxisY.LabelAutoFitStyle = DataVisualization.Charting.LabelAutoFitStyles.DecreaseFont
.AxisX.LabelStyle.Angle = -45
.AxisX.Title = "Lift"
.AxisY.Title = "CFM"
End With
'build a new dataset
Dim andata = New DataSet("andata")
andata.Tables.Add(SourceTable)
'create and filter dataview
Dim dv As DataView
dv = New DataView(andata.Tables(0), "port = 'port 1' ", "port", DataViewRowState.CurrentRows)
DataGridView2.DataSource = dv
Chart1.DataSource = DataGridView2
Chart1.Series(0).Points.Clear()
For Count As Integer = 0 To Me.DataGridView2.Rows.Count - 2
Chart1.Series(1).Points.AddXY(DataGridView2.Item(0, Count).Value, DataGridView2.Item(2, Count).Value)
Next
dv = New DataView(andata.Tables(0), "port = 'port 2' ", "port", DataViewRowState.CurrentRows)
DataGridView3.DataSource = dv
Chart1.DataSource = DataGridView3
Chart1.Series(1).Points.Clear()
For Count As Integer = 0 To Me.DataGridView3.Rows.Count - 2
Chart1.Series(1).Points.AddXY(DataGridView3.Item(0, Count).Value, DataGridView3.Item(2, Count).Value)
Next
Pic to show the filtered data in the DGV's is correct