Skip to content
Advertisement

How to change JFreeChart vertical bar to a solid color?

I have the following sample code for a JFreeChart, how to change the vertical bars to a solid color [ right now it has some white color in each bar ] ?

enter image description here

JavaScript

Advertisement

Answer

As shown here, use a StandardXYBarPainter to get a flat effect instead of the default gradient.

JavaScript

I tried, but didn’t work: renderer2.setDefaultBarPainter(new StandardXYBarPainter()).

Note that XYBarRenderer.setDefaultBarPainter() is a static method. It should be called before instantiating the renderer.

JavaScript

Either formulation produces the desired result:

image

As an aside, plot.setRangeAxis(1,rangeAxis2) needs to be called only once.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement