JFreeChart : Gradient color for background and when using 3-D bar graph
807603Nov 26 2007 — edited Nov 27 2007I have a couple of queries regarding using JFreeGraphs:
Query 1
How do you make the background color of the graph area a combination of 2 colors (i.e. giving a gradient effect .. starting with one color and fading into another
Normally we can set the background to only one color.
Eg:
JFreeChart barGraph;
CategoryPlot plot = (CategoryPlot)barGraph.getPlot();
plot.setBackgroundPaint(Color.lightGray);
But if I want to set it as a combination of 2 colors
Color Start = new Color(100,207, 100);
Color End = new Color(104, 230, 255);
How do I go about doing so?
Query 2:
I have a 3D bar Graph, and I want to give it a gradient color effect, it is possible in a plain bar graph (i.e. not a 3D).
i.e.
BarRenderer renderer = (BarRenderer) plot.getRenderer();
// add gradient features if selected
GradientPaint gp0 = new GradientPaint(0.5f, 0.5f, Color.red,
0.0f, 0.0f, Color.lightGray);
GradientPaint gp1 = new GradientPaint(0.1f, 0.5f, Color.blue,
0.0f, 0.0f, new Color(0, 64, 0), true);
GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.green,
0.0f, 0.0f, new Color(64, 0, 0));
renderer.setSeriesPaint(0, gp0);
renderer.setSeriesPaint(1, gp1);
renderer.setSeriesPaint(2, gp2);
But I want to do the same in a 3D graph.
Also, if any of you know of useful documentation in using JFreeCharts or pointers to good example code for different graphs will really appreciate it.
Thanks,