Dynamically changing color of individual points

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
willsc8forwings
Posts: 2
Joined: Mon Oct 27, 2014 9:24 pm
antibot: No, of course not.

Dynamically changing color of individual points

Post by willsc8forwings » Mon Oct 27, 2014 9:26 pm

I was wondering how I would be able to dynamically change the color of individual points dynamically (so after it is initially created). From what I've gathered, it may have to do with extending XYLineAndShapeRenderer or overriding a method or two from the class.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Dynamically changing color of individual points

Post by John Matthews » Tue Oct 28, 2014 11:12 am

As shown here, you can override the renderer's getItemPaint method. As shown here, you can update a chart's appearance after it's been made visible.

willsc8forwings
Posts: 2
Joined: Mon Oct 27, 2014 9:24 pm
antibot: No, of course not.

Re: Dynamically changing color of individual points

Post by willsc8forwings » Tue Oct 28, 2014 5:38 pm

John Matthews wrote:As shown here, you can override the renderer's getItemPaint method. As shown here, you can update a chart's appearance after it's been made visible.
I don't understand from the second example. How do I change the renderer and then change the plot? Do I make the change to my renderer and then add the renderer again to the plot?

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Dynamically changing color of individual points

Post by John Matthews » Wed Oct 29, 2014 2:12 am

It depends on what you want to do. Changes to the underlying dataset will notify a listening ChartPanel to update the chart. Any changes you've made to the renderer will be applied accordingly.

Locked