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.

  1. download annotation files click here
  2. you need org.jfree.chart.annotations folder. add project.
  3. replace marker annotations code below

    xydomainvalueannotation 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); 
  4. when mouse on annotation lines tooltip appear.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -