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

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

Introduction

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

Prototype

public void setCategoryLabelPositions(CategoryLabelPositions positions) 

Source Link

Document

Sets the category label position specification for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:playground.anhorni.PLOC.analysis.MultipleEnsemblesBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;//www .  j  a v  a2s  .c o  m

    final CategoryAxis xAxis = new CategoryAxis("Runs ensemble size");
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis("AvgDaysRuns_OfEnsembleAverageOfTotalExpenditures");
    yAxis.setAutoRangeIncludesZero(true);

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

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

/**
 * Creates a 3D bar chart.//from   w  ww  . ja v a2  s  .com
 * 
 * @param dataset  the category dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

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

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainGridlinesVisible(true);
    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0));
    BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    renderer.setDrawBarOutline(false);

    setCategorySummary(dataset);
    return chart;

}

From source file:fitmon.Chart.java

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

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // 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...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

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

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:net.sourceforge.subsonic.controller.UserChartController.java

private JFreeChart createChart(CategoryDataset dataset, HttpServletRequest request) {
    JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false,
            false, false);//w  ww.  j av a 2s  .  c  o  m

    CategoryPlot plot = chart.getCategoryPlot();
    Paint background = new GradientPaint(0, 0, Color.lightGray, 0, IMAGE_MIN_HEIGHT, Color.white);
    plot.setBackgroundPaint(background);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    LogarithmicAxis rangeAxis = new LogarithmicAxis(null);
    rangeAxis.setStrictValuesFlag(false);
    rangeAxis.setAllowNegativesFlag(true);
    plot.setRangeAxis(rangeAxis);

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

    // Set up gradient paint for series.
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    renderer.setSeriesPaint(0, gp0);

    // Rotate labels.
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    // Set theme-specific colors.
    Color bgColor = getBackground(request);
    Color fgColor = getForeground(request);

    chart.setBackgroundPaint(bgColor);

    domainAxis.setTickLabelPaint(fgColor);
    domainAxis.setTickMarkPaint(fgColor);
    domainAxis.setAxisLinePaint(fgColor);

    rangeAxis.setTickLabelPaint(fgColor);
    rangeAxis.setTickMarkPaint(fgColor);
    rangeAxis.setAxisLinePaint(fgColor);

    return chart;
}

From source file:playground.dgrether.analysis.charts.DgModalSplitGroupChart.java

public JFreeChart createChart() {
    CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel);
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel);
    valueAxis.setRange(0.0, 100.0);//from w w w . jav a 2 s .  c om

    DgColorScheme colorScheme = new DgColorScheme();

    CategoryPlot plot = new CategoryPlot();
    plot.setDomainAxis(categoryAxis);
    plot.setRangeAxis(valueAxis);
    plot.setDataset(0, this.dataset);
    BarRenderer carRenderer = new BarRenderer();
    carRenderer.setSeriesPaint(0, colorScheme.COLOR1A);
    carRenderer.setSeriesPaint(1, colorScheme.COLOR3A);

    carRenderer.setItemMargin(0.10);
    plot.setRenderer(0, carRenderer);

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    return chart;
}

From source file:sanger.team16.gui.genevar.eqtl.query.SNPGeneAssocPlot.java

private JFreeChart createChart(String populationName, CategoryDataset categoryDataset, double max, double min) {
    CategoryAxis categoryaxis = new CategoryAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    //categoryaxis.setMaximumCategoryLabelWidthRatio(5F);
    //categoryaxis.setMaximumCategoryLabelLines(141);
    //categoryaxis.setCategoryMargin(450);

    LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    lineandshaperenderer.setBaseShapesFilled(false);
    lineandshaperenderer.setBaseShape(ShapeUtilities.createDiamond((float) 3));
    lineandshaperenderer.setBaseSeriesVisibleInLegend(false);
    //lineandshaperenderer.setBaseLinesVisible(false);
    lineandshaperenderer.setAutoPopulateSeriesShape(false);
    lineandshaperenderer.setAutoPopulateSeriesPaint(false);
    //lineandshaperenderer.findRangeBounds(categoryDataset);

    NumberAxis numberaxis = new NumberAxis("Expression");
    numberaxis.setAutoRangeIncludesZero(false);
    //numberaxis.setRangeWithMargins(min, max);

    CategoryPlot categoryplot = new CategoryPlot(categoryDataset, categoryaxis, numberaxis,
            lineandshaperenderer);/*from   w w w . j  a  v  a2s  .  c  om*/
    categoryplot.setDomainGridlinesVisible(false);
    categoryplot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart jfreechart = new JFreeChart(populationName, new Font("SansSerif", 1, 14), categoryplot, true);
    return jfreechart;
}

