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

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

Introduction

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

Prototype

public static TickUnitSource createStandardTickUnits() 

Source Link

Document

Creates the standard tick units.

Usage

From source file:org.cyberoam.iview.charts.CustomDomainAxis.java

public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
    JFreeChart chart = null;/*  w  ww  .  j  a v  a2 s . c  om*/
    //   DefaultCategoryDataset dataset=null;
    CustomCategoryDataset datasetCustom = null;

    try {
        ReportColumnBean reportColumnBeanX = null;
        ReportColumnBean reportColumnBeanY = null;
        ReportColumnBean reportColumnBeanZ = null;
        GraphBean graphBean = null;

        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());
        reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getXColumnId());//getting ReportColumnBean For X Axis
        String xColumnDBname = reportColumnBeanX.getDbColumnName();
        reportColumnBeanY = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnDBname = reportColumnBeanY.getDbColumnName();
        String zColumnDBname = null;

        datasetCustom = new CustomCategoryDataset();
        rsw.beforeFirst();
        String data = "";
        int count = -1;
        Boolean showLegend = false;
        if (graphBean.getZColumnId() == -1) {

            while (rsw.next()) {
                data = rsw.getString(xColumnDBname);
                datasetCustom.addValue(rsw.getLong(yColumnDBname), "", data);
            }

        } else {
            String zData;
            showLegend = true;
            reportColumnBeanZ = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                    graphBean.getZColumnId());
            zColumnDBname = reportColumnBeanZ.getDbColumnName();
            while (rsw.next()) {
                data = rsw.getString(xColumnDBname);
                zData = rsw.getString(zColumnDBname);
                datasetCustom.addValue(rsw.getLong(yColumnDBname), zData, data);
                count++;
            }

        }
        chart = ChartFactory.createLineChart("", // chart title
                "", // domain axis label
                "", // range axis label
                datasetCustom, // data
                PlotOrientation.VERTICAL, // orientation
                showLegend, // include legend
                true, // tooltips
                false // urls
        );
        LegendTitle legendTitle = chart.getLegend();
        if (legendTitle != null)
            legendTitle.setItemFont(new Font("Vandara", Font.BOLD, 11));
        chart.setBackgroundPaint(Color.white);
        CategoryPlot plot = chart.getCategoryPlot();
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setDomainGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10));
        rangeAxis.setTickLabelInsets(new RectangleInsets(0, 0, 0, 5));
        rangeAxis.setTickLabelsVisible(true);
        rangeAxis.setTickMarksVisible(false);
        rangeAxis.setAxisLineVisible(false);
        CustomDomainAxis catAxis = new CustomDomainAxis();
        CustomDomainAxis.counter = 0;
        CustomDomainAxis.colCount = datasetCustom.getColumnCount();
        catAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        catAxis.setTickMarksVisible(false);
        catAxis.setTickLabelInsets(new RectangleInsets(10, 15, 30, 10));
        catAxis.setAxisLineVisible(false);
        catAxis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(20 * Math.PI / 180));
        plot.setDomainAxis(catAxis);
        final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
        renderer.setSeriesPaint(0, Color.DARK_GRAY);
        if (count > 0) {
            Color[] colors = null;
            colors = new Color[5];
            colors[0] = new Color(24, 112, 176);
            colors[1] = new Color(168, 192, 232);
            colors[2] = new Color(248, 120, 8);
            colors[3] = new Color(248, 184, 120);
            colors[4] = new Color(152, 216, 136);
            for (int i = 0; i < count && i < colors.length; i++)
                renderer.setSeriesPaint(i, colors[i]);
        }
    } catch (Exception e) {
        CyberoamLogger.appLog.debug("LineChart: " + e.getMessage(), e);
    }
    return chart;
}

From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYBarChart.java

/**
 * Toggel the axis ticks to show a standard thing or just integers
 * //w  ww .j  a  v  a  2  s .c  om
 * @param showIntegers - flag to activate integer ticks
 */
public void toggleIntegerTicks(boolean showIntegers) {
    if (thePlot != null) {
        NumberAxis rangeAxis = (NumberAxis) ((XYPlot) thePlot).getRangeAxis();

        if (showIntegers) {
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        } else {
            rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        }
    }
}

