Gradient fill bar chart with default colours

A discussion forum for the JCommon class library.

Gradient fill bar chart with default colours

Postby brownmb » Wed Dec 02, 2009 12:14 pm

Hi

I want to copy the chart from page 23 of the developer guide (Figure 2.4).

The demo source code produces a chart with the white glow line.

I want vertical gradients and can see there are method to do this, but they all require the colours to be defined.

I.e. i want default colours but with dark to light shading.

Is this possible?

Cheers
brownmb
 
Posts: 2
Joined: Wed Dec 02, 2009 12:08 pm

Re: Gradient fill bar chart with default colours

Postby brownmb » Wed Dec 02, 2009 1:46 pm

...Update.

Ive managed to achieve what i wanted with this code snipet;

Code: Select all
CategoryPlot plot1 = (CategoryPlot) chart1.getPlot();
        BarRenderer renderer1 = (BarRenderer) plot1.getRenderer();
       
       
        renderer1.setDefaultBarPainter(new StandardBarPainter());
       
        renderer1.setBarPainter(new StandardBarPainter());
        renderer1.setDrawBarOutline(false);
       
        int cc = dataset.getRowCount();
       
        for (int c = 0; c <= cc; c++){
           Color col = (Color) renderer1.getItemPaint(c,0);   
           renderer1.setSeriesPaint(c, new GradientPaint(0.0f, 0.0f, col, 0.0f, 0.0f, col.darker().darker()));
       
        }
       
        renderer1.setGradientPaintTransformer(
                new StandardGradientPaintTransformer(
                        GradientPaintTransformType.VERTICAL));


Is this wise or is there a better way!?
brownmb
 
Posts: 2
Joined: Wed Dec 02, 2009 12:08 pm


Return to JCommon

Who is online

Users browsing this forum: No registered users and 4 guests