Example usage for org.jfree.chart ChartFactory createBarChart3D

List of usage examples for org.jfree.chart ChartFactory createBarChart3D

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createBarChart3D.

Prototype

public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a bar chart with a 3D effect.

Usage

From source file:WeeklyReport.Sections.Declines.java

private JFreeChart declinesByCommodityClassChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    Map<Double, Map<String, String>> mp = DECLINES_BY_COMMODITY_CLASS;
    mp.entrySet().stream().forEach((mapEntry) -> {
        Map<String, String> m1 = mapEntry.getValue();
        m1.entrySet().stream().forEach((pair) -> {
            dataset.setValue(mapEntry.getKey(), pair.getValue(), pair.getKey());
        });/*w  ww. j  av  a 2 s. c om*/
    });
    JFreeChart barChart = ChartFactory.createBarChart3D("Declines by Commodity Class", "Commodity Class",
            "Cubic Meters", dataset, PlotOrientation.VERTICAL, true, true, false);
    return barChart;

}

From source file:edu.coeia.charts.BarChartPanel.java

private JFreeChart createChart(final CategoryDataset dataset, String str) {
    final JFreeChart chart = ChartFactory.createBarChart3D(str, // chart title
            "Names", // domain axis label
            "Values(%)", // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );//from  www.  j a v  a2 s . co m

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

    // left align the category labels...
    final CategoryAxis axis = plot.getDomainAxis();
    final CategoryLabelPositions p = axis.getCategoryLabelPositions();

    final CategoryLabelPosition left = new CategoryLabelPosition(RectangleAnchor.LEFT,
            TextBlockAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, 0.0, CategoryLabelWidthType.RANGE, 0.30f);
    axis.setCategoryLabelPositions(CategoryLabelPositions.replaceLeftPosition(p, left));

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(from, to);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.MaturityBarChart.java

protected JFreeChart createBarChart(Object dataset) {
    final float plotForegroundAlpha = 0.6f;
    final int axisUpperBound = 9;
    JFreeChart chart = ChartFactory.createBarChart3D(null, Messages.MaturityBarChart_1,
            Messages.MaturityBarChart_2, (CategoryDataset) dataset, PlotOrientation.HORIZONTAL, false, true,
            false);//from  ww w  .  j  a  v  a2  s.  co  m
    chart.setBackgroundPaint(Color.white);
    chart.getPlot().setForegroundAlpha(plotForegroundAlpha);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    plot.getRenderer().setSeriesPaint(0, ChartColor.LIGHT_BLUE);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);

    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setUpperBound(axisUpperBound);

    return chart;
}

From source file:sernet.gs.ui.rcp.main.bsi.views.chart.SamtProgressChart.java

protected JFreeChart createBarChart(Object dataset) {
    JFreeChart chart = ChartFactory.createBarChart3D(null, Messages.SamtProgressChart_1,
            Messages.SamtProgressChart_2, (CategoryDataset) dataset, PlotOrientation.HORIZONTAL, true, true,
            false);/* www. j av  a2  s  . c o  m*/

    chart.setBackgroundPaint(Color.white);
    chart.getPlot().setForegroundAlpha(CHART_FOREGROUND_ALPHA);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    plot.getRenderer().setSeriesPaint(0, ChartColor.LIGHT_GREEN);
    plot.getRenderer().setSeriesPaint(1, ChartColor.LIGHT_RED);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);

    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setUpperBound(AXIS_UPPER_BOUND);

    return chart;
}

From source file:net.chaosserver.timelord.swingui.ChartingPanel.java

/**
 * Creates the Chart Object for display.
 *
 * @param dataset the dataset to be charted
 * @return the chart object for display/*from   w  w w. j a  v a 2  s  .c  o  m*/
 */