From source file:eu.hydrologis.jgrass.charting.impl.JGrassXYLineChart.java

/**
 * Toggel the axis ticks to show a standard thing or just integers
 * //from   w  w w  . j a  va 2  s  .  c  o  m
 * @param showIntegers - flag to activate integer ticks
 */
public void toggleIntegerTicks(boolean showIntegers) {
    if (thePlot != null) {
        final NumberAxis rangeAxis = (NumberAxis) ((XYPlot) thePlot).getRangeAxis();

        if (showIntegers) {
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        } else {
            rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        }
    }
}

From source file:org.cyberoam.iview.charts.CustomCategoryDataset.java

/**
 * This method generates JFreeChart instance for 3D Stacked Column chart with iView customization.
 * @param reportID specifies that for which report Chart is being prepared.
 * @param rsw specifies data set which would be used for the Chart
 * @param requeest used for Hyperlink generation from uri.
 * @return jfreechart instance with iView Customization.
 */// w w w . j  ava  2  s.  c  om
public static JFreeChart getChart(int reportId, ResultSetWrapper rsw, HttpServletRequest request) {
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportId);
    JFreeChart chart = null;
    try {
        /*
         * Create data set based on rsw object.
         */
        ReportColumnBean reportColumnBean = null;
        GraphBean graphBean = null;
        DataLinkBean dataLinkBean = null;
        CustomCategoryDataset dataset = new CustomCategoryDataset();
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getXColumnId());//getting ReportColumnBean For X Axis
        String xColumnDBname = reportColumnBean.getDbColumnName();
        reportColumnBean.getColumnName();

        //Wheather DataLink is Given For X Axis column
        if (reportColumnBean.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId());
        }

        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnDBname = reportColumnBean.getDbColumnName();
        reportColumnBean.getColumnName();

        //if DataLink is not Given For X Axis column then Check of Y Axis Column
        if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId());
        }
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getZColumnId());
        //String zColumnDbname = reportColumnBean.getDbColumnName();
        String xData = null, zData = null;
        //Preparing DataSet
        rsw.beforeFirst();
        while (rsw.next()) {
            xData = rsw.getString(xColumnDBname);
            //zData = rsw.getString(zColumnDbname);
            zData = TabularReportGenerator.getFormattedColumn(reportColumnBean.getColumnFormat(),
                    reportColumnBean.getDbColumnName(), rsw);
            if (xData == null || "".equalsIgnoreCase(xData) || "null".equalsIgnoreCase(xData))
                xData = "N/A";
            dataset.addValue(new Long(rsw.getLong(yColumnDBname)), zData, xData, rsw.getString("deviceid"));
        }

        //Create the jfree chart instance.
        chart = ChartFactory.createStackedBarChart3D("", // chart title
                "", "", dataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, // tooltips?
                false // URLs?
        );
        /*
         *Setting additional customization to the chart. 
         */
        //Set the background color for the chart...
        chart.setBackgroundPaint(Color.white);
        //Get a reference to the plot for further customisation...
        CategoryPlot plot = chart.getCategoryPlot();
        plot.setBackgroundPaint(new Color(245, 245, 245));
        plot.setDomainGridlinePaint(Color.white);
        plot.setDomainGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

        //Set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();

        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        if (reportColumnBean.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) {
            rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4));
        }
        rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10));
        rangeAxis.setTickLabelsVisible(true);
        rangeAxis.setTickMarksVisible(false);
        rangeAxis.setAxisLineVisible(false);

        Axis domainAxis = plot.getDomainAxis();
        domainAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10));
        domainAxis.setTickMarksVisible(false);
        domainAxis.setAxisLineVisible(false);

        LegendTitle legendTitle = chart.getLegend();
        legendTitle.setItemFont(new Font("Arial", Font.CENTER_BASELINE, 11));

        BarRenderer renderer = (BarRenderer) plot.getRenderer();
        renderer.setDrawBarOutline(false);
        renderer.setMaximumBarWidth(0.05);

        renderer.setSeriesPaint(0, new Color(24, 112, 176));
        renderer.setSeriesPaint(1, new Color(168, 192, 232));
        renderer.setSeriesPaint(2, new Color(248, 120, 8));
        renderer.setSeriesPaint(3, new Color(248, 184, 120));
        renderer.setSeriesPaint(4, new Color(152, 216, 136));
        if (dataLinkBean != null && request != null) {
            renderer.setBaseItemURLGenerator(new CustomURLGeneratorForStackedChart(
                    dataLinkBean.generateURLForChart(request), "", "deviceid"));
        }
        renderer.setBaseToolTipGenerator(new CustomToolTipGeneratorForStacked());
    } catch (Exception e) {
        CyberoamLogger.appLog.debug("StackedColumn3D.e:" + e, e);
    }
    return chart;
}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

