views:

26

answers:

1

Imagine an XY Line Chart. The X axis is a number range, as is the Y axis.

There are 3 series on the chart

The domain cross hair is NOT locked on data:

plot.setDomainCrosshairLockedOnData(false);

I would like to know what the Range value is for each of the three series for the selected DomainCrossHair values. The issue is not each series has an actual datapoint at each of the domain points BUT, there should be a way, based on the rendered line and its slope between the two points to know what the corresponding Range value is.

Make sense? edit: A picture is worth a thousand words: alt text

+4  A: 

Given the crosshair at xc and surrounding points x1,y1 x2,y2 the value for yc should be:

yc = y1 + ((y2 - y1)/(x2 - x1)) * (xc - x1)

giving your intersection at xc,yc

(using int arithmetic mutiplying before dividing prevents rounding errors.)

rsp
Can't. My issue is I don't have the Y coordinate since it's not an actual data point but rather an intersection between 2.
Jamie McIlroy
@Jamie McIlroy, you do have the x-value of the insersection and the x- and y-values of the 2 surrounding points right? In my answer yc is the y-value you need, derived from the known values.
rsp
@rsp: +1 Good example of two-point form: http://en.wikipedia.org/wiki/Linear_equation#Two-point_form
trashgod