Example usage for org.jfree.chart.renderer.category BarRenderer setBaseItemURLGenerator

List of usage examples for org.jfree.chart.renderer.category BarRenderer setBaseItemURLGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category BarRenderer setBaseItemURLGenerator.

Prototype

@Override
public void setBaseItemURLGenerator(CategoryURLGenerator generator) 

Source Link

Document

Sets the base item URL generator and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:com.ewcms.plugin.report.generate.service.chart.ChartGenerationService.java

/**
 * ?//from  w ww  .  ja v  a  2 s . c o m
 *
 * @param title 
 * @param titleFont 
 * @param categoryAxisLabel 
 * @param valueAxisLabel 
 * @param data ??
 * @param orientation ?
 * @param legend 
 * @param tooltips ????
 * @param urls ??URL
 * @param urlGenerator
 *
 * @return ?
 */
public static JFreeChart createBarChart(String title, java.awt.Font titleFont, String categoryAxisLabel,
        String valueAxisLabel, CategoryDataset data, PlotOrientation orientation, boolean legend,
        boolean tooltips, boolean urls, CategoryURLGenerator urlGenerator) {
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    BarRenderer renderer = new BarRenderer();

    if (tooltips) {
        //            renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        //            renderer.setItemURLGenerator(urlGenerator);
        renderer.setBaseItemURLGenerator(urlGenerator);
    }
    CategoryPlot plot = new CategoryPlot(data, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, titleFont, plot, legend);

    return chart;

}

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.
 *//*from ww  w .  j  a v a  2s .co  m*/
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:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createBarChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    BarRenderer renderer = new BarRenderer();
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        renderer.setBaseNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        renderer.setBaseNegativeItemLabelPosition(position2);
    }//www  .  j  av  a 2  s .  c o  m
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart("Bar Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    renderer.setDrawBarOutline(false);

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    categoryAxis
            .setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;

}

From source file:org.tap4j.plugin.util.GraphHelper.java

/**
 * Creates the graph displayed on Method results page to compare execution
 * duration and status of a test method across builds.
 * /*w w w .  ja  va  2  s  .  c  o  m*/
 * At max, 9 older builds are displayed.
 * 
 * @param req
 *            request
 * @param dataset
 *            data set to be displayed on the graph
 * @param statusMap
 *            a map with build as key and the test methods execution status
 *            (result) as the value
 * @param methodUrl
 *            URL to get to the method from a build test result page
 * @return the chart
 */
public static JFreeChart createMethodChart(StaplerRequest req, final CategoryDataset dataset,
        final Map<NumberOnlyBuildLabel, String> statusMap, final String methodUrl) {

    final JFreeChart chart = ChartFactory.createBarChart(null, // chart
            // title
            null, // unused
            " Duration (secs)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            true // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setOutlinePaint(null);
    plot.setForegroundAlpha(0.8f);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);

    CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
    plot.setDomainAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.setCategoryMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer br = new BarRenderer() {

        private static final long serialVersionUID = 961671076462240008L;
        Map<String, Paint> statusPaintMap = new HashMap<String, Paint>();

        {
            statusPaintMap.put("PASS", ColorPalette.BLUE);
            statusPaintMap.put("SKIP", ColorPalette.YELLOW);
            statusPaintMap.put("FAIL", ColorPalette.RED);
        }

        /**
         * Returns the paint for an item. Overrides the default behavior
         * inherited from AbstractSeriesRenderer.
         * 
         * @param row
         *            the series.
         * @param column
         *            the category.
         * 
         * @return The item color.
         */
        public Paint getItemPaint(final int row, final int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            Paint paint = statusPaintMap.get(statusMap.get(label));
            // when the status of test method is unknown, use gray color
            return paint == null ? Color.gray : paint;
        }
    };

    br.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        public String generateToolTip(CategoryDataset dataset, int row, int column) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(column);
            if ("UNKNOWN".equals(statusMap.get(label))) {
                return "unknown";
            }
            // values are in seconds
            return dataset.getValue(row, column) + " secs";
        }
    });

    br.setBaseItemURLGenerator(new CategoryURLGenerator() {
        public String generateURL(CategoryDataset dataset, int series, int category) {
            NumberOnlyBuildLabel label = (NumberOnlyBuildLabel) dataset.getColumnKey(category);
            if ("UNKNOWN".equals(statusMap.get(label))) {
                // no link when method result doesn't exist
                return null;
            }
            // return label.build.getUpUrl() + label.build.getNumber() + "/" + PluginImpl.URL + "/" + methodUrl;
            return label.build.getUpUrl() + label.build.getNumber() + "/tap/" + methodUrl;
        }
    });

    br.setItemMargin(0.0);
    br.setMinimumBarLength(5);
    // set the base to be 1/100th of the maximum value displayed in the
    // graph
    br.setBase(br.findRangeBounds(dataset).getUpperBound() / 100);
    plot.setRenderer(br);

    // crop extra space around the graph
    plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));
    return chart;
}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
* Creates a bar chart.  The chart object returned by this method uses a     
* {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}     
* for the domain axis, a {@link NumberAxis} as the range axis, and a     
* {@link BarRenderer} as the renderer.    
*    //from  w  w w .  jav  a 2  s  . co m
* @param title  the chart title (<code>null</code> permitted).    
* @param categoryAxisLabel  the label for the category axis     
*                           (<code>null</code> permitted).    
* @param valueAxisLabel  the label for the value axis     
*                        (<code>null</code> permitted).    
* @param dataset  the dataset for the chart (<code>null</code> permitted).    
* @param orientation  the plot orientation (horizontal or vertical)     
*                     (<code>null</code> not permitted).    
* @param legend  a flag specifying whether or not a legend is required.    
* @param tooltips  configure chart to generate tool tips?    
* @param urls  configure chart to generate URLs?    
*    
* @return A bar chart.    
*/
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    BarRenderer renderer = new BarRenderer();
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        renderer.setBaseNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        renderer.setBaseNegativeItemLabelPosition(position2);
    }
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

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

