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

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

Introduction

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

Prototype

public void setLabelAngle(double angle) 

Source Link

Document

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

Usage

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createAreaChart("Area Chart", "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "An area chart demonstration.  We use this subtitle as an example of what happens when you get a really long title or subtitle.");
    texttitle.setFont(new Font("SansSerif", 0, 12));
    texttitle.setPosition(RectangleEdge.TOP);
    texttitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.050000000000000003D, 0.050000000000000003D,
            0.050000000000000003D, 0.050000000000000003D));
    texttitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    jfreechart.addSubtitle(texttitle);//from   w  w w  . j  a v  a 2 s  . c  o m
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setForegroundAlpha(0.5F);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    categoryaxis.setLowerMargin(0.0D);
    categoryaxis.setUpperMargin(0.0D);
    categoryaxis.addCategoryLabelToolTip("Type 1", "The first type.");
    categoryaxis.addCategoryLabelToolTip("Type 2", "The second type.");
    categoryaxis.addCategoryLabelToolTip("Type 3", "The third type.");
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLabelAngle(0.0D);
    return jfreechart;
}

From source file:org.gwaspi.reports.GenericReportGenerator.java

private static void appendToCombinedRangeManhattanPlot(CombinedRangeXYPlot combinedPlot, String chromosome,
        XYSeriesCollection currChrSC, boolean showlables, double threshold, Color background,
        Color backgroundAlternative, Color main) {

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true);

    // Set dot shape of the currently appended Series
    renderer.setSeriesPaint(currChrSC.getSeriesCount() - 1, main);
    renderer.setSeriesVisibleInLegend(currChrSC.getSeriesCount() - 1, showlables);
    renderer.setSeriesShape(currChrSC.getSeriesCount() - 1, new Rectangle2D.Double(-1.0, -1.0, 2.0, 2.0));

    // Set range axis
    if (combinedPlot.getSubplots().isEmpty()) {
        LogAxis rangeAxis = new LogAxis("P value");
        rangeAxis.setBase(10);//from  www  .j  a  v  a2  s .  com
        rangeAxis.setInverted(true);
        rangeAxis.setNumberFormatOverride(FORMAT_P_VALUE);

        rangeAxis.setTickMarkOutsideLength(2.0f);
        rangeAxis.setMinorTickCount(2);
        rangeAxis.setMinorTickMarksVisible(true);
        rangeAxis.setAxisLineVisible(true);
        rangeAxis.setUpperMargin(0);

        TickUnitSource units = NumberAxis.createIntegerTickUnits();
        rangeAxis.setStandardTickUnits(units);

        combinedPlot.setRangeAxis(0, rangeAxis);
    }

    // Build subchart
    JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", currChrSC,
            PlotOrientation.VERTICAL, false, false, false);

    // Get subplot from subchart
    XYPlot subplot = (XYPlot) subchart.getPlot();
    subplot.setRenderer(renderer);
    subplot.setBackgroundPaint(null);

    // CHART BACKGROUD COLOR
    if (combinedPlot.getSubplots().size() % 2 == 0) {
        subplot.setBackgroundPaint(background); // Hue, saturation, brightness
    } else {
        subplot.setBackgroundPaint(backgroundAlternative); // Hue, saturation, brightness
    }

    // Add significance Threshold to subplot
    final Marker thresholdLine = new ValueMarker(threshold);
    thresholdLine.setPaint(Color.red);
    // Add legend to hetzyThreshold
    if (showlables) {
        thresholdLine.setLabel("P = " + FORMAT_P_VALUE.format(threshold));
    }
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    subplot.addRangeMarker(thresholdLine);

    // Chromosome Axis Labels
    NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis();
    chrAxis.setLabelAngle(1.0);
    chrAxis.setAutoRangeIncludesZero(false);
    chrAxis.setAxisLineVisible(true);

    chrAxis.setTickLabelsVisible(false);
    chrAxis.setTickMarksVisible(false);
    //      chrAxis.setNumberFormatOverride(Report_Analysis.FORMAT_SCIENTIFIC);
    //      TickUnitSource units = NumberAxis.createIntegerTickUnits();
    //      chrAxis.setStandardTickUnits(units);

    //combinedPlot.setGap(0);
    combinedPlot.add(subplot, 1);
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    CategoryStepRenderer categorysteprenderer = new CategoryStepRenderer(true);
    categorysteprenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryAxis categoryaxis = new CategoryAxis("Category");
    NumberAxis numberaxis = new NumberAxis("Value");
    CategoryPlot categoryplot = new CategoryPlot(categorydataset, categoryaxis, numberaxis,
            categorysteprenderer);//from  ww w  . j  a  va  2  s .c om
    JFreeChart jfreechart = new JFreeChart("Category Step Chart", categoryplot);
    jfreechart.setBackgroundPaint(Color.white);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    categoryaxis.setLowerMargin(0.0D);
    categoryaxis.setUpperMargin(0.0D);
    categoryaxis.addCategoryLabelToolTip("Type 1", "The first type.");
    categoryaxis.addCategoryLabelToolTip("Type 2", "The second type.");
    categoryaxis.addCategoryLabelToolTip("Type 3", "The third type.");
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLabelAngle(0.0D);
    return jfreechart;
}

