1

I am using JFreeChart to render a scatter plot with a couple thousand data points. I control the appearance/style of each ScatterPlotDataset by attaching a suitable XYLineAndShapeRendererper to each data set; eg. points in data set 1 appear as circles and points in data set 2 appear as squares. I would like the user to be able to dynamically assign a sub-style per point in each data set; eg. if the data set were books then the user might wish to color fiction blue and nonfiction red. Is there a way to do this without defining a new data set for each sub style?

Incidentally I am carting with XYPlot but I can switch to another chart type if necessary.

Thank you in advance.

Toaster
  • 1,911
  • 2
  • 23
  • 43

1 Answers1

4

You might consider the approaches mentioned here. The first implements DrawingSupplier, as shown here:

class DefaultDrawingSupplier implements DrawingSupplier…

The second extends DefaultDrawingSupplier, as shown here, to achieve a similar effect.

Paint[] paintArray = {…};
plot.setDrawingSupplier(new DefaultDrawingSupplier(
    paintArray, …
    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));

Of course, you can always override getItemPaint(), as shown here.

trashgod
  • 203,806
  • 29
  • 246
  • 1,045