Example usage for org.jfree.chart.axis NumberAxis setLowerMargin

List of usage examples for org.jfree.chart.axis NumberAxis setLowerMargin

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis setLowerMargin.

Prototype

public void setLowerMargin(double margin) 

Source Link

Document

Sets the lower margin for the axis (as a percentage of the axis range) and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:org.glotaran.core.datadisplayers.multispec.MultiSpecEditorTopComponent.java

private JFreeChart createChart(XYDataset dataset1) {
    JFreeChart chart_temp = ChartFactory.createScatterPlot(null, null, null, dataset1, PlotOrientation.VERTICAL,
            false, false, false);//from  w w w  .  j a v a2s  . c  o m

    double range = Math.abs(data.getMaxInt() - data.getMinInt());
    double dataMin, dataMax;
    if (range == 0.0) {
        dataMin = data.getMinInt() - 0.1;
        dataMax = data.getMaxInt() + 0.1;
    } else {
        dataMin = data.getMinInt();
        dataMax = data.getMaxInt();
    }
    PaintScale ps = new RainbowPaintScale(dataMin, dataMax);
    //        PaintScale ps = new RedGreenPaintScale(dataMin, dataMax);
    BufferedImage image = ImageUtilities.createColorCodedImage(this.dataset, ps);

    XYDataImageAnnotation ann = new XYDataImageAnnotation(image, 0, 0, dataset.GetImageWidth(),
            dataset.GetImageHeigth(), true);
    XYPlot plot = (XYPlot) chart_temp.getPlot();
    plot.setDomainPannable(true);
    plot.setRangePannable(true);
    plot.getRenderer().addAnnotation(ann, Layer.BACKGROUND);
    NumberAxis xAxis = (NumberAxis) plot.getDomainAxis();
    xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);
    xAxis.setVisible(false);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setVisible(false);
    return chart_temp;
}

From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java

/**
 *
 * @param dataset/*from w w w  . j a va 2  s  . c  o  m*/
 * @param tooltipGenerator
 * @param minRange
 * @param maxRange
 * @param useRT
 * @return
 */
public XYPlot provide1DCoPlot(XYZDataset dataset, SelectionAwareXYTooltipGenerator tooltipGenerator,
        double minRange, double maxRange, boolean useRT) {
    XYBlockRenderer xyb = new XYBlockRenderer();
    GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), minRange, maxRange,
            ImageTools.rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv")));

    xyb.setPaintScale(ps);
    final String[] colnames = new String[dataset.getSeriesCount()];
    for (int i = 0; i < dataset.getSeriesCount(); i++) {
        colnames[i] = "" + dataset.getSeriesKey(i);//StringTools.removeFileExt(fragments.get(i).getName());
    }
    NumberAxis na = null;
    if (useRT) {
        na = new NumberAxis("time [s]");
        na.setAutoRangeIncludesZero(false);
        na.setLowerMargin(0);
        na.setUpperMargin(0);
    } else {
        na = new NumberAxis("scan index");
    }
    // na.setVerticalTickLabels(true);
    XYPlot xyp = new XYPlot(dataset, na, new SymbolAxis("chromatogram", colnames), xyb);
    //xyb.setBlockWidth(1);
    xyp.setBackgroundPaint(ps.getPaint(ps.getLowerBound()));
    tooltipGenerator.setXYToolTipGenerator(new XYZToolTipGenerator() {
        @Override
        public String generateToolTip(XYZDataset xyzd, int i, int i1) {
            return colnames[xyzd.getY(i, i1).intValue()] + " @" + xyzd.getXValue(i, i1) + " = "
                    + xyzd.getZValue(i, i1);
        }

        @Override
        public String generateToolTip(XYDataset xyd, int i, int i1) {
            if (xyd instanceof XYZDataset) {
                return generateToolTip((XYZDataset) xyd, i, i1);
            }
            return colnames[xyd.getY(i, i1).intValue()] + ":" + xyd.getXValue(i, i1);
        }
    });
    xyb.setBaseToolTipGenerator(tooltipGenerator);
    return xyp;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.clusterchart.SimpleCluster.java

