I would like to display the x,y data for a given point on a scatter plot that I have created using JFreeChart. I have looked online and in the developer's guide as well and am still having trouble doing this.
I create the scatter plot using ChartFactory
chart = ChartFactory.createScatterPlot( title, xlabel, ylabel, data, plotOrientation.VERTICAL,
false, true, false );
I have tried to implement the chartMouseClicked event.
public void chartMouseClicked(ChartMouseEvent event) {
ChartEntity entity = event.getEntity();
If (entity != null) {
XYItemEntity ent = (XYItemEntity) entity;
int sindex = ent.getSeriesIndex();
int iindex = ent.getItem();
System.out.println("x = " + data.getXValue(sindex, iindex));
}
}
where data is an implementation of the XYDataSet related to the plot.
This does not seem to give me any numbers. What am I doing wrong?
Thanks