开发者

Determine the value between 2 points in JFreeCharts

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 locke开发者_如何转开发d 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:

Determine the value between 2 points in JFreeCharts


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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