Example usage for org.jfree.chart.title TextTitle TextTitle

List of usage examples for org.jfree.chart.title TextTitle TextTitle

Introduction

In this page you can find the example usage for org.jfree.chart.title TextTitle TextTitle.

Prototype

public TextTitle(String text, Font font) 

Source Link

Document

Creates a new title, using default attributes where necessary.

Usage

From source file:KIDLYFactory.java

/**
 * Creates a chart that displays multiple pie plots.  The chart object
 * returned by this method uses a {@link MultiplePiePlot} instance as the
 * plot./*from ww  w. j  ava  2  s .c om*/
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset (<code>null</code> permitted).
 * @param order  the order that the data is extracted (by row or by column)
 *               (<code>null</code> not permitted).
 * @param legend  include a legend?
 * @param tooltips  generate tooltips?
 * @param urls  generate URLs?
 *
 * @return A chart.
 */
public static JFreeChart createMultiplePieChart3D(String title, CategoryDataset dataset, TableOrder order,
        boolean legend, boolean tooltips, boolean urls) {

    if (order == null) {
        throw new IllegalArgumentException("Null 'order' argument.");
    }
    MultiplePiePlot plot = new MultiplePiePlot(dataset);
    plot.setDataExtractOrder(order);
    plot.setBackgroundPaint(null);
    plot.setOutlineStroke(null);

    JFreeChart pieChart = new JFreeChart(new PiePlot3D(null));
    TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12));
    seriesTitle.setPosition(RectangleEdge.BOTTOM);
    pieChart.setTitle(seriesTitle);
    pieChart.removeLegend();
    pieChart.setBackgroundPaint(null);
    plot.setPieChart(pieChart);

    if (tooltips) {
        PieToolTipGenerator tooltipGenerator = new StandardPieToolTipGenerator();
        PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
        pp.setToolTipGenerator(tooltipGenerator);
    }

    if (urls) {
        PieURLGenerator urlGenerator = new StandardPieURLGenerator();
        PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
        pp.setURLGenerator(urlGenerator);
    }

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java

private static JFreeChart createMultiplePieChart(final CategoryDatasetChartDefinition chartDefinition) {
    // TODO Make the following accessible from the chartDefinition
    TableOrder order = TableOrder.BY_ROW;
    // boolean tooltips = true;
    // boolean urls = true;
    // -----------------------------------------------------------

    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();

    if (order == null) {
        throw new IllegalArgumentException(
                Messages.getInstance().getString("JFreeChartEngine.ERROR_0001_NULL_ORDER_ARGUMENT")); //$NON-NLS-1$
    }/*w w w.j a  v  a  2  s  . c  om*/
    MultiplePiePlot plot = new MultiplePiePlot(chartDefinition);
    JFreeChartEngine.updatePlot(plot, chartDefinition);
    plot.setDataExtractOrder(order);

    JFreeChart pieCharts = new JFreeChart(title, chartDefinition.getTitleFont(), plot, legend);
    JFreeChart pieChart = plot.getPieChart();
    TextTitle seriesTitle = new TextTitle("Series Title", new Font("SansSerif", Font.BOLD, 12)); //$NON-NLS-1$ //$NON-NLS-2$
    seriesTitle.setPosition(RectangleEdge.BOTTOM);
    pieChart.setTitle(seriesTitle);
    pieChart.setBackgroundPaint(chartDefinition.getChartBackgroundPaint());
    plot.setPieChart(pieChart);

    // if (tooltips) {
    // PieToolTipGenerator tooltipGenerator = new
    // StandardPieToolTipGenerator();
    // PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
    // pp.setToolTipGenerator(tooltipGenerator);
    // }

    // if (urls) {
    // PieURLGenerator urlGenerator = new StandardPieURLGenerator();
    // PiePlot pp = (PiePlot) plot.getPieChart().getPlot();
    // pp.setURLGenerator(urlGenerator);
    // }

    return pieCharts;
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample time series chart that will be displayed in a scroll pane.
 *
 * @return a sample time series chart./*ww  w. j  a va2  s  .c o  m*/
 */
public JFreeChart createTimeSeriesChartInScrollPane() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("test.scroll.title");
    final String domain = this.resources.getString("test.scroll.domain");
    final String range = this.resources.getString("test.scroll.range");
    final String subtitleStr = this.resources.getString("test.scroll.subtitle");
    final XYDataset data = DemoDatasetFactory.createTimeSeriesCollection2();
    final JFreeChart chart = ChartFactory.createTimeSeriesChart(title, domain, range, data, true, true, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.gray));
    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample overlaid chart.
 * <P>//from w  ww .j av  a  2  s.c  o m
 * Note:  with the introduction of multiple secondary datasets in JFreeChart version 0.9.10,
 * the overlaid chart facility has been removed.  You can achieve the same results using
 * a regular XYPlot with multiple datasets.
 *
 * @return an overlaid chart.
 */