private static JFreeChart createCustomXYStepChart(TimePeriodValuesCollection prices) {
    DateAxis xAxis = new DateAxis(null);
    NumberAxis yAxis = new NumberAxis("price");
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    XYPlot plot = new XYPlot(prices, xAxis, yAxis, null);
    plot.setRenderer(new XYStepRenderer(null, null));
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

public static JFreeChart createCustomXYStepAreaChart(TimePeriodValuesCollection top,
        TimePeriodValuesCollection bottom) {
    DateAxis xAxis = new DateAxis(null);
    NumberAxis yAxis = new NumberAxis("price");
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    yAxis.setUpperBound(100);/*from w  w w. j  ava 2 s.co  m*/
    yAxis.setLowerBound(0.0);

    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setDataset(0, top);
    plot.setDataset(1, bottom);
    XYStepAreaRenderer bottomRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null);
    XYStepAreaRenderer topRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null);
    topRenderer.setRangeBase(1.0);
    topRenderer.setSeriesPaint(0, new Color(204, 255, 153));
    bottomRenderer.setSeriesPaint(0, new Color(51, 255, 204));
    plot.setRenderer(bottomRenderer);
    plot.setRenderer(1, topRenderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:org.jgrasstools.gears.ui.OmsMatrixCharter.java

private JFreeChart doBarChart() {
    XYSeriesCollection collection = getSeriesCollection();
    XYBarDataset xyBarDataset = new XYBarDataset(collection, minInterval);
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    if (doHorizontal) {
        orientation = PlotOrientation.HORIZONTAL;
    }//  www . j av a2  s.c o m
    JFreeChart chart = ChartFactory.createHistogram(inTitle, inLabels[0], inLabels[1], xyBarDataset,
            orientation, doLegend, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setForegroundAlpha(0.85f);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    double delta = (max - min) * 0.1;
    yAxis.setRange(min, max + delta);
    yAxis.setMinorTickCount(4);
    yAxis.setMinorTickMarksVisible(true);
    if (inFormats != null && inFormats.length > 0 && inFormats[1].trim().length() > 0) {
        yAxis.setNumberFormatOverride(new DecimalFormat(inFormats[1]));
    }

    if (inFormats != null && inFormats.length > 0 && inFormats[0].trim().length() > 0) {
        ValueAxis domainAxis = plot.getDomainAxis();
        if (domainAxis instanceof NumberAxis) {
            NumberAxis xAxis = (NumberAxis) domainAxis;
            xAxis.setNumberFormatOverride(new DecimalFormat(inFormats[0]));
        }
    }

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    if (inColors != null) {
        String[] colorSplit = inColors.split(";");
        for (int i = 0; i < colorSplit.length; i++) {
            String[] split = colorSplit[i].split(",");
            int r = (int) Double.parseDouble(split[0]);
            int g = (int) Double.parseDouble(split[1]);
            int b = (int) Double.parseDouble(split[2]);
            renderer.setSeriesPaint(i, new Color(r, g, b));
        }
    }

    return chart;
}

From source file:org.cyberoam.iview.charts.CustomCategoryAxis.java

/**
 * This method generates JFreeChart instance for 3D Bar chart with iView customization.
 * @param reportID specifies that for which report Chart is being prepared.
 * @param rsw specifies data set which would be used for the Chart
 * @param requeest used for Hyperlink generation from uri.
 * @return jfreechart instance with iView Customization.
 *//* www. j  a va  2  s  .  co  m*/
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    JFreeChart chart = null;
    boolean isPDF = false;
    try {
        if (request == null) {
            isPDF = true;
        }
        /*
         * Create data set based on rsw object.
         */
        ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
        ReportColumnBean reportColumnBeanX, reportColumnBeanY = null;

        GraphBean graphBean = null;
        DataLinkBean dataLinkBean = null;
        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean
        reportColumnBeanX = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getXColumnId());//getting ReportColumnBean For X Axis
        if (reportColumnBeanX.getDataLinkId() != -1) {
            dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBeanX.getDataLinkId());
        }

        reportColumnBeanY = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        rsw.beforeFirst();
        int i = 0;
        DecimalFormat placeHolder = new DecimalFormat("00");
        String xData = null;
        String graphurl = "";
        HashMap<Integer, String> urlmap = new HashMap<Integer, String>();
        while (rsw.next()) {
            xData = rsw.getString(reportColumnBeanX.getDbColumnName());
            if (dataLinkBean != null && request != null) {
                //datalink id is non -1 in tblcolumnreport table means another report is avaialble so set url 
                // here multiple url possible bec multiple record so take hashmap and store url. 
                // we have dataset but dataset is occupied.
                graphurl = dataLinkBean.generateURLForChart(rsw, request);
                urlmap.put(new Integer(i), graphurl);
            }
            //dataset second arugument use for bar line of graph and third argument give name of graph
            dataset.addValue(new Long(rsw.getLong(reportColumnBeanY.getDbColumnName())), "",
                    placeHolder.format(i) + xData);
            i++;
        }
        // we define object of CustomURLGeneratorForBarChart and if datalinkid is not -1 then it object define for link
        CustomURLGeneratorForBarChart customURLGeneratorForBarChart = null;
        if (dataLinkBean != null && request != null) {
            customURLGeneratorForBarChart = new CustomURLGeneratorForBarChart(
                    dataLinkBean.generateURLForChart(request), reportColumnBeanX.getDbColumnName());
            customURLGeneratorForBarChart.setUrlMap(urlmap);
        }
        /*
         * Create the jfree chart object.
         */
        String title = isPDF ? reportBean.getTitle() : "";
        chart = ChartFactory.createBarChart3D(title, // chart title
                "", // domain axis label
                "", dataset, // data            
                PlotOrientation.HORIZONTAL, // orientation
                false, // include legend
                true, // tooltips?
                false // URLs?
        );

        /*
         *Setting additional customization to the chart. 
         */
        //Set background color
        chart.setBackgroundPaint(Color.white);
        //Get a reference to the plot for further customisation
        CategoryPlot plot = chart.getCategoryPlot();
        plot.setBackgroundPaint(Color.white);
        plot.setDomainGridlinePaint(Color.white);
        plot.setDomainGridlinesVisible(true);
        plot.setRangeGridlinePaint(Color.DARK_GRAY);
        plot.setForegroundAlpha(0.8f);
        plot.setDomainGridlineStroke(new BasicStroke(2));
        plot.setOutlineVisible(false);
        plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

        //Set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        if (reportColumnBeanY.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) {
            rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4));
        }
        rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
        rangeAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        rangeAxis.setTickLabelsVisible(true);
        rangeAxis.setTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(false);
        rangeAxis.setLabel(reportColumnBeanY.getColumnName());
        rangeAxis.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 12));
        rangeAxis.setLabelPaint(new Color(35, 139, 199));

        CustomCategoryAxis catAxis = new CustomCategoryAxis();
        catAxis.setTickLabelFont(new Font("Arial", Font.CENTER_BASELINE, 10));
        catAxis.setTickMarksVisible(false);
        catAxis.setAxisLineVisible(false);
        catAxis.setLabel(reportColumnBeanX.getColumnName());
        catAxis.setLabelFont(new Font("Arial", Font.CENTER_BASELINE, 12));
        catAxis.setLabelPaint(new Color(35, 139, 199));
        catAxis.setLabelFormat(reportColumnBeanX.getColumnFormat());

        plot.setDomainAxis(catAxis);

        //Set custom color for the chart.         
        CategoryItemRenderer renderer = new CustomRenderer(new Paint[] { new Color(254, 211, 41),
                new Color(243, 149, 80), new Color(199, 85, 82), new Color(181, 105, 152),
                new Color(69, 153, 204), new Color(155, 212, 242), new Color(52, 172, 100),
                new Color(164, 212, 92), new Color(177, 155, 138), new Color(149, 166, 141) });

        plot.setRenderer(renderer);

        BarRenderer renderer2 = (BarRenderer) plot.getRenderer();
        renderer2.setDrawBarOutline(false);
        renderer2.setBaseItemLabelsVisible(true);
        renderer2.setMaximumBarWidth(0.04);

        if (dataLinkBean != null && request != null) {
            renderer.setBaseItemURLGenerator(customURLGeneratorForBarChart);
            //renderer.setBaseItemURLGenerator(new CustomURLGeneratorForBarChart(dataLinkBean.generateURLForChart(request),reportColumnBeanX.getDbColumnName()));
        }
        renderer.setBaseToolTipGenerator(new CustomToolTipGenerator());
        renderer.setBaseToolTipGenerator(new CustomToolTipGenerator());
        renderer.setBaseToolTipGenerator(
                new CustomToolTipGenerator("{2} " + reportColumnBeanY.getColumnName()));
    } catch (Exception e) {
        CyberoamLogger.appLog.debug("Bar3D.e:" + e, e);
    }
    return chart;
}

