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:gchisto.gui.panels.gcstats.BreakdownChartPanelMulti.java

/**
 * It creates a chart for the given dataset and adds the chart to the panel.
 *
 * @param dataset The dataset that will provide the values for the chart.
 *///from  w  w  w .j  a  va  2s  .c  o m
private void addChart() {
    JFreeChart chart = ChartFactory.createStackedBarChart3D(getTitle(), null, "Breakdown" + unitSuffix(),
            dataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    chart.addProgressListener(locker);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setToolTipGenerator(dataset);

    mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart));
}

From source file:org.javarebel.chart.generator.ChartGenerator.java

protected void configureAxis(CategoryAxis axis, DefaultAxisConfig config) {
    axis.setCategoryLabelPositions(config.getLabelPosition());
    axis.setLabelFont(config.getLabelFont());
    axis.setTickLabelFont(config.getTickLabelFont());
    axis.setLowerMargin(config.getLowerMargin());
    axis.setUpperMargin(config.getUpperMargin());
    axis.setCategoryMargin(config.getCategoryMargin());
}

From source file:com.sonyericsson.jenkins.plugins.bfa.graphs.StackedBarChart.java

@Override
protected JFreeChart createGraph() {
    DefaultCategoryDataset dataset = createDataset();

    JFreeChart chart = ChartFactory.createStackedBarChart(getTitle(), getXAxisTitle(), getYAxisTitle(), dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot plot = chart.getCategoryPlot();
    int index = dataset.getRowIndex(NO_FAILURE);
    if (index >= 0) {
        plot.getRenderer().setSeriesVisibleInLegend(index, false);
    }//from  www  .j av a2  s . c o m
    CategoryAxis domainAxis = plot.getDomainAxis();

    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0);

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

    return chart;
}

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

/**
 * Creates a chart.//w w w .  j  av  a 2s.  c  om
 * 
 * @param dataset  the 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();
    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0));

    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setBaseItemLabelsVisible(true);
    BarRenderer r = (BarRenderer) renderer;
    r.setMaximumBarWidth(0.05);
    r.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    setCategorySummary(dataset);
    return chart;

}

From source file:org.squale.squaleweb.util.graph.BarMaker.java

/**
 * @return le diagramme JFreeChart/* w  w w .  jav a2s .  com*/
 */
protected JFreeChart getChart() {
    JFreeChart retChart = super.getChart();
    if (null == retChart) {
        retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL,
                false, false, false);

        CategoryPlot plot = retChart.getCategoryPlot();

        // Les valeurs sont des entiers
        final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

        // On effectue une rotation de 90 pour afficher le titre des abscisses  la verticale
        CategoryAxis domainAxis = plot.getDomainAxis();
        domainAxis.setCategoryLabelPositions(
                CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));
        super.setChart(retChart);
    }
    return retChart;
}

From source file:datavis.BarGraph.java

public JFreeChart getChartPanel() {
    JFreeChart chart = ChartFactory.createBarChart(getBarGraphName(), getIntervalTypeName(),
            getNumberTypeName(), getBarGraph(), PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.darkGray);
    plot.setDomainGridlinePaint(new Color(240, 180, 180));
    plot.setRangeGridlinePaint(new Color(240, 180, 180));

    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardBarPainter());

    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, new Color(170, 240, 240), 0.0f, 0.0f,
            new Color(170, 240, 240));

    renderer.setSeriesPaint(0, gp0);/*  w ww  .  ja  v  a  2 s. c  om*/

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

    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
    );//ww  w .ja v a2 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);
    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:Demo.LineGraph.java

private void InitChart() {
    JFreeChart chart = ChartFactory.createLineChart("Yield", "sample NB", "Probability", dataSet,
            PlotOrientation.VERTICAL, false, false, false);

    CategoryPlot plot = chart.getCategoryPlot();

    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);

    plot.setDomainGridlinesVisible(true);
    plot.setNoDataMessage("no data");

    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseItemLabelsVisible(true);
    renderer.setSeriesPaint(0, Color.BLUE);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);/*from w ww  . j av  a  2 s .c  om*/

    renderer.setBaseItemLabelsVisible(true);
    renderer.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelFont(new Font("Times New Romain", 0, 10));
    plot.setRenderer(renderer);

    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createDownRotationLabelPositions(Math.PI / 6.0));

    chartPane = new ChartPanel(chart);
}

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

private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart("Revenue", "Monthly", "Amount", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    // 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.white);
    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);/* w  w w  . java 2  s .co  m*/

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

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

    return chart;

}

From source file:playground.dgrether.analysis.charts.DgModalSplitQuantilesChart.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, 102.0);//from w  w  w  . j  a  v  a2 s . co  m

    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());
    chart.removeLegend();
    return chart;
}