Example usage for org.jfree.chart.axis CategoryAxis setLabelFont

List of usage examples for org.jfree.chart.axis CategoryAxis setLabelFont

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryAxis setLabelFont.

Prototype

public void setLabelFont(Font font) 

Source Link

Document

Sets the font for the axis label and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:com.manydesigns.portofino.chart.ChartStackedBarGenerator.java

public JFreeChart generate(ChartDefinition chartDefinition, Persistence persistence, Locale locale) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    java.util.List<Object[]> result;
    String query = chartDefinition.getQuery();
    logger.info(query);//from www .j  a  v  a  2 s  .  co m
    Session session = persistence.getSession(chartDefinition.getDatabase());
    result = QueryUtils.runSql(session, query);
    for (Object[] current : result) {
        ComparableWrapper x = new ComparableWrapper((Comparable) current[0]);
        ComparableWrapper y = new ComparableWrapper((Comparable) current[1]);
        if (current.length > 3) {
            x.setLabel(current[3].toString());
        }
        if (current.length > 4) {
            y.setLabel(current[4].toString());
        }
        dataset.setValue((Number) current[2], x, y);
    }

    PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL;
    if (chartDefinition.getActualOrientation() == ChartDefinition.Orientation.VERTICAL) {
        plotOrientation = PlotOrientation.VERTICAL;
    }

    JFreeChart chart = createChart(chartDefinition, dataset, plotOrientation);

    chart.setAntiAlias(antiAlias);

    // impostiamo il bordo invisibile
    // eventualmente e' il css a fornirne uno
    chart.setBorderVisible(borderVisible);

    // impostiamo il titolo
    TextTitle title = chart.getTitle();
    title.setFont(titleFont);
    title.setMargin(10.0, 0.0, 0.0, 0.0);

    // ottieni il Plot
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    CategoryItemRenderer renderer = plot.getRenderer();
    String urlExpression = chartDefinition.getUrlExpression();
    if (!StringUtils.isBlank(urlExpression)) {
        CategoryURLGenerator urlGenerator = new ChartBarUrlGenerator(chartDefinition.getUrlExpression());
        renderer.setBaseItemURLGenerator(urlGenerator);
    } else {
        renderer.setBaseItemURLGenerator(null);
    }
    renderer.setBaseOutlinePaint(Color.BLACK);

    // ///////////////
    if (renderer instanceof BarRenderer) {
        BarRenderer barRenderer = (BarRenderer) renderer;

        barRenderer.setDrawBarOutline(true);
        barRenderer.setShadowVisible(false);
        barRenderer.setBarPainter(new StandardBarPainter());

        // hongliangpan add
        // ?
        barRenderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator());
        // bar???
        barRenderer.setMinimumBarLength(0.02);
        // 
        barRenderer.setMaximumBarWidth(0.06);
    }
    if (renderer instanceof StackedBarRenderer3D || renderer instanceof StackedBarRenderer) {
        BarRenderer barRenderer = (BarRenderer) renderer;
        barRenderer.setDrawBarOutline(true);
        barRenderer.setShadowVisible(false);
        barRenderer.setBarPainter(new StandardBarPainter());

        // hongliangpan add
        // ? setSeriesItemLabelGenerator
        barRenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
        // bar???
        barRenderer.setMinimumBarLength(0.02);
        // 
        barRenderer.setMaximumBarWidth(0.06);
        // ?????
        ItemLabelPosition itemLabelPositionFallback = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BASELINE_LEFT, TextAnchor.HALF_ASCENT_LEFT, -1.57D);
        // ??labelposition
        barRenderer.setPositiveItemLabelPositionFallback(itemLabelPositionFallback);
        barRenderer.setNegativeItemLabelPositionFallback(itemLabelPositionFallback);

        barRenderer.setItemLabelsVisible(true);
        barRenderer.setItemMargin(10);
    }

    // ///////////////

    // il plot ha sfondo e bordo trasparente
    // (quindi si vede il colore del chart)
    plot.setBackgroundPaint(transparentColor);
    plot.setOutlinePaint(transparentColor);

    // Modifico il toolTip
    // plot.setToolTipGenerator(new StandardPieToolTipGenerator("{0} = {1} ({2})"));

    // imposta il messaggio se non ci sono dati
    plot.setNoDataMessage(ElementsThreadLocals.getText("no.data.available"));
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.GRAY);
    plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0));

    // Category axis
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setAxisLinePaint(Color.BLACK);
    categoryAxis.setLabelFont(axisFont);
    categoryAxis.setAxisLineVisible(true);

    // impostiamo la rotazione dell'etichetta
    if (plot.getOrientation() == PlotOrientation.VERTICAL) {
        CategoryLabelPosition pos = new CategoryLabelPosition(RectangleAnchor.TOP_LEFT,
                TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT, -Math.PI / 4.0,
                CategoryLabelWidthType.CATEGORY, 100);
        CategoryLabelPositions positions = new CategoryLabelPositions(pos, pos, pos, pos);
        categoryAxis.setCategoryLabelPositions(positions);
        categoryAxis.setMaximumCategoryLabelWidthRatio(6.0f);
        height = 333;
    } else {
        categoryAxis.setMaximumCategoryLabelWidthRatio(0.4f);

        // recuperiamo 8 pixel a sinistra
        plot.setInsets(new RectangleInsets(4.0, 0.0, 4.0, 8.0));

        height = 74;

        // contiamo gli elementi nel dataset
        height += 23 * dataset.getColumnCount();

        height += 57;
    }

    Axis rangeAxis = plot.getRangeAxis();
    rangeAxis.setAxisLinePaint(Color.BLACK);
    rangeAxis.setLabelFont(axisFont);

    DrawingSupplier supplier = new DesaturatedDrawingSupplier(plot.getDrawingSupplier());
    plot.setDrawingSupplier(supplier);

    // impostiamo il titolo della legenda
    String legendString = chartDefinition.getLegend();
    Title subtitle = new TextTitle(legendString, legendFont, Color.BLACK, RectangleEdge.BOTTOM,
            HorizontalAlignment.CENTER, VerticalAlignment.CENTER, new RectangleInsets(0, 0, 0, 0));
    subtitle.setMargin(0, 0, 5, 0);
    chart.addSubtitle(subtitle);

    // impostiamo la legenda
    LegendTitle legend = chart.getLegend();
    legend.setBorder(0, 0, 0, 0);
    legend.setItemFont(legendItemFont);
    int legendMargin = 10;
    legend.setMargin(0.0, legendMargin, legendMargin, legendMargin);
    legend.setBackgroundPaint(transparentColor);

    // impostiamo un gradiente orizzontale
    Paint chartBgPaint = new GradientPaint(0, 0, new Color(255, 253, 240), 0, height, Color.WHITE);
    chart.setBackgroundPaint(chartBgPaint);
    return chart;
}