public JFreeChart createChart(DatasetMap datasets) {

    DefaultXYZDataset dataset = (DefaultXYZDataset) datasets.getDatasets().get("1");

    JFreeChart chart = ChartFactory.createBubbleChart(name, yLabel, xLabel, dataset, PlotOrientation.HORIZONTAL,
            legend, true, false);/*from w w  w  . ja v  a 2s .  c o m*/

    /*Font font = new Font("Tahoma", Font.BOLD, titleDimension);
    TextTitle title = new TextTitle(name, font);
    chart.setTitle(title);*/

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    Color colorSubInvisibleTitle = Color.decode("#FFFFFF");
    StyleLabel styleSubSubTitle = new StyleLabel("Arial", 12, colorSubInvisibleTitle);
    TextTitle subsubTitle = setStyleTitle("", styleSubSubTitle);
    chart.addSubtitle(subsubTitle);

    chart.setBackgroundPaint(color);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    //plot.setForegroundAlpha(0.50f);
    plot.setForegroundAlpha(0.65f);

    XYItemRenderer renderer = plot.getRenderer();

    //define colors
    int seriesN = dataset.getSeriesCount();
    if (colorMap != null) {
        boolean isSerieSel = true;
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getSeriesKey(i);
            String tmpName = serieName.replaceAll(" ", "");
            tmpName = tmpName.replace('.', ' ').trim();
            if (serie_selected != null && serie_selected.size() > 0) {
                String serieSel = serie_selected.get(tmpName).toString();
                isSerieSel = (serieSel.equalsIgnoreCase("TRUE") || serieSel.equalsIgnoreCase("YES")
                        || serieSel.equalsIgnoreCase("1")) ? true : false;
                serieName = tmpName;
            }

            if (color != null && isSerieSel) {
                Color color = (Color) colorMap.get(serieName);
                renderer.setSeriesPaint(i, color);
            } else {
                Color color = new Color(Integer.decode(defaultColor).intValue());
                renderer.setSeriesPaint(i, color);
            }
        }
    }

    // increase the margins to account for the fact that the auto-range 
    // doesn't take into account the bubble size...
    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    //domainAxis.setAutoRange(true);
    domainAxis.setRange(yMin, yMax);
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());

    //rangeAxis.setAutoRange(true);
    rangeAxis.setRange(xMin, xMax);

    TickUnits units = null;
    if (decimalXValues == false)
        units = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        units = (TickUnits) NumberAxis.createStandardTickUnits();
    rangeAxis.setStandardTickUnits(units);

    TickUnits domainUnits = null;
    if (decimalYValues == false)
        domainUnits = (TickUnits) NumberAxis.createIntegerTickUnits();
    else
        domainUnits = (TickUnits) NumberAxis.createStandardTickUnits();
    domainAxis.setStandardTickUnits(domainUnits);

    rangeAxis.setLowerMargin(1.0);
    rangeAxis.setUpperMargin(1.0);

    domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setLabelPaint(styleYaxesLabels.getColor());
    domainAxis
            .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize()));
    domainAxis.setTickLabelPaint(styleYaxesLabels.getColor());

    domainAxis.setLowerMargin(1.0);
    domainAxis.setUpperMargin(1.0);
    //DecimalFormat format=(new DecimalFormat("0"));
    //rangeAxis.setNumberFormatOverride(format);

    if (legend == true)
        drawLegend(chart);

    return chart;
}

From source file:net.sf.maltcms.chromaui.charts.Chromatogram1DChartProvider.java

/**
 *
 * @param fragments/*from  www.  j  av  a2s  . com*/
 * @param ticvar
 * @param useRT
 * @return
 */