public JFreeChart createOverlaidChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("combined.overlaid.title");
    final String subtitleStr = this.resources.getString("combined.overlaid.subtitle");
    final String domainAxisLabel = this.resources.getString("combined.overlaid.domain");
    final String rangeAxisLabel = this.resources.getString("combined.overlaid.range");

    // create high-low and moving average dataset
    final DefaultHighLowDataset highLowData = DemoDatasetFactory.createHighLowDataset();

    // make an overlaid plot
    final ValueAxis domainAxis = new DateAxis(domainAxisLabel);
    final NumberAxis rangeAxis = new NumberAxis(rangeAxisLabel);
    rangeAxis.setAutoRangeIncludesZero(false);
    final XYItemRenderer renderer1 = new HighLowRenderer();
    renderer1.setToolTipGenerator(new HighLowItemLabelGenerator());

    final XYPlot plot = new XYPlot(highLowData, domainAxis, rangeAxis, renderer1);

    // overlay a moving average dataset
    final XYDataset maData = MovingAverage.createMovingAverage(highLowData, " (Moving Average)",
            5 * 24 * 60 * 60 * 1000L, 5 * 24 * 60 * 60 * 1000L);
    plot.setDataset(1, maData);
    final XYItemRenderer renderer2 = new StandardXYItemRenderer();
    renderer2.setToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.0")));
    plot.setRenderer(1, renderer2);

    // make the top level JFreeChart object
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates a horizontally combined chart.
 *
 * @return a horizontally combined chart.
 *//*from   w ww  .  j  a v  a  2s  .com*/
public JFreeChart createHorizontallyCombinedChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("combined.horizontal.title");
    final String subtitleStr = this.resources.getString("combined.horizontal.subtitle");
    final String[] domains = this.resources.getStringArray("combined.horizontal.domains");
    final String rangeAxisLabel = this.resources.getString("combined.horizontal.range");

    final TimeSeriesCollection dataset0 = new TimeSeriesCollection();
    final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries();
    dataset0.addSeries(eur);

    final TimeSeriesCollection dataset1 = new TimeSeriesCollection();
    final TimeSeries mav = MovingAverage.createMovingAverage(eur, "EUR/GBP (30 Day MA)", 30, 30);
    dataset1.addSeries(eur);
    dataset1.addSeries(mav);

    final TimeSeriesCollection dataset2 = new TimeSeriesCollection();
    dataset2.addSeries(eur);

    // make a combined range plot
    final NumberAxis valueAxis = new NumberAxis(rangeAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    final CombinedRangeXYPlot parent = new CombinedRangeXYPlot(valueAxis);
    parent.setRenderer(new StandardXYItemRenderer());

    // add subplots
    final int[] weight = { 1, 1, 1 }; // controls space assigned to each subplot

    // add subplot 1...
    final XYPlot subplot1 = new XYPlot(dataset0, new DateAxis(domains[0]), null, new StandardXYItemRenderer());
    parent.add(subplot1, weight[0]);

    // add subplot 2...
    final XYPlot subplot2 = new XYPlot(dataset1, new DateAxis(domains[1]), null, new StandardXYItemRenderer());
    parent.add(subplot2, weight[1]);

    // add subplot 3...
    final XYPlot subplot3 = new XYPlot(dataset2, new DateAxis(domains[2]), null, new XYBarRenderer(0.20));
    parent.add(subplot3, weight[2]);

    // now make the top level JFreeChart
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, parent, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample vertically combined chart.
 *
 * @return a sample vertically combined chart.
 *///  w ww .j a va  2s .c o m
public JFreeChart createVerticallyCombinedChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("combined.vertical.title");
    final String subtitleStr = this.resources.getString("combined.vertical.subtitle");
    final String domain = this.resources.getString("combined.vertical.domain");
    final String[] ranges = this.resources.getStringArray("combined.vertical.ranges");

    final TimeSeriesCollection dataset0 = new TimeSeriesCollection();
    final TimeSeries eur = DemoDatasetFactory.createEURTimeSeries();
    dataset0.addSeries(eur);

    final TimeSeriesCollection dataset1 = new TimeSeriesCollection();
    final TimeSeries jpy = DemoDatasetFactory.createJPYTimeSeries();
    final TimeSeries mav = MovingAverage.createMovingAverage(jpy, "JPY/GBP (30 Day MA)", 30, 30);
    dataset1.addSeries(jpy);
    dataset1.addSeries(mav);

    final XYDataset dataset2 = DemoDatasetFactory.createHighLowDataset();

    final TimeSeriesCollection dataset3 = new TimeSeriesCollection();
    dataset3.addSeries(eur);

    // make one shared horizontal axis
    final ValueAxis timeAxis = new DateAxis(domain);

    // make a vertically CombinedPlot that will contain the sub-plots
    final CombinedDomainXYPlot multiPlot = new CombinedDomainXYPlot(timeAxis);

    final int[] weight = { 1, 1, 1, 1 }; // control vertical space allocated to each sub-plot

    // add subplot1...
    final XYPlot subplot1 = new XYPlot(dataset0, null, new NumberAxis(ranges[0]), new StandardXYItemRenderer());
    final NumberAxis range1 = (NumberAxis) subplot1.getRangeAxis();
    range1.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    range1.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    range1.setAutoRangeIncludesZero(false);
    multiPlot.add(subplot1, weight[0]);

    // add subplot2...
    final XYPlot subplot2 = new XYPlot(dataset1, null, new NumberAxis(ranges[1]), new StandardXYItemRenderer());
    final NumberAxis range2 = (NumberAxis) subplot2.getRangeAxis();
    range2.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    range2.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    range2.setAutoRangeIncludesZero(false);
    multiPlot.add(subplot2, weight[1]);

    // add subplot3...
    final XYPlot subplot3 = new XYPlot(dataset2, null, new NumberAxis(ranges[2]), null);
    final XYItemRenderer renderer3 = new HighLowRenderer();
    subplot3.setRenderer(renderer3);
    final NumberAxis range3 = (NumberAxis) subplot3.getRangeAxis();
    range3.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    range3.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    range3.setAutoRangeIncludesZero(false);
    multiPlot.add(subplot3, weight[2]);

    // add subplot4...
    final XYPlot subplot4 = new XYPlot(dataset3, null, new NumberAxis(ranges[3]), null);
    final XYItemRenderer renderer4 = new XYBarRenderer();
    subplot4.setRenderer(renderer4);
    final NumberAxis range4 = (NumberAxis) subplot4.getRangeAxis();
    range4.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    range4.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    range4.setAutoRangeIncludesZero(false);
    multiPlot.add(subplot4, weight[3]);

    // now make the top level JFreeChart that contains the CombinedPlot
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, multiPlot, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}