From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java

private JFreeChart initializeChart() {

    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("overview.traceoverview.title"), null, null, createDataset(),
            PlotOrientation.HORIZONTAL, false, true, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis valueRangeAxis = plot.getDomainAxis();
    valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    valueRangeAxis.setMaximumCategoryLabelLines(2);
    valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentile"));
    rangeAxis.setRange(0.0, 100.0);/* w w  w .j a  v  a2  s. c o m*/
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);
    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String traceInfo = "";
            switch (arg2) {
            case TRACE_AVERAGE:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.avg");
                break;
            case TRACE_ENERGY:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.engy");
                break;
            case TRACE_OVERHEAD:
                traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.ovrhd");
                break;
            default:
                break;
            }

            return traceInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;

}

From source file:org.locationtech.udig.processingtoolbox.tools.BoxPlotDialog.java

private void updateChart(SimpleFeatureCollection features, String[] fields) {
    // Setup Box plot
    int fontStyle = java.awt.Font.BOLD;
    FontData fontData = getShell().getDisplay().getSystemFont().getFontData()[0];

    CategoryAxis xPlotAxis = new CategoryAxis(EMPTY); // Type
    xPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    xPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 12));

    NumberAxis yPlotAxis = new NumberAxis("Value"); // Value //$NON-NLS-1$
    yPlotAxis.setLabelFont(new Font(fontData.getName(), fontStyle, 12));
    yPlotAxis.setTickLabelFont(new Font(fontData.getName(), fontStyle, 10));
    yPlotAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setMedianVisible(true);/*from  ww w  .j  a va 2 s  . c o  m*/
    renderer.setMeanVisible(false);
    renderer.setFillBox(true);
    renderer.setSeriesFillPaint(0, java.awt.Color.CYAN);
    renderer.setBaseFillPaint(java.awt.Color.CYAN);
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    // Set the scatter data, renderer, and axis into plot
    CategoryDataset dataset = getDataset(features, fields);
    CategoryPlot plot = new CategoryPlot(dataset, xPlotAxis, yPlotAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setBackgroundPaint(java.awt.Color.WHITE);
    plot.setRangePannable(false);

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setForegroundAlpha(0.85f);

    // Map the scatter to the first Domain and first Range
    plot.mapDatasetToDomainAxis(0, 0);
    plot.mapDatasetToRangeAxis(0, 0);

    // 3. Setup Selection
    /*****************************************************************************************
     * CategoryAxis xSelectionAxis = new CategoryAxis(EMPTY);
     * xSelectionAxis.setTickMarksVisible(false); xSelectionAxis.setTickLabelsVisible(false);
     * 
     * NumberAxis ySelectionAxis = new NumberAxis(EMPTY);
     * ySelectionAxis.setTickMarksVisible(false); ySelectionAxis.setTickLabelsVisible(false);
     * 
     * BoxAndWhiskerRenderer selectionRenderer = new BoxAndWhiskerRenderer();
     * selectionRenderer.setSeriesShape(0, new Ellipse2D.Double(0, 0, 6, 6));
     * selectionRenderer.setSeriesPaint(0, java.awt.Color.RED); // dot
     * 
     * plot.setDataset(2, new DefaultBoxAndWhiskerCategoryDataset()); plot.setRenderer(2,
     * selectionRenderer); plot.setDomainAxis(2, xSelectionAxis); plot.setRangeAxis(2,
     * ySelectionAxis);
     * 
     * // Map the scatter to the second Domain and second Range plot.mapDatasetToDomainAxis(2,
     * 0); plot.mapDatasetToRangeAxis(2, 0);
     *****************************************************************************************/

    // 5. Finally, Create the chart with the plot and a legend
    java.awt.Font titleFont = new Font(fontData.getName(), fontStyle, 20);
    JFreeChart chart = new JFreeChart(EMPTY, titleFont, plot, false);
    chart.setBackgroundPaint(java.awt.Color.WHITE);
    chart.setBorderVisible(false);

    chartComposite.setChart(chart);
    chartComposite.forceRedraw();
}