From source file:com.kiyoshi.gui.AreaChart.java

private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );/*from  ww w  .  ja v a  2 s  . c  o m*/

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);
    chart.setBackgroundPaint(Color.white);
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    //      plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:com.mergano.core.AreaChart.java

private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Order statistic", // chart title
            "Days", // domain axis label
            "Order Average", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            false, // tooltips
            false // urls
    );//from w  w w.j a  v  a  2  s .com

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);
    chart.setBackgroundPaint(Color.white);
    chart.setAntiAlias(true);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.getRenderer().setSeriesPaint(0, new Color(0, 191, 165));
    plot.setForegroundAlpha(0.75f);
    plot.setBackgroundPaint(Color.white);

    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); // disable this
    plot.setDomainGridlinesVisible(false);
    plot.setDomainGridlinePaint(new Color(240, 240, 240));
    plot.setRangeGridlinesVisible(false);
    plot.setRangeGridlinePaint(new Color(240, 240, 240));
    plot.setDomainCrosshairPaint(Color.MAGENTA);
    plot.setRangeCrosshairPaint(Color.CYAN);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:com.seniorproject.augmentedreality.test.AreaChartDemo.java

/**
 * Creates a chart.//ww  w .  j  a v  a 2 s  .  c o m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

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

    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);

    chart.setBackgroundPaint(Color.white);
    final TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this "
            + "subtitle as an example of what happens when you get a really long title or " + "subtitle.");
    subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
    subtitle.setPosition(RectangleEdge.TOP);
    //        subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05));
    subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    chart.addSubtitle(subtitle);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    //      plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

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

/**
 * Creates a chart./*from www . j  av a2s  . c  o m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createAreaChart("Area Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

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

    // set the background color for the chart...
    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setAnchor(StandardLegend.SOUTH);

    chart.setBackgroundPaint(Color.white);
    final TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this subtitle "
            + " as an example of what happens when you get a really long title or subtitle.");
    subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
    subtitle.setPosition(RectangleEdge.TOP);
    //        subtitle.setSpacer(new Spacer(Spacer.RELATIVE, 0.05, 0.05, 0.05, 0.05));
    subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
    chart.addSubtitle(subtitle);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    //        plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:edu.ucla.stat.SOCR.chart.demo.AreaChartDemo1.java

/**
 * Creates a Area chart.//from ww w  .java  2 s .com
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createAreaChart(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);
    if (isDemo) {
        TextTitle subtitle = new TextTitle("An area chart demonstration.  We use this subtitle as an "
                + "example of what happens when you get a really long title or " + "subtitle.");
        subtitle.setFont(new Font("SansSerif", Font.PLAIN, 12));
        subtitle.setPosition(RectangleEdge.TOP);
        subtitle.setPadding(new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, 0.05));
        subtitle.setVerticalAlignment(VerticalAlignment.BOTTOM);
        chart.addSubtitle(subtitle);
    }

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.5f);

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    AreaRenderer renderer = (AreaRenderer) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    if (isDemo) {
        domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
        domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
        domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");
    }
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    setCategorySummary(dataset);
    return chart;

}

From source file:org.gwaspi.gui.reports.ManhattanPlotZoom.java

private JFreeChart createChart(XYDataset dataset, ChromosomeKey chr) {
    JFreeChart chart = ChartFactory.createScatterPlot(null, "", "P value", dataset, PlotOrientation.VERTICAL,
            true, false, false);//from www  .j a va2 s .co m

    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setNoDataMessage("NO DATA");
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    // CHART BACKGROUD COLOR
    chart.setBackgroundPaint(Color.getHSBColor(0.1f, 0.1f, 1.0f)); // Hue, saturation, brightness
    plot.setBackgroundPaint(manhattan_back); // Hue, saturation, brightness 9

    // GRIDLINES
    plot.setDomainGridlineStroke(new BasicStroke(0.0f));
    plot.setDomainMinorGridlineStroke(new BasicStroke(0.0f));
    plot.setDomainGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7
    plot.setDomainMinorGridlinePaint(manhattan_back); // Hue, saturation, brightness 9
    plot.setRangeGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeMinorGridlineStroke(new BasicStroke(0.0f));
    plot.setRangeGridlinePaint(manhattan_back.darker().darker()); // Hue, saturation, brightness 7
    plot.setRangeMinorGridlinePaint(manhattan_back.darker()); // Hue, saturation, brightness 8

    plot.setDomainMinorGridlinesVisible(true);
    plot.setRangeMinorGridlinesVisible(true);

    // DOTS RENDERER
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, manhattan_dot);
    //      renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);
    //      renderer.setUseOutlinePaint(true);
    // Set dot shape of the currently appended Series
    renderer.setSeriesShape(0, new Rectangle2D.Double(0.0, 0.0, 2, 2));

    renderer.setSeriesVisibleInLegend(0, false);

    NumberAxis positionAxis = (NumberAxis) plot.getDomainAxis();
    //      domainAxis.setAutoRangeIncludesZero(false);
    //      domainAxis.setTickMarkInsideLength(2.0f);
    //      domainAxis.setTickMarkOutsideLength(2.0f);
    //      domainAxis.setMinorTickCount(2);
    //      domainAxis.setMinorTickMarksVisible(true);
    positionAxis.setLabelAngle(1.0);
    positionAxis.setAutoRangeIncludesZero(false);
    positionAxis.setAxisLineVisible(true);
    positionAxis.setTickLabelsVisible(true);
    positionAxis.setTickMarksVisible(true);

    // ADD INVERSE LOG(10) Y AXIS
    LogAxis logPAxis = new LogAxis("P value");
    logPAxis.setBase(10);
    logPAxis.setInverted(true);
    logPAxis.setNumberFormatOverride(GenericReportGenerator.FORMAT_P_VALUE);

    logPAxis.setTickMarkOutsideLength(2.0f);
    logPAxis.setMinorTickCount(2);
    logPAxis.setMinorTickMarksVisible(true);
    logPAxis.setAxisLineVisible(true);
    logPAxis.setUpperMargin(0);

    TickUnitSource units = NumberAxis.createIntegerTickUnits();
    logPAxis.setStandardTickUnits(units);
    plot.setRangeAxis(0, logPAxis);

    // Add significance Threshold to subplot
    //threshold = 0.5/rdMatrixMetadata.getMarkerSetSize();  // (0.05/10? SNPs => 5*10-?)
    final Marker thresholdLine = new ValueMarker(threshold);
    thresholdLine.setPaint(Color.red);
    // Add legend to threshold
    thresholdLine.setLabel("P = " + GenericReportGenerator.FORMAT_P_VALUE.format(threshold));
    thresholdLine.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
    thresholdLine.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
    plot.addRangeMarker(thresholdLine);

    // Marker label if below threshold
    XYItemRenderer lblRenderer = plot.getRenderer();

    // THRESHOLD AND SELECTED LABEL GENERATOR
    MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(threshold, chr);
    lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator);
    lblRenderer.setSeriesItemLabelFont(0, new Font("SansSerif", Font.PLAIN, 12));
    lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.TOP_LEFT, TextAnchor.BOTTOM_LEFT, Math.PI / 4.0));

    // TOOLTIP GENERATOR
    MyXYToolTipGenerator tooltipGenerator = new MyXYToolTipGenerator(chr);

    lblRenderer.setBaseToolTipGenerator(tooltipGenerator);

    lblRenderer.setSeriesItemLabelsVisible(0, true);

    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.CategoryStepChartDemo1.java

/**
 * Creates a chart.//  w  ww  .  j ava2 s.c  o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    CategoryItemRenderer renderer = new CategoryStepRenderer(true);

    CategoryAxis domainAxis = new CategoryAxis(domainLabel);
    NumberAxis rangeAxis = new NumberAxis(rangeLabel);
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(chartTitle, plot);

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

    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    AbstractCategoryItemRenderer renderer2 = (AbstractCategoryItemRenderer) plot.getRenderer();
    renderer2.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());

    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    domainAxis.setLowerMargin(0.0);
    domainAxis.setUpperMargin(0.0);
    domainAxis.addCategoryLabelToolTip("Type 1", "The first type.");
    domainAxis.addCategoryLabelToolTip("Type 2", "The second type.");
    domainAxis.addCategoryLabelToolTip("Type 3", "The third type.");

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelAngle(0 * Math.PI / 2.0);
    // OPTIONAL CUSTOMISATION COMPLETED.

    setCategorySummary(dataset);
    if (legendPanelOn)
        chart.removeLegend();
    return chart;

}