public XYPlot provide1DCoPlot(List<IFileFragment> fragments, String ticvar, boolean useRT) {

    final String satVar = "scan_acquisition_time";

    DefaultXYZDataset cd = new DefaultXYZDataset();
    int rowIdx = 0;
    double min = 0;
    double max = 1;
    double minRT = Double.POSITIVE_INFINITY;
    double maxRT = Double.NEGATIVE_INFINITY;

    int y = 0;
    for (IFileFragment f : fragments) {

        double[] domainValues = null;
        if (useRT) {
            domainValues = (double[]) f.getChild(satVar).getArray().get1DJavaArray(double.class);
        } else {
            domainValues = (double[]) f.getChild("scan_index").getArray().get1DJavaArray(double.class);
        }

        double[] tic = (double[]) f.getChild(ticvar).getArray().get1DJavaArray(double.class);
        double maxtic = MathTools.max(tic);
        double mintic = MathTools.min(tic);
        double[][] values = new double[3][tic.length];
        for (int i = 0; i < tic.length; i++) {
            values[0][i] = domainValues[i];
            values[1][i] = y;
            values[2][i] = Math.sqrt((tic[i] - mintic) / (maxtic - mintic));
        }

        y++;
        cd.addSeries(f.getName(), values);
    }

    // ArrayDouble.D1 a = new ArrayDouble.D1(npoints);
    // int offset = 0;
    // for (IFileFragment f : t) {
    // Array tic = f.getChild(ticvar).getArray();
    // int len = tic.getShape()[0];
    // Array.arraycopy(tic, 0, a, offset, len);
    // offset += len;
    // }
    // histogram with fixed binsize
    // fill intensities into adequate bin, raise count in bin by one
    // afterwards, relative frequency within a bin gives a normalization
    // coefficient
    XYBlockRenderer xyb = new XYBlockRenderer();
    GradientPaintScale ps = new GradientPaintScale(ImageTools.createSampleTable(256), min, max,
            ImageTools.rampToColorArray(new ColorRampReader().readColorRamp("res/colorRamps/bcgyr.csv")));

    xyb.setPaintScale(ps);
    final String[] colnames = new String[fragments.size()];
    for (int i = 0; i < colnames.length; i++) {
        colnames[i] = StringTools.removeFileExt(fragments.get(i).getName());
    }
    NumberAxis na = null;
    if (useRT) {
        na = new NumberAxis("time [s]");
        na.setAutoRangeIncludesZero(false);
        na.setLowerMargin(0);
        na.setUpperMargin(0);
    } else {
        na = new NumberAxis("scan index");
    }
    // na.setVerticalTickLabels(true);
    XYPlot xyp = new XYPlot(cd, na, new SymbolAxis("chromatogram", colnames), xyb);
    xyb.setBlockWidth(1);
    xyp.setBackgroundPaint(Color.BLACK);
    xyb.setBaseToolTipGenerator(new XYZToolTipGenerator() {
        @Override
        public String generateToolTip(XYZDataset xyzd, int i, int i1) {
            return colnames[xyzd.getY(i, i1).intValue()] + " @" + xyzd.getXValue(i, i1) + " = "
                    + xyzd.getZValue(i, i1);
        }

        @Override
        public String generateToolTip(XYDataset xyd, int i, int i1) {
            if (xyd instanceof XYZDataset) {
                return generateToolTip((XYZDataset) xyd, i, i1);
            }
            return colnames[xyd.getY(i, i1).intValue()] + ":" + xyd.getXValue(i, i1);
        }
    });
    return xyp;
}

From source file:org.operamasks.faces.render.graph.ChartRenderer.java

private void setNumberAxisStyles(NumberAxis axis, UIAxis comp) {
    axis.setInverted(comp.isInverted());

    Object lowerBound = comp.getLowerBound();
    Object upperBound = comp.getUpperBound();
    Double lowerMargin = comp.getLowerMargin();
    Double upperMargin = comp.getUpperMargin();

    if (lowerBound != null)
        axis.setLowerBound(Coercion.coerceToDouble(lowerBound));
    if (upperBound != null)
        axis.setUpperBound(Coercion.coerceToDouble(upperBound));
    if (lowerMargin != null)
        axis.setLowerMargin(lowerMargin);
    if (upperMargin != null)
        axis.setUpperMargin(upperMargin);

    Double tickStep = comp.getTickStep();
    String tickFormat = comp.getTickLabelFormat();

    if ((tickStep != null && tickStep > 0) || tickFormat != null) {
        if (tickFormat == null) {
            axis.setTickUnit(new NumberTickUnit(tickStep));
        } else if (tickStep == null) {
            NumberFormat format = new DecimalFormat(tickFormat);
            axis.setNumberFormatOverride(format);
        } else {//from   w w w. j  av  a2  s  .  c om
            NumberFormat format = new DecimalFormat(tickFormat);
            axis.setTickUnit(new NumberTickUnit(tickStep, format));
        }
    }
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private static JFreeChart createEmptyChart(XYZDataset dataset) {
    NumberAxis xAxis = new NumberAxis("address");
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);/*from   ww  w  . ja  va  2  s .  c  om*/
    NumberAxis yAxis = new NumberAxis("address");
    yAxis.setAutoRangeIncludesZero(false);
    yAxis.setInverted(false);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    // yAxis.setAxisLinePaint(Color.pink);
    // yAxis.setTickMarkPaint(Color.white);
    yAxis.setTickLabelFont(new Font("Dialog", 0, 7));
    yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    MyXYBlockRenderer renderer = new MyXYBlockRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // plot.setBackgroundPaint(Color.white);
    // plot.setDomainGridlineStroke(new BasicStroke(1));
    plot.setDomainGridlinePaint(Color.white);

    // plot.setRangeGridlineStroke(new BasicStroke(1));
    plot.setRangeGridlinePaint(Color.white);

    JFreeChart chart = new JFreeChart("Memory read/write hot zone", new Font("Serif", Font.PLAIN, 12), plot,
            true);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    return chart;
}

