none
VB.NET 2010 How can I select a series or data point on a chart?

    Question

  • I'm want to write some code that will allow the user to select a series (or a specific point) an a chart and based on what they choose pull up more information.  In VB6 there was an event for this, but I cant seem to find any event that will work.  (the Click event does not seeem to show what was clicked on)
    Saturday, June 05, 2010 5:25 AM

Answers

  • Hi you can specify a selection of points that fall into a paticular range and customize them with the following:

    this code assumes that any datapoint with a value over 100 is green and anything under 100 gets coloured red

        
        For Each s in Chart1.Series
          For Each p As DataPoint In s.Points
            If p.YValues(0) >100 Then
              p.Color = Color.Green
            Else
              p.Color = Color.Red
            End If
          Next
        Next

    regards

    enex

    Thursday, June 10, 2010 12:58 PM

All replies

  • I figured it out.  I just needed to use the chart1.hitresult method in the MouseDown event.  It allows me to determine exactly what what clicked on.
    Saturday, June 05, 2010 6:35 AM
  • Hi,

     

    I am actually looking to select a series of points on the chart control and change the bar colors in that region. Could you please paste the code as to how to select a series of points on the chart control?

     

     

    Thursday, June 10, 2010 12:53 PM
  • Hi you can specify a selection of points that fall into a paticular range and customize them with the following:

    this code assumes that any datapoint with a value over 100 is green and anything under 100 gets coloured red

        
        For Each s in Chart1.Series
          For Each p As DataPoint In s.Points
            If p.YValues(0) >100 Then
              p.Color = Color.Green
            Else
              p.Color = Color.Red
            End If
          Next
        Next

    regards

    enex

    Thursday, June 10, 2010 12:58 PM
  • Hi,

    Once the chart is displayed the user will select a region and the i want to change the color of the bars in between the selected region.

     

     

    Thursday, June 10, 2010 1:05 PM