From source file:charts.Chart.java

public static void BarChart(DefaultCategoryDataset dataset, String title, String x_axis_label,
        String y_axis_label, boolean showlegend) {
    JFrame chartwindow = new JFrame(title);
    JFreeChart jfreechart = ChartFactory.createStackedBarChart(title, x_axis_label, y_axis_label, dataset,
            PlotOrientation.HORIZONTAL, showlegend, true, false);

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.black);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setLabelFont(new Font("SansSerif", Font.BOLD, 12));

    CategoryAxis domainaxis = categoryplot.getDomainAxis();
    domainaxis.setLabelFont(new Font("SansSerif", Font.BOLD, 12));

    JPanel jpanel = new ChartPanel(jfreechart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    chartwindow.setContentPane(jpanel);/*from  w  w  w . ja v a  2  s. c o m*/
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
}

From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java

public JFreeChart initializeChart() {
    JFreeChart chart = ChartFactory.createBarChart(
            ResourceBundleHelper.getMessageString("overview.sessionoverview.title"), null, null,
            createDataset(), PlotOrientation.HORIZONTAL, false, false, false);
    chart.setBackgroundPaint(this.getBackground());
    chart.getTitle().setFont(AROUIManager.HEADER_FONT);

    this.plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(1.0f);
    domainAxis.setMaximumCategoryLabelLines(2);
    domainAxis.setLabelFont(AROUIManager.LABEL_FONT);
    domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentage"));
    rangeAxis.setRange(0.0, 100.0);/*from   w w w . j ava 2 s  .c om*/
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabelFont(AROUIManager.LABEL_FONT);
    rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT);

    BarRenderer renderer = new StackedBarRenderer();
    renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR);
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBaseItemLabelGenerator(new PercentLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelPaint(Color.black);

    // Make second bar in stack invisible
    renderer.setSeriesItemLabelsVisible(1, false);
    renderer.setSeriesPaint(1, new Color(0, 0, 0, 0));

    ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    renderer.setBasePositiveItemLabelPosition(insideItemlabelposition);

    ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
            TextAnchor.CENTER_LEFT);
    renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition);

    renderer.setBarPainter(new StandardBarPainter());
    renderer.setShadowVisible(false);
    renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT);

    renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
        @Override
        public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) {
            String sessionInfo = "";
            switch (arg2) {
            case SESSION_TERMINATION:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTermination");
                break;
            case SESSION_TIGHT_CONN:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTightConn");
                break;
            case SESSION_BURST:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionBurst");
                break;
            case SESSION_LONG_BURST:
                sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionLongBurst");
                break;
            default:
                break;
            }

            return sessionInfo;
        }
    });

    plot.setRenderer(renderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(2);

    return chart;
}

