JFreeChart Annotations

I find it difficult to understand how the annotation system works. For example, I can draw a vertical line as annotation using some coordinates that I get from the mouse, but I cannot draw a line between two different points.

It works:

HighLowRenderer hlr=(HighLowRenderer)plot.getRenderer();

XYLineAnnotation a1=new XYLineAnnotation(chartX, 0, chartX, dataArea.getHeight(), bs1, Color.black);
hlr.addAnnotation(a1);

      

where chartX is the calculated value from the mouse position.

This does not work:

HighLowRenderer hlr=(HighLowRenderer)plot.getRenderer();  
XYLineAnnotation a2=new XYLineAnnotation(175, 67, 230, 167, bs1, Color.black);
hlr.addAnnotation(a2);

      

+1


a source to share


1 answer


See this example , which adds XYLineAnnotations to the XYPlot (in the example above, you add it to the renderer).



I had a lot of problems with annotations and unfortunately the only real advice I can offer is to look at examples http://www.java2s.com/

+1


a source







All Articles