private static JFreeChart createBarChart(final CategoryDatasetChartDefinition chartDefinition) {
    // TODO Make the following accessible from the chartDefinition
    String categoryAxisLabel = null;
    String valueAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------

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

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    BarRenderer renderer = null;
    // Determine the type of renderer to use
    if (chartDefinition.isStacked() || chartDefinition.isThreeD()) {
        if (chartDefinition.isStacked() && chartDefinition.isThreeD()) {
            renderer = new StackedBarRenderer3D();
        } else if (chartDefinition.isStacked()) {
            renderer = new StackedBarRenderer();
        } else {//from w  ww . ja  v a  2  s. c o  m
            renderer = new BarRenderer3D();
        }
    } else {
        renderer = new BarRenderer();
    }
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        renderer.setPositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        renderer.setNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        renderer.setPositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        renderer.setNegativeItemLabelPosition(position2);
    }
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    if (chartDefinition.getMaxBarWidth() != null) {
        renderer.setMaximumBarWidth(chartDefinition.getMaxBarWidth().doubleValue());
    }

    CategoryPlot plot = new CategoryPlot(chartDefinition, categoryAxis, valueAxis, renderer);
    JFreeChartEngine.updatePlot(plot, chartDefinition);

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

    return chart;

}

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

private static JFreeChart createBarLineChart(final BarLineChartDefinition chartDefinition) {
    // TODO Make the following accessible from the chartDefinition
    String categoryAxisLabel = null;
    String valueAxisLabel = null;
    String secondValueAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------
    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();
    PlotOrientation orientation = chartDefinition.getOrientation();

    // split BarLineChartDefinition in two Definitions
    CategoryDatasetChartDefinition barsDataset = new CategoryDatasetChartDefinition(
            chartDefinition.getSession(), chartDefinition.getChartAttributes());
    CategoryDatasetChartDefinition linesDataset = new CategoryDatasetChartDefinition(
            chartDefinition.getSession(), chartDefinition.getChartAttributes());

    /*/*from w w w  .ja v a  2s  . c  o  m*/
     * try{ barsDataset = (CategoryDatasetChartDefinition)chartDefinition.clone(); linesDataset =
     * (CategoryDatasetChartDefinition)chartDefinition.clone(); }catch(Exception e){}
     */

    // get column and row count of the data set
    int iColumnCount = chartDefinition.getColumnCount();
    int iRowCount = chartDefinition.getRowCount();

    if (iRowCount <= 0) {
        chartDefinition.setNoDataMessage(Messages.getInstance().getString("CHART.USER_NO_DATA_AVAILABLE")); //$NON-NLS-1$
    }

    /*
     * Copy data to the two new data sets
     */
    // Loop through columns
    for (int r = 0; r < iRowCount; r++) {

        // check if measure should be include in bar or line dataset
        String strMeasureName = (String) chartDefinition.getRowKey(r);
        boolean bIsBarColumn = JFreeChartEngine.isBarColumn(chartDefinition.getBarColumns(), strMeasureName);
        boolean bIsLineColumn = JFreeChartEngine.isLineColumn(chartDefinition.getLineColumns(), strMeasureName);

        // getting all values
        for (int c = 0; c < iColumnCount; c++) {
            Comparable compColumnName = chartDefinition.getColumnKey(c);
            Number nValue = chartDefinition.getValue(strMeasureName, compColumnName);
            if (bIsBarColumn) {
                barsDataset.addValue(nValue, strMeasureName, compColumnName);
            }
            if (bIsLineColumn) {
                linesDataset.addValue(nValue, strMeasureName, compColumnName);
            }
        }

    }

    if ((iRowCount > 0) && (barsDataset.getRowCount() <= 0) && (linesDataset.getRowCount() <= 0)) {
        chartDefinition.setNoDataMessage(Messages.getInstance().getString("CHART.USER_INCORRECT_DATA_FORMAT")); //$NON-NLS-1$
    }

    // Create Axis Objects
    CategoryAxis catAxis = new CategoryAxis(categoryAxisLabel);
    NumberAxis barsAxis = new NumberAxis(valueAxisLabel);
    NumberAxis linesAxis = new NumberAxis(secondValueAxisLabel);

    // set title and font for lines Axis
    linesDataset.setRangeTitle(chartDefinition.getLinesRangeTitle());
    linesDataset.setRangeTitleFont(chartDefinition.getLinesRangeTitleFont());
    if (chartDefinition.getLinesRangeTickFormat() != null) {
        linesAxis.setNumberFormatOverride(chartDefinition.getLinesRangeTickFormat());
    }

    // create renderer
    BarRenderer barRenderer = null;
    LineAndShapeRenderer lineRenderer = null;
    // Determine the type of renderer to use
    if (chartDefinition.isStacked() || chartDefinition.isThreeD()) {
        if (chartDefinition.isStacked() && chartDefinition.isThreeD()) {
            barRenderer = new StackedBarRenderer3D();
            lineRenderer = new LineRenderer3D();
        } else if (chartDefinition.isStacked()) {
            barRenderer = new StackedBarRenderer();
            lineRenderer = new LineAndShapeRenderer();
        } else {
            barRenderer = new BarRenderer3D();
            lineRenderer = new LineRenderer3D();
        }
    } else {
        barRenderer = new BarRenderer();
        lineRenderer = new LineAndShapeRenderer();
    }
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        barRenderer.setPositiveItemLabelPosition(position1);
        lineRenderer.setPositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        barRenderer.setNegativeItemLabelPosition(position2);
        lineRenderer.setNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        barRenderer.setPositiveItemLabelPosition(position1);
        lineRenderer.setPositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        barRenderer.setNegativeItemLabelPosition(position2);
        lineRenderer.setNegativeItemLabelPosition(position2);
    }
    if (tooltips) {
        barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
        lineRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        barRenderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
        lineRenderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    if (chartDefinition.getMaxBarWidth() != null) {
        barRenderer.setMaximumBarWidth(chartDefinition.getMaxBarWidth().doubleValue());
    }

    // setting some line attributes
    lineRenderer.setStroke(JFreeChartEngine.getLineStyleStroke(chartDefinition.getLineStyle(),
            chartDefinition.getLineWidth()));
    lineRenderer.setShapesVisible(chartDefinition.isMarkersVisible());
    lineRenderer.setBaseShapesFilled(chartDefinition.isMarkersVisible());

    /*
     * Create plot and make necessary adjustments for overlaid chart
     */
    // create the plot with bar chart
    CategoryPlot plot = new CategoryPlot(barsDataset, catAxis, barsAxis, barRenderer);
    // add line renderer
    plot.setRenderer(1, lineRenderer);
    // add lines dataset, renderer and axis to plot
    plot.setDataset(1, linesDataset);
    plot.setRangeAxis(1, linesAxis);
    // map lines to second axis
    plot.mapDatasetToRangeAxis(1, 1);
    // set rendering order
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    // set location of second axis
    plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

    // standard settings for plots
    JFreeChartEngine.updatePlot(plot, barsDataset);
    // additional settings for second axis
    ValueAxis secondValueAxis = plot.getRangeAxis(1);

    if (secondValueAxis != null) {
        if (chartDefinition.getLinesRangeTitle() != null) {
            secondValueAxis.setLabel(chartDefinition.getLinesRangeTitle());
        }
        if (chartDefinition.getLinesRangeTitleFont() != null) {
            secondValueAxis.setLabelFont(chartDefinition.getLinesRangeTitleFont());
        }
        if (chartDefinition.getLinesRangeTickFont() != null) {
            secondValueAxis.setTickLabelFont(chartDefinition.getLinesRangeTickFont());
        }
        if (chartDefinition.getLinesRangeMinimum() != ValueAxis.DEFAULT_LOWER_BOUND) {
            secondValueAxis.setLowerBound(chartDefinition.getLinesRangeMinimum());
        }
        if (chartDefinition.getLinesRangeMaximum() != ValueAxis.DEFAULT_UPPER_BOUND) {
            secondValueAxis.setUpperBound(chartDefinition.getLinesRangeMaximum());
        }
    }

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

    return chart;
}