From source file:org.sakaiproject.evaluation.tool.reporting.EvalLikertChartBuilder.java

@SuppressWarnings("deprecation")
public JFreeChart makeLikertChart() {

    DefaultCategoryDataset likertDataset = new DefaultCategoryDataset();

    for (int i = 0; i < responses.length; i++) {
        likertDataset.addValue(values[i], "Responses", responses[i]);
    }//from w  ww .j  ava 2s  . co m

    JFreeChart chart = ChartFactory.createBarChart(null, // "Likert Chart", // Chart title
            null, // "Choices", // domain axis label
            null, // "# of Responses", // range axis label
            likertDataset, PlotOrientation.HORIZONTAL, false, // show legend
            false, // show tooltips
            false // show URLs
    );

    // Set the background colours
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // Configure the bar colors and display
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(244, 252, 212));
    renderer.setDrawBarOutline(true);
    renderer.setOutlinePaint(new Color(34, 35, 237));
    renderer.setOutlineStroke(new BasicStroke(0.5f));
    renderer.setBaseItemLabelsVisible(true);
    if (showPercentages) {
        renderer.setBaseItemLabelGenerator(new LikertPercentageItemLabelGenerator(this.responseCount));
    } else {
        renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    }
    // Turn off the Top Value Axis
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setVisible(false);
    rangeAxis.setUpperMargin(0.35);
    rangeAxis.resizeRange(1.1f);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(0.4f);
    domainAxis.setMaximumCategoryLabelLines(2);

    // Set the font for the labels
    Font labelFont = new Font("Serif", Font.PLAIN, 6);

    CategoryItemRenderer itemRenderer = plot.getRenderer();
    itemRenderer.setBaseItemLabelFont(labelFont);

    plot.setOutlinePaint(null);

    domainAxis.setLabelFont(labelFont);
    domainAxis.setTickLabelFont(labelFont);
    rangeAxis.setLabelFont(labelFont);
    rangeAxis.setTickLabelFont(labelFont);

    return chart;
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.SimpleBar.java

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1");

    PlotOrientation plotOrientation = PlotOrientation.VERTICAL;
    if (horizontalView) {
        plotOrientation = PlotOrientation.HORIZONTAL;
    }/*from w w w  . j  ava  2s. c  om*/

    JFreeChart chart = ChartFactory.createBarChart(name, // chart title
            categoryLabel, // domain axis label
            valueLabel, // range axis label
            dataset, // data
            plotOrientation, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

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

    // set the background color for the chart...
    chart.setBackgroundPaint(color);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    NumberFormat nf = NumberFormat.getNumberInstance(locale);

    // set the range axis to display integers only...
    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.setUpperMargin(0.10);
    rangeAxis.setNumberFormatOverride(nf);

    if (firstAxisLB != null && firstAxisUB != null) {
        rangeAxis.setLowerBound(firstAxisLB);
        rangeAxis.setUpperBound(firstAxisUB);
    }

    if (rangeIntegerValues == true) {
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    } else
        rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());

    if (rangeAxisLocation != null) {
        if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) {
            plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
        } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) {
            plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
        } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) {
            plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT);
        } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) {
            plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
        }
    }

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // add
    CategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("{0}");
    renderer.setLegendItemLabelGenerator(generator);

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

    if (showValueLabels) {
        renderer.setBaseItemLabelsVisible(true);
        renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
        renderer.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        renderer.setBaseItemLabelPaint(styleValueLabels.getColor());

        //         if(valueLabelsPosition.equalsIgnoreCase("inside")){
        //         renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
        //         ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
        //         renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
        //         ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT));
        //         } else {
        //         renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
        //         ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT));
        //         renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(
        //         ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT));
        //         }

    }

    // PROVA LEGENDA      
    if (legend == true) {

        drawLegend(chart);

        /*BlockContainer wrapper = new BlockContainer(new BorderArrangement());
        wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0));
                
        LabelBlock titleBlock = new LabelBlock("Legend Items:",
              new Font("SansSerif", Font.BOLD, 12));
        title.setPadding(5, 5, 5, 5);
        wrapper.add(titleBlock, RectangleEdge.TOP);
                
        LegendTitle legend = new LegendTitle(chart.getPlot());
        BlockContainer items = legend.getItemContainer();
        items.setPadding(2, 10, 5, 2);
        wrapper.add(items);
        legend.setWrapper(wrapper);
                
        if(legendPosition.equalsIgnoreCase("bottom")) legend.setPosition(RectangleEdge.BOTTOM);
        else if(legendPosition.equalsIgnoreCase("left")) legend.setPosition(RectangleEdge.LEFT);
        else if(legendPosition.equalsIgnoreCase("right")) legend.setPosition(RectangleEdge.RIGHT);
        else if(legendPosition.equalsIgnoreCase("top")) legend.setPosition(RectangleEdge.TOP);
        else legend.setPosition(RectangleEdge.BOTTOM);
                
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        chart.addSubtitle(legend);*/
    }

    int seriesN = dataset.getRowCount();

    // the order color vedctor overrides the color map!!

    if (orderColorVector != null && orderColorVector.size() > 0) {
        logger.debug("color serie by SERIES_ORDER_COLORS template specification");
        for (int i = 0; i < seriesN; i++) {
            if (orderColorVector.get(i) != null) {
                Color color = orderColorVector.get(i);
                renderer.setSeriesPaint(i, color);
            }
        }
    } else if (colorMap != null) {
        logger.debug("color serie by SERIES_COLORS template specification");
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getRowKey(i);
            String labelName = "";
            int index = -1;
            if (seriesCaptions != null && seriesCaptions.size() > 0) {
                labelName = serieName;
                serieName = (String) seriesCaptions.get(serieName);
                index = dataset.getRowIndex(labelName);
            } else
                index = dataset.getRowIndex(serieName);

            Color color = (Color) colorMap.get(serieName);
            if (color != null) {
                //renderer.setSeriesPaint(i, color);
                renderer.setSeriesPaint(index, color);
                renderer.setSeriesItemLabelFont(i,
                        new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
                renderer.setSeriesItemLabelPaint(i, defaultLabelsStyle.getColor());
            }
        }
    }

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.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.setUpperMargin(0.10);
    logger.debug("OUT");
    return chart;

}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.OverlaidStackedBarLine.java

