StandardBarPainter

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

StandardBarPainter

Post by eselick » Wed Apr 20, 2016 11:55 pm

Hi
I would like to use the GroupedStackedBarRenderer() renderer for the chart I'm working on. Here's what it looks like so far:
Image

My client wants the bars to be flatter as in the old legacy verison of jFree and also in the following demo:

Image

I have tried both of the following which did not work

renderer.setBarPainter(new StandardBarPainter());

and als0

ChartTheme legacy = StandardChartTheme.createLegacyTheme();
ChartFactory.setChartTheme(legacy);

Ideas?
Thanks
Elliot

Naxter
Posts: 45
Joined: Thu Jun 26, 2014 8:24 am
antibot: No, of course not.
Location: Germany, Aachen

Re: StandardBarPainter

Post by Naxter » Thu Apr 21, 2016 9:55 am

hey,

mabye a silly idea, but why don´t you just squeeze the Y-Axis? So only difference between these two charts I see, is that the second one is way smaller in the Y-Axis and larger in the X-Axis.
Or do I misunderstand you?

Greetings Tobi

eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

Re: StandardBarPainter

Post by eselick » Thu Apr 21, 2016 11:37 am

Hi Tobi

Thanks for the idea but I don't think it's going to help.

The difference as far as I can tell is that there really is a gradient in the bar color going from a more intense hue towards a lighter shade in the first image; this is not present in the second image.

This gives the illusion that the surface is rounded and reflecting some light. It uses a "GradientBarPainter"

Elliot

eselick
Posts: 7
Joined: Sat Apr 16, 2016 1:24 am
antibot: No, of course not.

Re: StandardBarPainter

Post by eselick » Thu Apr 21, 2016 12:22 pm

I found a really good post which gave me the answer.
http://stackoverflow.com/questions/7076 ... 67#7092567

I changed
plot.getRenderer()).setBarPainter(new StandardBarPainter();
to
((BarRenderer) plot.getRenderer()).setBarPainter(new StandardBarPainter());
The last required a new import:
import org.jfree.chart.renderer.category.BarRenderer;

I would love someone to explain the difference between the two statements which look the same but obviously the cast to BarRenderer was important.

This gave me an image with a vertical rather than horizontal gradient:

Image

I then removed the following which I hadn't noticed before

renderer.setGradientPaintTransformer(
new StandardGradientPaintTransformer(
GradientPaintTransformType.HORIZONTAL));

and changed it to this:

renderer.setGradientPaintTransformer(null);

The final image looks flat ( which I think is really boring but that's what the client wants LOL ):

Image

E.

Naxter
Posts: 45
Joined: Thu Jun 26, 2014 8:24 am
antibot: No, of course not.
Location: Germany, Aachen

Re: StandardBarPainter

Post by Naxter » Thu Apr 21, 2016 12:49 pm

Oh well, sorry that i misunderstood your question. I could have told you that earlier than how that works. But great that you found it yourself.

Greetings

Locked