Gradient Look For AreaChart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
raunakkathuria
Posts: 16
Joined: Wed Dec 22, 2010 5:35 pm
antibot: No, of course not.
Location: India
Contact:

Gradient Look For AreaChart

Post by raunakkathuria » Thu Dec 23, 2010 5:57 am

Hi

I need to make area chart with gradient look and feel as shown in the image url below:

http://www.raunakkathuria.com/images/jf ... achart.jpg

Currently what I have made looks like this

http://www.raunakkathuria.com/images/jf ... actual.jpg

I need to have gradient look and feel inside the chart area.

Information : Chart Type: XYAreaChart, Plot: XYPlot, Domain Axis: DateAxis

Thanks
Raunak Kathuria

lfkpoa
Posts: 7
Joined: Wed Dec 22, 2010 8:28 pm
antibot: No, of course not.

Re: Gradient Look For AreaChart

Post by lfkpoa » Thu Dec 23, 2010 7:43 pm

Hi,

I'm still learning JFreechart so my answer might not be the right solution.
You can set the Paint used by the renderer as follows:

Code: Select all

XYItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(seriesIndex, paint);
where:
seriesIndex: the index of the series you want to set the paint
paint: use GradientPaint class for a gradient fill

The problem with this approach is that you must set the startingY and endingY for the gradient and if the Plot is resized afterwards then you might need to create a new GradientPaint.
You also have the option of extending XYAreaRenderer to make it render the way you like it.

With regards,

Luis Fernando

Locked