From source file:no.met.jtimeseries.chart.ChartPlotter.java

public void addThresholdLineChart(TimeBase timeBase, NumberPhenomenon ph, PlotStyle plotStyle) {
    NumberPhenomenon phenomenon = ph.clone();
    if (phenomenon.getItems().size() > 0) {
        XYItemRenderer renderer = RendererFactory.createRenderer(SplineStyle.STANDARD);
        // if using hybrid
        if (plotStyle.getSplineStyle().equalsIgnoreCase(SplineStyle.HYBRID)) {
            phenomenon.doHybridSpline(0.5d, 4);
            renderer = RendererFactory.createRenderer(SplineStyle.NONE);
        }/*from   ww w.ja v  a 2  s. c  om*/

        if (plotStyle.getNonNegative()) {
            phenomenon.removeNegativeValues();
        }

        // add threshold point into the dataset
        phenomenon.addThresholdPoints(plotStyle.getThreshold());
        // create threshold data set with specified threshold value
        XYDataset dataset = phenomenon.getTimeSeriesWithThreshold(plotStyle.getTitle(), timeBase,
                plotStyle.getThreshold());

        // render even series lines with color1 and odd series lines with
        // color2
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            if (i % 2 == 0)
                renderer.setSeriesPaint(i, plotStyle.getPlusDegreeColor());
            else
                renderer.setSeriesPaint(i, plotStyle.getMinusDegreeColor());
            renderer.setSeriesStroke(i, plotStyle.getStroke());
            // hidden legend
            renderer.setSeriesVisibleInLegend(i, false);
        }

        plot.setDataset(plotIndex, dataset);
        plot.setRenderer(plotIndex, renderer);

        NumberAxis numberAxis;
        // null check for number axis
        if (plotStyle.getNumberAxis() == null) {
            numberAxis = new NumberAxis(plotStyle.getTitle());
            numberAxis.setAutoRangeIncludesZero(false);
            numberAxis.setLabelPaint(plotStyle.getLabelColor());
            numberAxis.setTickLabelPaint(plotStyle.getLabelColor());

            // ugly calculation
            double max = phenomenon.getMaxValue();
            double min = phenomenon.getMinValue();
            int tUnit = getTemperatureTicksUnit(max, min);
            int[] range = calculateAxisMaxMin(phenomenon, tUnit, plotStyle.getTotalTicks());

            NumberTickUnit ntu = new NumberTickUnit(tUnit);
            numberAxis.setTickUnit(ntu);
            numberAxis.setLowerMargin(LOWER_PLOT_MARGIN);
            numberAxis.setRangeWithMargins(range[1], range[0]);
        } else {
            numberAxis = plotStyle.getNumberAxis();
        }

        plot.setRangeAxis(rangeAxisIndex, numberAxis);

        Date minDate = phenomenon.getStartTime();
        Date maxDate = phenomenon.getEndTime();

        DateAxis domainAxis = (DateAxis) plot.getDomainAxis();
        domainAxis.setRange(minDate, maxDate);

        plot.mapDatasetToRangeAxis(plotIndex, rangeAxisIndex);

        plotIndex++;
        rangeAxisIndex++;
    }
}

From source file:com.peterbochs.instrument.InstrumentPanel.java

