Hi,
I have a chart whose datasource is set to a locally defined datatable, but initially I only want to display some of the data columns as dataseries as there are too many. Later the user will then pick which extra dataseries they want to see - I currently do this by storing the locally defined datatable in a public dataset which I use to store tables that I might need later (There are no databases involved). This works OK, but I was wondering that as the chart knows the name of the datatable it is using as it datasource that I might be able to add / remove dataseries without having to go off an retrieve a reference to the datatable again.
My Code for setting the chart up initially (The extra dataseries all use the 2nd Y Axis)
I was hoping to be able to do something like this:Code:With chartSingle_Data_File .DataSource = dtSelected_Data_File_and_PMT .ChartAreas(0).AxisX.Title = "WL" .ChartAreas(0).AxisY.Title = "CD" .ChartAreas(0).AxisY2.Enabled = AxisEnabled.True .ChartAreas(0).AxisY2.Title = "Volts" Do While .Series.Count > 0 .Series.RemoveAt(0) Loop For intSeries_Collection_Count = 0 To intSeries_Collection_Total - 1 .Series.Add(dtSelected_Data_File_and_PMT.Columns(intSeries_Collection_Count + 1).ColumnName) .Series(intSeries_Collection_Count).XValueMember = "WL" .Series(intSeries_Collection_Count).YValueMembers = dtSelectedFile.Columns(intSeries_Collection_Count + 1).ColumnName ' .Series(intSeries_Collection_Count).ChartType = SeriesChartType.Line .Series(intSeries_Collection_Count).YAxisType = AxisType.Primary Next intSeries_Collection_Count End With
ThanksCode:chartSingle_Data_File.datasource.Series.Add.Columns(intSeries_Collection_Count + 1)
Kristian




Reply With Quote
