show label when user mouseOver ValueMarker in jFreeChart -
right jfreechart line graph. want add marker mark events. have added markers. problem marker labels have started overlap. want solve showing marker label if user mouse over's marker line. how can capture mouseover event?
marker tempmarker = new valuemarker(hour.getfirstmillisecond()); tempmarker.setpaint(color.black); tempmarker.setlabelanchor(rectangleanchor.top_left); tempmarker.setlabeltextanchor(textanchor.top_right); //instead of want mouseoverlistner , show label tempmarker.setlabel("event name");
code mouse over
chartpanel.addchartmouselistener(new chartmouselistener() { @override public void chartmouseclicked(chartmouseevent event) { //do on mouse click } @override public void chartmousemoved(chartmouseevent event) { system.out.println("entity type: " + event.getentity()); } });
when mouse on marker objects chartentity sent chartmousemoved. same when mouse on other non filled portions of chart.
it's not possible this. got @paradoxoff in this thread on jfree forum. here how achieved it.
- download annotation files click here
- you need
org.jfree.chart.annotations
folder. add project. replace marker
annotations
code belowxydomainvalueannotation tempmarker = new xydomainvalueannotation(); tempmarker.setvalue(hour.getfirstmillisecond()); //set color of lines switch (priority) { case constants.high_importance: tempmarker.setpaint(color.red); break; case constants.low_importance: tempmarker.setpaint(color.green); break; default: tempmarker.setpaint(color.black); } // dont set label //tempmarker.setlabel("event name"); //set tool tip display when mouse over. tempmarker.settooltiptext("annotation"); //format tempmarker.setstroke(new basicstroke(5.0f)); tempmarker.setlabeltextanchor(textanchor.top_left); tempmarker.setlabelanchor(rectangleanchor.top_left); tempmarker.setrotationanchor(textanchor.top_left); //add annotation lines plot.addannotation(tempmarker);
when mouse on annotation lines tooltip appear.
Comments
Post a Comment