public JFreeChart createChart(DatasetMap datasets) {

    // create the first renderer...

    CategoryPlot plot = new CategoryPlot();
    NumberFormat nf = NumberFormat.getNumberInstance(locale);

    NumberAxis rangeAxis = new NumberAxis(getValueLabel());
    rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setLabelPaint(styleXaxesLabels.getColor());
    rangeAxis//w w w .  j  av  a  2s .  c  o  m
            .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
    rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor());
    rangeAxis.setNumberFormatOverride(nf);
    plot.setRangeAxis(rangeAxis);
    if (rangeIntegerValues == true) {
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    CategoryAxis domainAxis = new CategoryAxis(getCategoryLabel());
    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());
    plot.setDomainAxis(domainAxis);

    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setRangeGridlinesVisible(true);
    plot.setDomainGridlinesVisible(true);

    DefaultCategoryDataset datasetBar = (DefaultCategoryDataset) datasets.getDatasets().get("stackedbar");

    //I create one bar renderer and one line

    MyStandardCategoryItemLabelGenerator generator = null;
    if (additionalLabels) {
        generator = new MyStandardCategoryItemLabelGenerator(catSerLabels, "{1}", NumberFormat.getInstance());
    }

    if (useBars) {
        CategoryItemRenderer barRenderer = new StackedBarRenderer();

        if (maxBarWidth != null) {
            ((BarRenderer) barRenderer).setMaximumBarWidth(maxBarWidth.doubleValue());
        }

        if (additionalLabels) {
            barRenderer.setBaseItemLabelGenerator(generator);
            double orient = (-Math.PI / 2.0);
            if (styleValueLabels.getOrientation().equalsIgnoreCase("horizontal")) {
                orient = 0.0;
            }
            barRenderer.setBaseItemLabelFont(
                    new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
            barRenderer.setBaseItemLabelPaint(styleValueLabels.getColor());
            barRenderer.setBaseItemLabelsVisible(true);
            barRenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));
            barRenderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
                    TextAnchor.CENTER, TextAnchor.CENTER, orient));

        }

        if (colorMap != null) {
            for (Iterator iterator = datasetBar.getRowKeys().iterator(); iterator.hasNext();) {
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;
                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetBar.getRowIndex(labelName);
                } else
                    index = datasetBar.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    barRenderer.setSeriesPaint(index, color);
                }
            }
        }
        // add tooltip if enabled
        if (enableToolTips) {
            MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips,
                    seriesTooltip, categoriesTooltip, seriesCaptions);
            barRenderer.setToolTipGenerator(generatorToolTip);
        }

        //defines url for drill
        boolean document_composition = false;
        if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
            document_composition = true;

        logger.debug("Calling Url Generation");

        MyCategoryUrlGenerator mycatUrl = null;
        if (super.rootUrl != null) {
            logger.debug("Set MycatUrl");
            mycatUrl = new MyCategoryUrlGenerator(super.rootUrl);

            mycatUrl.setDocument_composition(document_composition);
            mycatUrl.setCategoryUrlLabel(super.categoryUrlName);
            mycatUrl.setSerieUrlLabel(super.serieUrlname);
            mycatUrl.setDrillDocTitle(drillDocTitle);
            mycatUrl.setTarget(target);
        }
        if (mycatUrl != null) {
            barRenderer.setItemURLGenerator(mycatUrl);
        }

        plot.setDataset(1, datasetBar);
        plot.setRenderer(1, barRenderer);

    }

    if (useLines) {

        LineAndShapeRenderer lineRenderer = new LineAndShapeRenderer();
        //lineRenderer.setShapesFilled(false);
        lineRenderer.setShapesFilled(true);
        if (additionalLabels) {
            lineRenderer.setBaseItemLabelGenerator(generator);
            lineRenderer.setBaseItemLabelFont(
                    new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize()));
            lineRenderer.setBaseItemLabelPaint(defaultLabelsStyle.getColor());
            lineRenderer.setBaseItemLabelsVisible(true);
        }

        DefaultCategoryDataset datasetLine = (DefaultCategoryDataset) datasets.getDatasets().get("line");

        if (enableToolTips) {
            MyCategoryToolTipGenerator generatorToolTip = new MyCategoryToolTipGenerator(freeToolTips,
                    seriesTooltip, categoriesTooltip, seriesCaptions);
            lineRenderer.setToolTipGenerator(generatorToolTip);
        }

        if (colorMap != null) {
            for (Iterator iterator = datasetLine.getRowKeys().iterator(); iterator.hasNext();) {
                String serName = (String) iterator.next();
                String labelName = "";
                int index = -1;

                if (seriesCaptions != null && seriesCaptions.size() > 0) {
                    labelName = serName;
                    serName = (String) seriesCaptions.get(serName);
                    index = datasetLine.getRowIndex(labelName);
                } else
                    index = datasetLine.getRowIndex(serName);

                Color color = (Color) colorMap.get(serName);
                if (color != null) {
                    lineRenderer.setSeriesPaint(index, color);
                }
            }
        }
        plot.setDataset(0, datasetLine);
        plot.setRenderer(0, lineRenderer);
    }

    if (secondAxis) {
        NumberAxis na = new NumberAxis(secondAxisLabel);
        na.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
        na.setLabelPaint(styleXaxesLabels.getColor());
        na.setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize()));
        na.setTickLabelPaint(styleXaxesLabels.getColor());
        na.setUpperMargin(0.10);
        if (rangeIntegerValues == true) {
            na.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        }
        na.setNumberFormatOverride(nf);
        plot.setRangeAxis(1, na);
        plot.mapDatasetToRangeAxis(0, 1);
    }

    //plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    JFreeChart chart = new JFreeChart(plot);
    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    chart.setBackgroundPaint(Color.white);

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

}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.LinkableBar.java

