How can I change one point size/color and show label in JFreeChart? By this ChartMouseListener
, I can get the user select witch point, and I want set the point in special style,like larger or change color, etc. Please help me how to do this.
chartPanel.addChartMouseListener(new ChartMouseListener() {
@Override
public void chartMouseMoved(ChartMouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void chartMouseClicked(ChartMouseEvent arg0) {
// TODO Auto-generated method stub
JFreeChart chart = arg0.getChart();
if (chart == null)
return;
XYItemEntity ce = (XYItemEntity) arg0.getEntity();
if (ce == null)
return;
IntervalXYDataset my = (IntervalXYDataset) ce.getDataset();
int sindex = ce.getSeriesIndex();
int iindex = ce.getItem();
//i want make change the selectted point in here. how to do this
System.out.println("x = " + my.getXValue(sindex, iindex));
System.out.println("y = " + my.getYValue(sindex, iindex));
}
});
Given your chosen renderer, apply a suitable label generator and override the relevant methods to return the desired shape and paint properties when the row and column match the respective series and item index recorded by your ChartMouseListener
. In the specific case of XYLineAndShapeRenderer
, you can