From source file:net.commerce.zocalo.freechart.ChartGenerator.java

public static JFreeChart createOverlaidOHLCAndStepChart(TimePeriodValuesCollection bottom,
        TimePeriodValuesCollection top, OHLCDataset ohlCdata) {
    DateAxis xAxis = new DateAxis(null);
    NumberAxis yAxis = new NumberAxis("price");
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    yAxis.setUpperBound(100);//w  w  w .jav a 2  s  .  com
    yAxis.setLowerBound(0.0);

    XYPlot plot = new XYPlot(null, xAxis, yAxis, null);
    plot.setDataset(0, bottom);
    plot.setDataset(1, top);
    plot.setDataset(2, ohlCdata);

    XYStepAreaRenderer bottomRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null);
    XYStepAreaRenderer topRenderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA, null, null);
    HighLowRenderer hiLoRenderer = new HighLowRenderer();

    topRenderer.setRangeBase(1.0);
    topRenderer.setSeriesPaint(0, new Color(204, 255, 153));
    bottomRenderer.setSeriesPaint(0, new Color(51, 255, 204));
    plot.setRenderer(bottomRenderer);
    plot.setRenderer(1, topRenderer);
    plot.setRenderer(2, hiLoRenderer);

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    return new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:uk.co.moonsit.sockets.GraphClient.java

