Hi
i have a problem to add an annotation relative to a dataset that isn't the primary.
Imagine a xy plot where I plot, for example, two datasets with the same x axis and two different y axis.
Then I want to draw an annotation for the two different dataset.
When I click with the mouse on the plot of the first (primary) dataset, i retrieve the information of where i have to add the annotation, and then I draw correctly the annotation on the chart.
Then I want to add the annotation for the second dataset.
I click with the mouse on the plot of the second dataset, I retrieve the information of where i have to add the annotation,
and then when I draw the annotation nothing appears. This because the annotaion function always works with
coordinates respect to the main axis. So now the question is: How can I switch coordinates in order to allow to the second
annotion call to display the annotation for the second dataset on the chart ...or What is the calling sequence to
allow the drwaing of the annotation for the second or further datasets ?
Thanks
XYPointerAnnotation not primary dataset
Re: XYPointerAnnotation not primary dataset
Instead of adding the Annotation to the XYPlot add it to the renderer responsible for your second dataset.
Similarly you could add the Annotations for the first dataset to its renderer instead of the XYPlot.
See:
Similarly you could add the Annotations for the first dataset to its renderer instead of the XYPlot.
See:
Code: Select all
XYItemRenderer.addAnnotation(XYAnnotation annotation)
Re: XYPointerAnnotation not primary dataset
Ok, it works prerfectly,
thanks
but now i can't retrieve the list of annotation added to the renderer,
becuase from XYPlot.getRenderer.getAnnotations() doesn't exist a function similar to XYPlot.getAnnotations()
Are there any method to give this informations?
thanks
but now i can't retrieve the list of annotation added to the renderer,
becuase from XYPlot.getRenderer.getAnnotations() doesn't exist a function similar to XYPlot.getAnnotations()
Are there any method to give this informations?
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: XYPointerAnnotation not primary dataset
Yes. Check AbstractXYItemRenderer.getAnnotations(). Unfortunately the method is not part of the XYItemRenderer interface. In order to use the method, you will have to cast the XYItemRenderer returned from XYPlot.getRenderer() to an AbstractXYItemRenderer.pdvmipv wrote: Are there any method to give this informations?
Re: XYPointerAnnotation not primary dataset
Ok, perfect!
Thanks
Thanks