locked
Intersection points of two lines on a single chart RRS feed

  • Question

  • Hi All,

    I am trying to get a list of all the intersection points of two lines on a single chart.

    Series Red and Series Blue are added to a line chart. 

    Sometimes the blue and red lines will cross multiple times. 

    How do I get the Y corridinate of these line interections?

    (The series points will not intersect but the lines drawn from the series will cross.)

    Thanks!

    Sunday, February 1, 2009 10:39 PM

Answers

  • Chart does not provide you a simple way to get the intersection point but it has everything you need to do that yourself. You can calculate the position of all the data points in pixels and then using a simple math calculate the intersection points. Then you can apply the opposite transformation from pixels to axes values.

    The trick is that you need to use one of the chart events when position of all chart elements is already calculated. For example, PrePaint event. Use chart Axis methods PixelPositionToValue and ValueToPixelPosition to do the conversion.

    Alex.
    http://blogs.msdn.com/alexgor
    Monday, February 2, 2009 6:39 AM

All replies

  • Unfortunately the chart control does not provide this capability.
    Monday, February 2, 2009 1:44 AM
  • Chart does not provide you a simple way to get the intersection point but it has everything you need to do that yourself. You can calculate the position of all the data points in pixels and then using a simple math calculate the intersection points. Then you can apply the opposite transformation from pixels to axes values.

    The trick is that you need to use one of the chart events when position of all chart elements is already calculated. For example, PrePaint event. Use chart Axis methods PixelPositionToValue and ValueToPixelPosition to do the conversion.

    Alex.
    http://blogs.msdn.com/alexgor
    Monday, February 2, 2009 6:39 AM