Creating Pie Charts using JFreeChart with custom colors

I have attached a sample code snippet for creating a Pie Chart using JFreeChart with custom colors. There is a PieReneder (a static inner class) which can be used to achieve the same. The PieRenderer takes an array of java.awt.Color in its constructor.
package subin.rnd.chart;
import java.awt.Color;
import java.io.File;
import java.util.List;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot;
import org.jfree.data.general.DefaultPieDataset;
public class PieChartWithCustomColours
{
    public [...]

Displaying dynamic charts in a web page (using JFreeChart & JSP)

This code snippet will tell you how to create a chart (using JFreeChart) on the fly and displaying it in a webpage.
getChart.jsp
<%@ page import=“java.io.*” %>
<%@ page import=“org.jfree.chart.JFreeChart” %>
<%@ page import=“org.jfree.chart.ChartUtilities” %>
<%
 try
 {
  File image = File.createTempFile(“image”, “tmp”);
  
  // Assume that we have the chart
  ChartUtilities.saveChartAsPNG(image, chart, 500, 300);
  
  FileInputStream fileInStream = new FileInputStream(image);
  OutputStream outStream = response.getOutputStream();

  long fileLength;
  byte[] byteStream;
  
  fileLength [...]

Creating BarCharts with custom colours using JFreeChart

This can be achieved by extending the BarRenderer. BarRenderer is responsible for all kind of UI related things like setting the font, setting the colors, setting the alignment etc etc. Rather we can say everything. The same can be achieved by extending corresponding renderer.
Here the getItemPaint(row, col) has been overridden to achieve the custom colors.
CustomRenderer:
import [...]

Creating a 3D BarChart using JFreeChart

The given code snippet can create a 3D Bar Chart. The given Bar Chart compares 2 aspects of each customer. The generated chart will have two bars for each customer for both Profit1 and Profit 2 (see the dataset).
Profit 1 can can be total annual profit and Profit 2 can be profit for a [...]

Creating Time Series charts using JFreeChart

I have attached a code snippet which can give you a basic idea on creating a time-series chart using JFreeChart. This is a part of JFreeChart samples which come along with the free distribution of JFreeChart.
// Creating a dataset
TimeSeries s1 = new TimeSeries(”Name of the Time series”, Month.class);
s1.add(new Month(2, 2001), 181.8);
s1.add(new Month(3, 2001), 167.3);
s1.add(new Month(4, 2001), [...]