/**
 * Inherited by IChart./*  w ww .  j a va  2 s.co  m*/
 * 
 * @param chartTitle the chart title
 * @param dataset the dataset
 * 
 * @return the j free chart
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1");

    CategoryAxis categoryAxis = new CategoryAxis(categoryLabel);
    ValueAxis valueAxis = new NumberAxis(valueLabel);
    if (rangeIntegerValues == true) {
        valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    org.jfree.chart.renderer.category.BarRenderer renderer = new org.jfree.chart.renderer.category.BarRenderer();

    renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    //      renderer.setBaseItemLabelFont(new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
    //      renderer.setBaseItemLabelPaint(styleValueLabels.getColor());

    if (showValueLabels) {
        renderer.setBaseItemLabelsVisible(true);
        renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator());
        renderer.setBaseItemLabelFont(
                new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize()));
        renderer.setBaseItemLabelPaint(styleValueLabels.getColor());
    }

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

    boolean document_composition = false;
    if (mode.equalsIgnoreCase(SpagoBIConstants.DOCUMENT_COMPOSITION))
        document_composition = true;

    MyCategoryUrlGenerator mycatUrl = new MyCategoryUrlGenerator(rootUrl);
    mycatUrl.setDocument_composition(document_composition);
    mycatUrl.setCategoryUrlLabel(categoryUrlName);
    mycatUrl.setSerieUrlLabel(serieUrlname);
    mycatUrl.setDrillDocTitle(drillDocTitle);
    mycatUrl.setTarget(target);

    renderer.setItemURLGenerator(mycatUrl);

    /*      }
    else{
       renderer.setItemURLGenerator(new StandardCategoryURLGenerator(rootUrl));
    }*/

    CategoryPlot plot = new CategoryPlot((CategoryDataset) dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    if (horizontalView) {
        plot.setOrientation(PlotOrientation.HORIZONTAL);
    }

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

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

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(color);

    // get a reference to the plot for further customisation...
    //CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    NumberFormat nf = NumberFormat.getNumberInstance(locale);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    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.setNumberFormatOverride(nf);

    if (rangeAxisLocation != null) {
        if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) {
            plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT);
        } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) {
            plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT);
        } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) {
            plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT);
        } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) {
            plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT);
        }
    }

    // disable bar outlines...
    //BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    /*   if(currentSeries!=null && colorMap!=null){
       //for each serie selected
       int j=0;   
       for (Iterator iterator = currentSeries.iterator(); iterator.hasNext();) {
    String s = (String) iterator.next();
    Integer position=(Integer)seriesNumber.get(s);
    // check if for that position a value is defined
    if(colorMap.get("color"+position.toString())!=null){
       Color col= (Color)colorMap.get("color"+position);
       renderer.setSeriesPaint(j, col);
    }
    j++;
       }  // close for on series
    } // close case series selcted and color defined
    else{
       if(colorMap!=null){ // if series not selected check color each one
            
    for (Iterator iterator = colorMap.keySet().iterator(); iterator.hasNext();) {
       String key = (String) iterator.next();
       Color col= (Color)colorMap.get(key);
       String keyNum=key.substring(5, key.length());
       int num=Integer.valueOf(keyNum).intValue();
       num=num-1;
       renderer.setSeriesPaint(num, col);
    }
       }
    }*/

    int seriesN = dataset.getRowCount();

    if (orderColorVector != null && orderColorVector.size() > 0) {
        logger.debug("color serie by SERIES_ORDER_COLORS template specification");
        for (int i = 0; i < seriesN; i++) {
            if (orderColorVector.get(i) != null) {
                Color color = orderColorVector.get(i);
                renderer.setSeriesPaint(i, color);
            }
        }
    } else if (colorMap != null) {
        for (int i = 0; i < seriesN; i++) {
            String serieName = (String) dataset.getRowKey(i);
            Color color = (Color) colorMap.get(serieName);
            if (color != null) {
                renderer.setSeriesPaint(i, color);
            }
        }
    }

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.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());

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

    logger.debug("OUT");
    return chart;

}

