java - XYPlot: Annotation is placed incorrectly with respect to Y axis -


i have following code generates annotation in xyplot on on-mouse-click event.

    _chartpanel.addchartmouselistener(new chartmouselistener() {         @override         public void chartmouseclicked(chartmouseevent cme)          {             rectangle2d dataarea = _chartpanel.getscreendataarea();             xyplot plot = (xyplot) cme.getchart().getplot();             plot.clearannotations();             valueaxis xaxis = plot.getdomainaxis();             valueaxis yaxis = plot.getrangeaxis();             double x = xaxis.java2dtovalue(cme.gettrigger().getx(), dataarea, rectangleedge.bottom);             double y = yaxis.java2dtovalue(cme.gettrigger().gety(), dataarea, rectangleedge.bottom);             if (!xaxis.getrange().contains(x)) {                  x = double.nan;                               }                             decimalformat df = new decimalformat("#.##");             df.setroundingmode(roundingmode.ceiling);             xypointerannotation pt = new xypointerannotation("lat: " + df.format(y) + "\n lon: " + df.format(x), x, y, 0.2);             //pt.setbackgroundpaint(color.red);             pt.setarrowpaint(color.red);             pt.setfont(_font);             pt.setpaint(color.red);             plot.addannotation(pt);         } 

everything works fine except y axis (see example below). when click on series point (red arrow), annotation appears in place (the location correct respect x-axis, while it's incorrect respect y).

enter image description here

when call java2dtovalue() calculate y-value, specifying rectangleedge.bottom axis location, should rectangleedge.left.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -