Example usage for org.jfree.chart.axis CategoryLabelPositions DOWN_45

List of usage examples for org.jfree.chart.axis CategoryLabelPositions DOWN_45

Introduction

In this page you can find the example usage for org.jfree.chart.axis CategoryLabelPositions DOWN_45.

Prototype

CategoryLabelPositions DOWN_45

To view the source code for org.jfree.chart.axis CategoryLabelPositions DOWN_45.

Click Source Link

Document

DOWN_45 category label positions.

Usage

From source file:com.xpn.xwiki.plugin.charts.params.CategoryLabelPositionsChartParam.java

@Override
protected void init() {
    addChoice("down_45", CategoryLabelPositions.DOWN_45);
    addChoice("down_90", CategoryLabelPositions.DOWN_90);
    addChoice("standard", CategoryLabelPositions.STANDARD);
    addChoice("up_45", CategoryLabelPositions.UP_45);
    addChoice("up_90", CategoryLabelPositions.UP_90);
}

From source file:de.tuberlin.dima.flinkhandson.utils.SingleSeriesBarChart.java

public SingleSeriesBarChart(String title, String xLabel, String yLabel, Color barColor,
        Map<String, Double> result) {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Map.Entry<String, Double> e : result.entrySet()) {
        dataset.addValue(e.getValue(), "", e.getKey());
    }//from  www .  java 2s  . c o  m

    JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL,
            false, true, false);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryAxis xAxis = plot.getDomainAxis();

    xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.BLACK);
    plot.setBackgroundPaint(Color.WHITE);

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

    renderer.setSeriesPaint(0, barColor);

    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(1024, 768));
    getContentPane().add(chartPanel);

    pack();
    setVisible(true);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

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());
        });/* w  w  w.j  av  a 2s .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:chart.DualAxis.java

/**
 * Creates a new demo instance./*from w w w. jav a2s.  c o m*/
 *
 * @param title  the frame title.
 */

public DualAxis(final String title, double[] xData, double[] YDataAnalitic, double[] YDataNumerical) {

    super(title);

    final CategoryDataset dataset1 = createDataset1(xData, YDataAnalitic);

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart("", // chart title
            "x", // domain axis label
            "y", // range axis label
            dataset1, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URL generator?  Not required...
    );

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

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF));
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    final CategoryDataset dataset2 = createDataset2(xData, YDataNumerical);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    //final ValueAxis axis2 = new NumberAxis("");
    final ValueAxis axis2 = new NumberAxis(" ");
    plot.setRangeAxis(1, axis2);

    final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(1, renderer2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);
    //  panel.removeAll();
    //   panel.add(chartPanel);
    //   panel.validate();

}

From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeBarTimeChartData.java

@Override
public JFreeChart getJFreeChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    double counts[] = ds.getCounts();
    String legends[] = ds.getLegends();
    int max_len = 0;
    for (int i = 0; i < ds.getNumSets(); i++) {
        if (legends != null && legends.length > i) {
            dataset.addValue(new Double(counts[i]), "Series-1", legends[i]);
            int leg_len = legends[i].length();
            if (leg_len > max_len) {
                max_len = leg_len;/*from  w  w  w  .j  av a2s  . co  m*/
            }
            //System.out.println(legends[i] + counts[i]);
        } else {
            dataset.addValue(new Double(counts[i]), "Series-1", Integer.toString(i));
        }
    }
    CategoryDataset data = dataset;

    JFreeChart chart = ChartFactory.createBarChart(title, null, quantity, data, PlotOrientation.VERTICAL, false, // include legends
            false, // tooltips
            false // urls
    );

    CategoryPlot categoryPlot = chart.getCategoryPlot();
    CategoryAxis axis = categoryPlot.getDomainAxis();
    if (max_len > 8 || ds.getNumSets() > 16 || (max_len * ds.getNumSets()) > 50) {
        axis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    }
    Font tickLabelFont = axis.getTickLabelFont();
    if (ds.getNumSets() > 24) {
        axis.setTickLabelFont(tickLabelFont.deriveFont(tickLabelFont.getSize() - 2.0F));
    }
    Font labelFont = axis.getLabelFont();
    axis.setMaximumCategoryLabelLines(3);
    //axis.setLabelFont(labelFont.d);
    // axis.setLabel("Pingu"); This works so we can modify

    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);/* w w  w. j  a va  2 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;
}

From source file:org.openfaces.component.chart.impl.PropertiesConverter.java

public static CategoryLabelPositions toCategroryLabelPosition(CategoryAxisLabelPosition position) {
    if (position == null)
        return CategoryLabelPositions.STANDARD;

    if (position.equals(CategoryAxisLabelPosition.UP_45))
        return CategoryLabelPositions.UP_45;
    if (position.equals(CategoryAxisLabelPosition.UP_90))
        return CategoryLabelPositions.UP_90;
    if (position.equals(CategoryAxisLabelPosition.DOWN_45))
        return CategoryLabelPositions.DOWN_45;
    if (position.equals(CategoryAxisLabelPosition.DOWN_90))
        return CategoryLabelPositions.DOWN_90;

    return CategoryLabelPositions.STANDARD;
}

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

/**
 * Creates a new demo instance./* w  ww  . ja v  a  2  s  .  com*/
 *
 * @param title  the frame title.
 */
public DualAxisDemo(final String title) {

    super(title);

    final CategoryDataset dataset1 = createDataset1();

    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart("Dual Axis Chart", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset1, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips?
            false // URL generator?  Not required...
    );

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

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(new Color(0xEE, 0xEE, 0xFF));
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);

    final CategoryDataset dataset2 = createDataset2();
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    final ValueAxis axis2 = new NumberAxis("Secondary");
    plot.setRangeAxis(1, axis2);

    final LineAndShapeRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(1, renderer2);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    setContentPane(chartPanel);

}

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

private static JFreeChart createChart() {
    JFreeChart jfreechart = ChartFactory.createBarChart("Dual Axis Chart", "Category", "Value",
            createDataset1(), PlotOrientation.VERTICAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(new Color(238, 238, 255));
    categoryplot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    CategoryDataset categorydataset = createDataset2();
    categoryplot.setDataset(1, categorydataset);
    categoryplot.mapDatasetToRangeAxis(1, 1);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    NumberAxis numberaxis = new NumberAxis("Secondary");
    categoryplot.setRangeAxis(1, numberaxis);
    LineAndShapeRenderer lineandshaperenderer = new LineAndShapeRenderer();
    lineandshaperenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    categoryplot.setRenderer(1, lineandshaperenderer);
    categoryplot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    LegendTitle legendtitle = new LegendTitle(categoryplot.getRenderer(0));
    legendtitle.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendtitle.setFrame(new BlockBorder());
    LegendTitle legendtitle1 = new LegendTitle(categoryplot.getRenderer(1));
    legendtitle1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendtitle1.setFrame(new BlockBorder());
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    blockcontainer.add(legendtitle, RectangleEdge.LEFT);
    blockcontainer.add(legendtitle1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle = new CompositeTitle(blockcontainer);
    compositetitle.setPosition(RectangleEdge.BOTTOM);
    jfreechart.addSubtitle(compositetitle);
    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//from   ww w  .  ja v  a  2  s .  co  m
    //      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;
}