WaterfallBarRenderer.setSeriesFillPaint() does nothing!

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

WaterfallBarRenderer.setSeriesFillPaint() does nothing!

Post by mhilpert » Mon Apr 22, 2013 10:56 am

How to change the colors of the bars of a waterfall chart? I tried this, but the colors don't change:

Code: Select all

final WaterfallBarRenderer renderer = new WaterfallBarRenderer();
        renderer.setSeriesFillPaint(1, Color.BLUE);
        renderer.setSeriesFillPaint(2, Color.BLUE);
        renderer.setSeriesFillPaint(3, Color.BLUE);
        renderer.setSeriesFillPaint(4, Color.RED);
        
        plot.setRenderer(renderer);
The developer guide just offers the special constructor where you can state the colors of start/positive/negative/end.
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: WaterfallBarRenderer.setSeriesFillPaint() does nothing!

Post by remiohead » Wed Apr 24, 2013 7:12 pm

The constructor, or the set methods (setFirstBarPaint(Paint), ...) are the only options. Check the code to WaterfallBarRenderer.java if you want to see it for yourself.

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Re: WaterfallBarRenderer.setSeriesFillPaint() does nothing!

Post by mhilpert » Wed Apr 24, 2013 8:56 pm

Yes, I've seen this in the developer guide. BUt what is wrong for setSeriesFillPaint()? I would like to have a waterfall chart where I can set individual colors for each bar.
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: WaterfallBarRenderer.setSeriesFillPaint() does nothing!

Post by remiohead » Wed Apr 24, 2013 9:48 pm

Extend the renderer and add this to the draw method. Very minor changes required.

mhilpert
Posts: 497
Joined: Wed Apr 02, 2003 1:57 pm
Location: Germany

Re: WaterfallBarRenderer.setSeriesFillPaint() does nothing!

Post by mhilpert » Thu Apr 25, 2013 12:38 am

The problem with such answers is that it doesn't make sense to enhance the API for myself because the API offers the setSeriesFillPaint() and JFreeCHart should only offer an implementation for this API for waterfall charts, too. I already contributed code to JFreeChart - some got integrated in JFreeChart, others I have to maintain since several years (e.g. LogarithmicAxis with custom parameters like the log base or a PercentageAxis) - so, even making my code public doesn't always help because it is never integrated in JFreeChart. The latest one is the SpiderChart for which I have added much custom code for features that many other JFreeChart users request, too. This can be time consuming to test (and sometimes adjust) the code for every new JFreeChart version. This request is no rocket science as you mention and exactly this is the reason that it should be in JFreeChart itself! So even if I subclass, copy and adjust code, I don't like to create custom code that could break on the next JFreeChart release. At least not for simple feature requests.
Java 11, JFreeChart 1.0.15, JFreeSVG 4.0

remiohead
Posts: 201
Joined: Fri Oct 02, 2009 3:53 pm
antibot: No, of course not.

Re: WaterfallBarRenderer.setSeriesFillPaint() does nothing!

Post by remiohead » Thu Apr 25, 2013 8:47 pm

I agree completely by the way. The class was written by a third party, not David Gilbert, which probably explains the unusual behaviour. I too have written thousands of lines of custom code (and completely new renderers) around the provided classes to get the desired results. Sure I wish I didn't have to, but it's still an awesome tool to work from.

Locked