Thanks in advance.
Code: Select all
public void chartMouseClicked(ChartMouseEvent chartmouseevent) {
ChartEntity chartentity = chartmouseevent.getEntity();
XYPlot plot = (XYPlot) myChart.getChart().getPlot();
if (chartentity instanceof XYAnnotationEntity){
XYAnnotationEntity xyEntity = (XYAnnotationEntity) chartentity;
String tip = xyEntity.getToolTipText();
List<AbstractXYAnnotation> list = plot.getAnnotations();
for (AbstractXYAnnotation annot : list) {
if ((annot.getToolTipText()).equals(tip)) {
plot.removeAnnotation(annot);
break;
}
}
}
}