From source file:skoa.helpers.Graficos.java

/*********************************************************************************************************
 * FUNCIONES PARA CREAR LOS GRFICOS DE LA CONSULTA C! MANIPULANDO LOS DATOS OBTENIDOS DE LAS CONSULTAS.*
 *********************************************************************************************************/
private void maxMinMed() {
    //En este tipo de consultas, sacamos la DG del fichero original de datos, para ponerla en la graf.
    String dg = nombresFicheros.get(0);
    //dg=dg.substring(dg.indexOf("-")+7,dg.indexOf(".txt")); //Saca la DG del nombre del fich.
    if (dg.indexOf("D") > 0 && dg.indexOf(" ") < 0) { //Si es el resultado final de una consulta D.
        dg = dg.substring(dg.indexOf(".txt") - 13, dg.indexOf(".txt")); //Saca la DG del nombre del fich.
    } else { //Si son resultados de una consulta D.
        //As, buscando a partir de .txt da igual el tipo de consulta que sea, que se saca igual.
        dg = dg.substring(dg.indexOf(" ") - 6, dg.indexOf(".txt")); //Saca la DG del nombre del fich.
    }//from   w  ww . ja  v  a  2s  . co m
    //---------------------------------------------
    crearEstadisticas(); //Crea el fichero estadisticas.txt donde se encuentra el FECHA MAX MIN y MED en este orden
    Vector<String> vectorOrdenUnidades = new Vector<String>();
    vectorOrdenUnidades.add(unidad);
    nombresDGs.add("Max"); //Reusamos esta variable. Nos referimos al nombre de cada una de las barras que se ven.
    nombresDGs.add("Min");
    nombresDGs.add("Med");
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset = obtenerSerieBarras2(vectorOrdenUnidades);
    String unidad = "";
    for (int i = 0; i < vectorOrdenUnidades.size(); i++)
        unidad = unidad + vectorOrdenUnidades.elementAt(i) + ", ";
    unidad = unidad.substring(0, unidad.length() - 2); //Quita el ultimo espacio y la ultima coma.
    if (unidad.indexOf("C") >= 0)
        unidad = "C";
    dg = dg.replaceAll("-", "/");
    JFreeChart grafica = ChartFactory.createBarChart("Valores medidos de las direcciones de grupo", "Fechas", //titulo eje x
            "Mediciones (" + unidad + ") de " + dg, dataset, PlotOrientation.VERTICAL, true, //leyenda
            true, false);
    if (fechaInicial.equals("") & fechaFinal.equals("")) { //Si estn vacas es porque no hay resultados para ese intervalo.
        fechaInicial = " ? ";
        fechaFinal = " ? ";
    }
    TextTitle t = new TextTitle("desde " + fechaInicial + " hasta " + fechaFinal,
            new Font("SanSerif", Font.ITALIC, 12));
    grafica.addSubtitle(t);
    CategoryPlot plot = grafica.getCategoryPlot();
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    domainAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 9)); //Letra de las fechas ms pequea
    //Esconder las sombras de las barras del barchart.
    CategoryPlot categoryPlot = (CategoryPlot) grafica.getPlot();
    BarRenderer renderer = new BarRenderer();
    renderer.setShadowVisible(false);
    categoryPlot.setRenderer(renderer);
    //-------------------------------------------------
    try {
        ChartUtilities.saveChartAsJPEG(new File(ruta + "MaxMinMedSmall.jpg"), grafica, 400, 300);
        ChartUtilities.saveChartAsJPEG(new File(ruta + "MaxMinMedBig.jpg"), grafica, 900, 600);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart." + e);
    }
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates a combined and overlaid chart.
 * <p>//from  www. ja  v  a2 s .com
 * Note: from version 0.9.10, the overlaid chart is no longer supported (you can achieve
 * the same result using a regular XYPlot with multiple datasets and renderers).
 *
 * @return a combined and overlaid chart.
 */