From source file:com.rapidminer.gui.plotter.charts.ParetoChartPlotter.java

private JFreeChart createChart() {
    if (data.getItemCount() > 0) {
        // get cumulative percentages
        KeyedValues cumulative = DataUtilities.getCumulativePercentages(data);

        CategoryDataset categoryDataset = DatasetUtilities.createCategoryDataset(
                "Count for " + this.dataTable.getColumnName(this.countColumn) + " = " + countValue, data);

        // create the chart...
        final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
                this.dataTable.getColumnName(this.groupByColumn), // domain axis label
                "Count", // range axis label
                categoryDataset, // data
                PlotOrientation.VERTICAL, true, // include legend
                true, false);/*from  w  w  w  .j a  v  a2  s  . co  m*/

        // set the background color for the chart...
        chart.setBackgroundPaint(Color.WHITE);

        // get a reference to the plot for further customization...
        CategoryPlot plot = chart.getCategoryPlot();

        CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setLowerMargin(0.02);
        domainAxis.setUpperMargin(0.02);
        domainAxis.setLabelFont(LABEL_FONT_BOLD);
        domainAxis.setTickLabelFont(LABEL_FONT);

        // set the range axis to display integers only...
        NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits(Locale.US));
        rangeAxis.setLabelFont(LABEL_FONT_BOLD);
        rangeAxis.setTickLabelFont(LABEL_FONT);

        // second data set (cumulative percentages)
        CategoryDataset dataset2 = DatasetUtilities.createCategoryDataset("Cumulative (Percent)", cumulative);

        LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
        renderer2.setSeriesPaint(0, SwingTools.VERY_DARK_BLUE.darker());

        NumberAxis axis2 = new NumberAxis("Percent of " + countValue);
        axis2.setNumberFormatOverride(NumberFormat.getPercentInstance());
        axis2.setLabelFont(LABEL_FONT_BOLD);
        axis2.setTickLabelFont(LABEL_FONT);

        plot.setRangeAxis(1, axis2);
        plot.setDataset(1, dataset2);
        plot.setRenderer(1, renderer2);
        plot.mapDatasetToRangeAxis(1, 1);

        axis2.setTickUnit(new NumberTickUnit(0.1));

        // show grid lines
        plot.setRangeGridlinesVisible(true);

        // bring cumulative line to front
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        if (isLabelRotating()) {
            domainAxis.setTickLabelsVisible(true);
            domainAxis.setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
        }

        return chart;
    } else {
        return null;
    }
}