Results 1 to 7 of 7

Thread: Charts (Not Excel) and referencing the datasource when it's table is out of scope

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2012
    Location
    Wiltshire, England
    Posts
    211

    Question Charts (Not Excel) and referencing the datasource when it's table is out of scope

    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)

    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
    I was hoping to be able to do something like this:

    Code:
    chartSingle_Data_File.datasource.Series.Add.Columns(intSeries_Collection_Count + 1)
    Thanks

    Kristian
    Last edited by kriswork; Sep 28th, 2015 at 07:25 AM. Reason: increase clarity

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width