public JFreeChart createCombinedAndOverlaidChart1() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("combined.combined-overlaid.title");
    final String subtitleStr = this.resources.getString("combined.combined-overlaid.subtitle");
    final String domain = this.resources.getString("combined.combined-overlaid.domain");
    final String[] ranges = this.resources.getStringArray("combined.combined-overlaid.ranges");

    final TimeSeries jpy = DemoDatasetFactory.createJPYTimeSeries();
    final TimeSeries mav = MovingAverage.createMovingAverage(jpy, "30 Day Moving Average", 30, 30);

    final TimeSeriesCollection dataset0 = new TimeSeriesCollection();
    dataset0.addSeries(jpy);

    final TimeSeriesCollection dataset1 = new TimeSeriesCollection();
    dataset1.addSeries(jpy);
    dataset1.addSeries(mav);

    final DefaultHighLowDataset highLowDataset = DemoDatasetFactory.createHighLowDataset();
    final XYDataset highLowDatasetMA = MovingAverage.createMovingAverage(highLowDataset, " (MA)",
            5 * 24 * 60 * 60 * 1000L, 5 * 24 * 60 * 60 * 1000L);

    // make one vertical axis for each (vertical) chart
    final NumberAxis[] valueAxis = new NumberAxis[3];
    for (int i = 0; i < valueAxis.length; i++) {
        valueAxis[i] = new NumberAxis(ranges[i]);
        if (i <= 1) {
            valueAxis[i].setAutoRangeIncludesZero(false); // override default
        }
    }

    // create CombinedPlot...
    final CombinedDomainXYPlot parent = new CombinedDomainXYPlot(new DateAxis(domain));

    final int[] weight = { 1, 2, 2 };

    // add subplot1...
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final XYPlot subplot1 = new XYPlot(dataset0, null, new NumberAxis(ranges[0]), renderer1);
    final NumberAxis axis1 = (NumberAxis) subplot1.getRangeAxis();
    axis1.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    axis1.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    axis1.setAutoRangeIncludesZero(false);
    parent.add(subplot1, weight[0]);

    // add subplot2 (an overlaid plot)...
    final XYPlot subplot2 = new XYPlot(dataset0, null, new NumberAxis(ranges[1]), new StandardXYItemRenderer());
    final NumberAxis axis2 = (NumberAxis) subplot2.getRangeAxis();
    axis2.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    axis2.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    axis2.setAutoRangeIncludesZero(false);
    subplot2.setDataset(1, dataset1);
    subplot2.setRenderer(1, new StandardXYItemRenderer());

    parent.add(subplot2, weight[1]);

    // add subplot3 (an overlaid plot)...
    final XYItemRenderer renderer3 = new HighLowRenderer();
    final XYPlot subplot3 = new XYPlot(highLowDataset, null, new NumberAxis(ranges[2]), renderer3);
    final NumberAxis axis3 = (NumberAxis) subplot3.getRangeAxis();
    axis3.setTickLabelFont(new Font("Monospaced", Font.PLAIN, 7));
    axis3.setLabelFont(new Font("SansSerif", Font.PLAIN, 8));
    axis3.setAutoRangeIncludesZero(false);
    subplot3.setDataset(1, highLowDatasetMA);
    subplot3.setRenderer(1, new StandardXYItemRenderer());

    parent.add(subplot3, weight[2]);

    // now create the master JFreeChart object
    final JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 12), parent, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 10));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Displays an XY chart that is periodically updated by a background thread.  This is to
 * demonstrate the event notification system that automatically updates charts as required.
 *
 * @return a chart.//from  w  w w .  j a  v a 2s .c  om
 */