private static JFreeChart createChart(XYZDataset dataset) {
    NumberAxis xAxis = new NumberAxis("address (" + jBlockSizeComboBox.getSelectedItem() + ")");
    xAxis.setLowerMargin(0.0);
    xAxis.setUpperMargin(0.0);/*from  ww  w.  j  a  v a2  s.c om*/
    xAxis.setAxisLinePaint(Color.cyan);
    xAxis.setTickMarkPaint(Color.cyan);
    // xAxis.setAutoTickUnitSelection(false);
    // xAxis.setTickUnit(new NumberTickUnit(1));
    // NumberFormat nf = NumberFormat.getPercentInstance();
    // xAxis.setNumberFormatOverride(nf);
    // xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis yAxis = new NumberAxis("address (" + jBlockSizeComboBox.getSelectedItem() + " KB)");
    // yAxis.setAutoRangeIncludesZero(true);
    // yAxis.setInverted(false);
    yAxis.setLowerMargin(0.0);
    yAxis.setUpperMargin(0.0);
    yAxis.setAxisLinePaint(Color.pink);
    yAxis.setTickMarkPaint(Color.pink);
    // yAxis.setTickUnit(new NumberTickUnit(10));
    // yAxis.setTickLabelFont(new Font("Dialog", 0, 7));
    // yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    MyXYBlockRenderer renderer = new MyXYBlockRenderer();
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);

    // plot.setBackgroundPaint(Color.white);
    // plot.setDomainGridlineStroke(new BasicStroke(1));
    plot.setDomainGridlinePaint(Color.white);

    // plot.setRangeGridlineStroke(new BasicStroke(1));
    plot.setRangeGridlinePaint(Color.white);

    // JFreeChart chart = new JFreeChart("Memory read/write hot zone", new
    // Font("Serif", Font.PLAIN, 12), plot, true);
    JFreeChart chart = new JFreeChart("Memory read/write hot zone", plot);
    chart.removeLegend();
    chart.setBackgroundPaint(Color.white);

    return chart;
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

/**
 * Creates a chart.//from   w  w  w  .  j av a  2 s .co m
 * 
 * @param dataset  the dataset.
 * 
 * @return The dataset.
 */
private JFreeChart createCandlestickChart(OHLCDataset priceOHLCDataset) {
    final String title = getBestStockName();

    final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date"));
    final NumberAxis valueAxis = new NumberAxis(GUIBundle.getString("ChartJDialog_Price"));
    valueAxis.setAutoRangeIncludesZero(false);
    valueAxis.setUpperMargin(0.0);
    valueAxis.setLowerMargin(0.0);
    XYPlot plot = new XYPlot(priceOHLCDataset, timeAxis, valueAxis, null);

    final CandlestickRenderer candlestickRenderer = new CandlestickRenderer();
    plot.setRenderer(candlestickRenderer);

    // Give good width when zoom in, but too slow in calculation.
    ((CandlestickRenderer) plot.getRenderer()).setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(timeAxis);
    cplot.add(plot, 3);
    cplot.setGap(8.0);

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

    org.yccheok.jstock.charting.Utils.applyChartThemeEx(chart);

    // Handle zooming event.
    chart.addChangeListener(this.getChartChangeListner());

    return chart;
}

From source file:org.yccheok.jstock.gui.charting.ChartJDialog.java

/**
 * Creates a chart./*from  w ww .  j  a  v a2  s  . c  o  m*/
 *
 * @return a chart.
 */
private JFreeChart createPriceVolumeChart(XYDataset priceDataset, XYDataset volumeDataset) {
    final String title = getBestStockName();

    final ValueAxis timeAxis = new DateAxis(GUIBundle.getString("ChartJDialog_Date"));
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);

    final NumberAxis rangeAxis1 = new NumberAxis(GUIBundle.getString("ChartJDialog_Price"));
    rangeAxis1.setAutoRangeIncludesZero(false); // override default
    rangeAxis1.setLowerMargin(0.40); // to leave room for volume bars
    DecimalFormat format = new DecimalFormat("0.00#");
    rangeAxis1.setNumberFormatOverride(format);

    XYPlot plot = new XYPlot(priceDataset, timeAxis, rangeAxis1, null);

    XYItemRenderer renderer1 = new XYLineAndShapeRenderer(true, false);
    renderer1.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00#")));
    plot.setRenderer(0, renderer1);

    final NumberAxis rangeAxis2 = new NumberAxis("Volume");
    rangeAxis2.setUpperMargin(1.00); // to leave room for price line
    plot.setRangeAxis(1, rangeAxis2);
    plot.setDataset(1, volumeDataset);
    plot.mapDatasetToRangeAxis(1, 1);

    XYBarRenderer renderer2 = new XYBarRenderer(0.20);
    renderer2.setBaseToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
    plot.setRenderer(1, renderer2);

    CombinedDomainXYPlot cplot = new CombinedDomainXYPlot(timeAxis);
    cplot.add(plot, 1);
    cplot.setGap(8.0);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, cplot, true);
    org.yccheok.jstock.charting.Utils.applyChartThemeEx(chart);

    // Only do it after applying chart theme.
    org.yccheok.jstock.charting.Utils.setPriceSeriesPaint(renderer1);
    org.yccheok.jstock.charting.Utils.setVolumeSeriesPaint(renderer2);

    // Handle zooming event.
    chart.addChangeListener(this.getChartChangeListner());

    return chart;
}