Reputation: 459
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:
Upvotes: 1
Views: 407
Reputation: 23383
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.)
Upvotes: 4