private NumberAxis getTheRangeAxis(int index) {//, DatasetAndAxis[] dAnda) {
    //if (dAnda[index].numberAxisObj !=null) {
    //  return dAnda[index].numberAxisObj;
    //}/* www. j a  v a 2s . c om*/

    NumberAxis rangeAxis;
    Color axisColor = getAxisColor(index);
    String axisLabel = "Range";
    if (index > 0) {
        axisLabel += "-" + (index + 1);
    }
    rangeAxis = new NumberAxis(axisLabel);
    rangeAxis.setTickLabelFont(new Font("Arial", Font.PLAIN, 9));
    rangeAxis.setLabelFont(new Font("Arial", Font.PLAIN, 12));
    rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    // rangeAxis.setRange(new Range(0,0)); // need to set a range or we get a NaN on getRange() calls
    //rangeAxis.setAutoRange(false);
    rangeAxis.setAutoRangeIncludesZero(false);

    // set colors
    rangeAxis.setLabelPaint(axisColor);
    rangeAxis.setAxisLinePaint(axisColor);
    rangeAxis.setLabelPaint(axisColor);
    rangeAxis.setTickLabelPaint(axisColor);
    rangeAxis.setTickMarkPaint(axisColor);
    //dAnda[index].numberAxisObj=rangeAxis;
    return rangeAxis;
}