From source file:playground.dgrether.analysis.charts.DgModalSplitDiffQuantilesChart.java

public JFreeChart createChart() {
    CategoryAxis categoryAxis = this.axisBuilder.createCategoryAxis(xLabel);
    categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    ValueAxis valueAxis = this.axisBuilder.createValueAxis(yLabel);
    //RANGE/*  w w w. j a  v a2s  .  c om*/
    //      valueAxis.setRange(-50.0, 50.0); //test
    valueAxis.setRange(-20.0, 20.0); //zh
    DgColorScheme colorScheme = new DgColorScheme();

    CategoryPlot plot = new CategoryPlot();
    plot.setDomainAxis(categoryAxis);
    //      plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    plot.setRangeAxis(valueAxis);
    plot.setDataset(0, this.dataset);
    //      plot.setDomainGridlinePosition(CategoryAnchor.END);
    //      plot.setDomainGridlinesVisible(true);
    BarRenderer carRenderer = new BarRenderer();
    carRenderer.setSeriesPaint(0, colorScheme.COLOR1A);
    carRenderer.setSeriesPaint(1, colorScheme.COLOR3A);
    carRenderer.setSeriesItemLabelGenerator(0, this.labelgenerator);
    carRenderer.setSeriesItemLabelGenerator(1, this.labelgenerator);
    Font labelFont = new Font("Helvetica", Font.BOLD, 14);
    carRenderer.setSeriesItemLabelFont(0, labelFont);
    carRenderer.setSeriesItemLabelFont(1, labelFont);
    carRenderer.setSeriesItemLabelsVisible(0, true);
    carRenderer.setSeriesItemLabelsVisible(1, true);

    carRenderer.setItemMargin(0.15);
    plot.setRenderer(0, carRenderer);

    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(ChartColor.WHITE);
    chart.removeLegend();
    //      chart.getLegend().setItemFont(this.axisBuilder.getAxisFont());
    return chart;
}

From source file:playground.anhorni.surprice.analysis.SupriceBoxPlot.java

public JFreeChart createChart() {
    String title = chartTitle;/*from  ww w .  ja va2 s  .  c o m*/

    final CategoryAxis xAxis = new CategoryAxis(this.xAxisName);
    xAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 10));
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    final NumberAxis yAxis = new NumberAxis(this.yAxisName);
    yAxis.setAutoRangeIncludesZero(true);

    if (Math.abs(yrangeLower - yrangeUpper) > Double.MIN_VALUE) {
        yAxis.setRange(yrangeLower, yrangeUpper);
    }

    final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setFillBox(false);
    renderer.setSeriesPaint(0, Color.blue);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);

    this.chart_ = new JFreeChart(title, new Font("SansSerif", Font.BOLD, 14), plot, false);
    return this.chart_;
}

From source file:WeeklyReport.Sections.Bookings.java

private JFreeChart bookingsByPODChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Map<Double, Map<String, String>> map = new CargoQuoteType().bookingsByPOD();
    map.entrySet().stream().forEach((mapEntry) -> {
        Map<String, String> m1 = mapEntry.getValue();
        m1.entrySet().stream().forEach((pair) -> {
            dataset.setValue(mapEntry.getKey(), pair.getKey(), pair.getValue());
        });//from   www .j  a v  a2s .  c  o m
    });
    JFreeChart barChart = ChartFactory.createBarChart3D("Bookings by POD", "Company", "Cubic Meters", dataset,
            PlotOrientation.HORIZONTAL, true, true, false);
    barChart.setBackgroundPaint(Color.WHITE);
    CategoryPlot categoryPlot = barChart.getCategoryPlot();
    CategoryAxis domainAxis = categoryPlot.getDomainAxis();
    BarRenderer br = (BarRenderer) categoryPlot.getRenderer();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(Color.BLACK);
    return barChart;
}

From source file:j2se.jfreechart.barchart.BarChartDemo8.java

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

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 8", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );

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

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

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setUpperMargin(0.15);

    // disable bar outlines...
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesItemLabelsVisible(0, Boolean.TRUE);

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

    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}