private JFreeChart createChart(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart3D("Hours Worked Per Day", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    return chart;
}

From source file:com.ev.export.AnnualPDFExporter.java

@Override
public void initChart() {
    chart = ChartFactory.createBarChart3D("", getLang().getString("Month"), getLang().getString("Consumption"),
            consumption.generateYearDatasetForDiagram(), PlotOrientation.VERTICAL, true, true, true);
}

From source file:fr.paris.lutece.plugins.form.business.GraphTypeBarChart.java

/**
* return the JFreeChart BarChart graph/*from  w  w w  .  j  a va 2  s.  c o m*/
* @param listStatistic listStatistic
* @param strGraphTitle graph title
* @param nGraphThreeDimension true if the graph must be in three dimension
* @param nGraphLabelValue true if the labels must appear in the graph
* @return the JFreeChart graph associate to the graph type
*/

//Cration de l'histogramme
public static JFreeChart createBarChart(List<StatisticEntrySubmit> listStatistic, String strGraphTitle,
        boolean nGraphThreeDimension, boolean nGraphLabelValue) {
    JFreeChart chart;
    CategoryDataset dataset = createBarChartDataset(listStatistic);

    if (nGraphThreeDimension) {
        chart = ChartFactory.createBarChart3D(strGraphTitle, null, null, dataset, PlotOrientation.VERTICAL,
                true, false, false);
    } else {
        chart = ChartFactory.createBarChart(strGraphTitle, null, null, dataset, PlotOrientation.VERTICAL, true,
                false, false);
    }

    CategoryPlot categoryPlot = chart.getCategoryPlot();
    CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
    CategoryLabelPositions labelPositions = CategoryLabelPositions.UP_45;
    categoryAxis.setCategoryLabelPositions(labelPositions);

    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    if (nGraphLabelValue) {
        renderer.setItemLabelsVisible(true);

        DecimalFormat decimalformat1 = new DecimalFormat("#.#");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1));

        if (nGraphThreeDimension) {
            renderer.setPositiveItemLabelPositionFallback(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT));
            categoryPlot.setRenderer(renderer);
        }
    }

    return chart;
}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by day-of-the-
 * week. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.     * // ww w .  j  av a2s. c o  m
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against days of the Calendar week.
 */
public JFreeChart createPiracyHistogramDayOfWeek(LinkedList<PiracyEvent> data) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    Integer[] freqs = new Integer[DAYS_OF_THE_WEEK.length];
    Calendar cal = Calendar.getInstance();

    //set up the frequencies array
    for (int i = 0; i < freqs.length; i++) {
        freqs[i] = 0;
    }

    for (PiracyEvent ev : data) {
        cal.setTime(ev.getDate());
        freqs[cal.get(Calendar.DAY_OF_WEEK) - 1]++;
    }

    //add the frequencies to a dataset for plotting
    for (int i = 0; i < freqs.length; i++) {
        dataset.addValue(freqs[i], "Piracy Incidents", DAYS_OF_THE_WEEK[i]);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by days of the week",
            "Day of the Week", "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}

From source file:DualAxisDemo4.java

/**
 * Creates a new demo instance./*from   ww  w  .j  a v  a  2s .  c om*/
 *
 * @param title  the frame title.
 */
public DualAxisDemo4(final String title) {

    super(title);

    final CategoryDataset dataset1 = createDataset1();

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

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

    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC));
    //        chart.getLegend().setAnchor(Legend.SOUTH);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    final CategoryItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.yellow);
    renderer1.setSeriesPaint(2, Color.green);
    final CategoryDataset dataset2 = createDataset2();
    final ValueAxis axis2 = new NumberAxis3D("Secondary");
    plot.setRangeAxis(1, axis2);
    plot.setDataset(1, dataset2);
    plot.mapDatasetToRangeAxis(1, 1);
    final CategoryItemRenderer renderer2 = new LineAndShapeRenderer();
    renderer2.setSeriesPaint(0, Color.blue);
    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.eevolution.form.CRPDetail.java

/**
 * Create Chart based on UOM/*from w  ww .  j  av a  2  s. c  o m*/
 * 
 * @param dataset
 * @param title
 * @param uom
 * @return JFreeChart Chart based On UOM
 */
public JFreeChart createChart(CategoryDataset dataset, String title, MUOM uom) {

    JFreeChart chart = ChartFactory.createBarChart3D(title, Msg.translate(Env.getCtx(), "Day"), // X-Axis label
            Msg.translate(Env.getCtx(), (uom == null) ? "" : uom.getName()), // Y-Axis
            // label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    chart.setBackgroundPaint(Color.WHITE);
    chart.setAntiAlias(true);
    chart.setBorderVisible(true);

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.GRAY);

    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.GRAY);

    BarRenderer3D barrenderer = (BarRenderer3D) plot.getRenderer();
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelGenerator(new LabelGenerator());
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setSeriesPaint(0, new Color(10, 80, 150, 128));
    barrenderer.setSeriesPaint(1, new Color(180, 60, 50, 128));

    ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
            TextAnchor.TOP_CENTER);
    barrenderer.setPositiveItemLabelPosition(itemlabelposition);

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