public JFreeChart createCombinedAndOverlaidDynamicXYChart() {

    // chart title and axis labels...
    final String title = this.resources.getString("combined.dynamic.title");
    final String subtitleStr = this.resources.getString("combined.dynamic.subtitle");
    final String domainAxisLabel = this.resources.getString("combined.dynamic.domain");
    final String[] ranges = this.resources.getStringArray("combined.dynamic.ranges");

    // setup sample base 2-series dataset
    final SampleXYDataset data = new SampleXYDataset();

    // create some SubSeriesDatasets and CombinedDatasets to test events
    final XYDataset series0 = new SubSeriesDataset(data, 0);
    final XYDataset series1 = new SubSeriesDataset(data, 1);

    final CombinedDataset combinedData = new CombinedDataset();
    combinedData.add(series0);
    combinedData.add(series1);

    // create common time axis
    final NumberAxis timeAxis = new NumberAxis(domainAxisLabel);
    timeAxis.setTickMarksVisible(true);
    timeAxis.setAutoRangeIncludesZero(false);

    // make one vertical axis for each (vertical) chart
    final NumberAxis[] valueAxis = new NumberAxis[4];
    for (int i = 0; i < valueAxis.length; i++) {
        valueAxis[i] = new NumberAxis(ranges[i]);
        valueAxis[i].setAutoRangeIncludesZero(false);
    }

    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(timeAxis);

    // add subplot1...
    final XYItemRenderer renderer0 = new StandardXYItemRenderer();
    final XYPlot subplot0 = new XYPlot(series0, null, valueAxis[0], renderer0);
    plot.add(subplot0, 1);

    // add subplot2...
    final XYItemRenderer renderer1 = new StandardXYItemRenderer();
    final XYPlot subplot1 = new XYPlot(series1, null, valueAxis[1], renderer1);
    plot.add(subplot1, 1);

    // add subplot3...
    final XYPlot subplot2 = new XYPlot(series0, null, valueAxis[2], new StandardXYItemRenderer());
    subplot2.setDataset(1, series1);
    subplot2.setRenderer(1, new StandardXYItemRenderer());
    plot.add(subplot2, 1);

    // add subplot4...
    final XYItemRenderer renderer3 = new StandardXYItemRenderer();
    final XYPlot subplot3 = new XYPlot(data, null, valueAxis[3], renderer3);
    plot.add(subplot3, 1);

    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.cyan));

    // setup thread to update base Dataset
    final SampleXYDatasetThread update = new SampleXYDatasetThread(data);
    final Thread thread = new Thread(update);
    thread.start();

    return chart;

}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates a basic wafermap chart with a random dataset
 *
 * @return a wafermap chart/*  w  ww.  j a  v a 2  s .  c om*/
 */
public JFreeChart createWaferMapChart() {
    final WaferMapDataset dataset = DemoDatasetFactory.createRandomWaferMapDataset(5);
    final JFreeChart chart = ChartFactory.createWaferMapChart("Wafer Map Demo", // title
            dataset, // wafermapdataset
            PlotOrientation.VERTICAL, // vertical = notchdown
            true, // legend
            false, // tooltips
            false);

    //        final Legend legend = chart.getLegend();
    //      legend.setAnchor(Legend.EAST);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    final TextTitle copyright = new TextTitle("JFreeChart WaferMapPlot", new Font("SansSerif", Font.PLAIN, 9));
    copyright.setPosition(RectangleEdge.BOTTOM);
    copyright.setHorizontalAlignment(HorizontalAlignment.RIGHT);
    chart.addSubtitle(copyright);

    return chart;
}