java - Obtain series identifiers when clicking on XYPlot's series -


i have 4 series plotted on xyplot. want obtain series id when click on xyplot (see //int seriesid = ???;). possible?

   _chartpanel.addchartmouselistener(new chartmouselistener() {         @override         public void chartmouseclicked(chartmouseevent cme)          {             mouseevent me = cme.gettrigger();             xyplot plot = (xyplot) cme.getchart().getplot();             if (me.getclickcount() == 2)             {                 plot.clearannotations();             }             else             {                 rectangle2d dataarea = _chartpanel.getscreendataarea();                 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.left);                 if (!xaxis.getrange().contains(x)) {                      x = double.nan;                                    //int seriesid = ???;                  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(new color(103,154,236));                 // pt.setarrowpaintnew color(103,154,236)d);                 pt.setfont(_font);                 pt.setpaint(color.light_gray);                 plot.addannotation(pt);             }         } 

as shown here, can retrieve chartentity chartmouseevent. chartentity of type xyitementity, can dataset via getdataset() , series index via getseriesindex().

chartentity ce = cme.getentity(); if (ce instanceof xyitementity) {     xyitementity e = (xyitementity) ce;     system.out.println("dataset: " + e.getdataset());     system.out.println("series index: " + e.getseriesindex()); } 

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 -