Example usage for org.jfree.chart ChartFactory createStackedBarChart3D

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

Introduction

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

Prototype

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

Source Link

Document

Creates a stacked bar chart with a 3D effect and default settings.

Usage

From source file:edu.uara.wrappers.customcharts.CustomBarChart.java

@Override
public void generate3DStackedBarChart(CategoryDataset dataset) {
    this.ds = dataset;//store reference to dataset to do update
    try {/*from  w w  w . j a  va 2s.  c  o m*/
        if (dataset == null)
            throw new Exception("No dataset provided");
        chart = ChartFactory.createStackedBarChart3D(title, // chart title
                domainAxisLabel, // domain axis label
                rangeAxisLabel, // range axis label
                dataset, // data
                orientation, // orientation
                legend, // include legend
                false, // no tooltips
                false // URLs?
        );
        currentDatasetType = DatasetTypes.CategoryDataset;
    } catch (Exception ex) {
        //handle exception
    }
}

From source file:net.sourceforge.atunes.kernel.modules.statistics.StatsDialogController.java

/**
 * Puts image with chart in given label, with title and data provided
 * //from   www.  ja v  a2 s.  c  o  m
 * @param data
 * @param titleKey
 * @param chartLabel
 */
private void setChart(final List<?> data, final String titleKey, final JLabel chartLabel) {
    DefaultCategoryDataset dataset = getDataSet(data);
    JFreeChart chart = ChartFactory.createStackedBarChart3D(I18nUtils.getString(titleKey), null, null, dataset,
            PlotOrientation.HORIZONTAL, false, false, false);
    chart.setBackgroundPaint(Color.WHITE);
    chart.setPadding(new RectangleInsets(5, 0, 0, 0));
    NumberAxis axis = new NumberAxis();
    axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    chart.setBackgroundPaint(GuiUtils.getBackgroundColor());
    chart.getTitle().setPaint(GuiUtils.getForegroundColor());
    chart.getCategoryPlot().setRangeAxis(axis);
    chart.getCategoryPlot().setForegroundAlpha(1f);
    chart.getCategoryPlot().getRenderer().setSeriesPaint(0, Color.GREEN);
    chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(GuiUtils.getForegroundColor());
    chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(GuiUtils.getForegroundColor());
    chart.getPlot().setBackgroundPaint(GuiUtils.getBackgroundColor());
    chartLabel.setIcon(new ImageIcon(chart.createBufferedImage(710, 250)));
}

From source file:org.tiefaces.components.websheet.chart.ChartHelper.java

/**
 * Create jfree bar chart./*from  w w  w . ja v a2s  .c o m*/
 * 
 * @param chartData
 *            contain information gathered from excel chart object.
 * @param vertical
 *            chart orientation.
 * @return jfree line chart.
 */
public JFreeChart createStackedBarChart3D(final ChartData chartData, final boolean vertical) {

    PlotOrientation orientation = PlotOrientation.VERTICAL;
    if (!vertical) {
        orientation = PlotOrientation.HORIZONTAL;
    }
    // create the chart...
    final JFreeChart chart = ChartFactory.createStackedBarChart3D(chartData.getTitle(), // chart title
            chartData.getCatAx().getTitle(), // x axis label
            chartData.getValAx().getTitle(), // y axis label
            createDataset(chartData), // data
            orientation, true, // include legend
            false, // tooltips
            false // urls
    );

    setupBarStyle(chart, chartData);

    return chart;

}

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

/**
 * Creates and returns a sample stacked vertical 3D bar chart.
 *
 * @return a sample stacked vertical 3D bar chart.
 *///ww  w .j  a  v  a 2s  . com
public JFreeChart createVerticalStacked3DBarChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("bar.vertical-stacked3D.title");
    final String domain = this.resources.getString("bar.vertical-stacked3D.domain");
    final String range = this.resources.getString("bar.vertical-stacked3D.range");
    final CategoryDataset data = DemoDatasetFactory.createCategoryDataset();
    final JFreeChart chart = ChartFactory.createStackedBarChart3D(title, domain, range, data,
            PlotOrientation.VERTICAL, true, true, false);

    // then customise it a little...
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 1000, 0, Color.red));
    return chart;

}

From source file:org.adempiere.apps.graph.ChartBuilder.java

private JFreeChart create3DStackedBarChart() {
    JFreeChart chart = ChartFactory.createStackedBarChart3D(chartModel.get_Translation(MChart.COLUMNNAME_Name), // chart title
            chartModel.get_Translation(MChart.COLUMNNAME_DomainLabel), // domain axis label
            chartModel.get_Translation(MChart.COLUMNNAME_RangeLabel), // range axis label
            getCategoryDataset(), // data
            X_AD_Chart.CHARTORIENTATION_Horizontal.equals(chartModel.getChartOrientation())
                    ? PlotOrientation.HORIZONTAL
                    : PlotOrientation.VERTICAL, // orientation
            chartModel.isDisplayLegend(), // include legend
            true, // tooltips?
            true // URLs?
    );/*from   w w w . j  a v  a 2s .  com*/

    setupCategoryChart(chart);
    return chart;
}

From source file:org.bhavaya.ui.view.ChartView.java

private JFreeChart createStackedVerticalBarChart() {
    JFreeChart chart;//from   w w w.j  a va  2 s  . c om
    if (isPlot3D()) {
        chart = ChartFactory.createStackedBarChart3D(getName(), getDomainName(), getRangeName(),
                tableModelDataSet, PlotOrientation.VERTICAL, true, true, false);
    } else {
        chart = ChartFactory.createStackedBarChart(getName(), getDomainName(), getRangeName(),
                tableModelDataSet, PlotOrientation.VERTICAL, true, true, false);
    }
    NumberAxis rangeAxis = (NumberAxis) chart.getCategoryPlot().getRangeAxis();
    rangeAxis.setAutoTickUnitSelection(true);

    CategoryAxis domainAxis = (CategoryAxis) chart.getCategoryPlot().getDomainAxis();
    domainAxis.setTickMarksVisible(true);
    return chart;
}

From source file:de.forsthaus.webui.customer.CustomerChartCtrl.java

/**
 * onClick button Stacked Bar 3D Chart. <br>
 * /*from   w ww. j  a v  a 2  s  .c  o  m*/
 * @param event
 * @throws IOException
 */
public void onClick$button_CustomerChart_StackedBar3D(Event event) throws InterruptedException, IOException {
    // logger.debug(event.toString());

    div_chartArea.getChildren().clear();

    // get the customer ID for which we want show a chart
    long kunId = getCustomer().getId();

    // get a list of data
    List<ChartData> kunAmountList = getChartService().getChartDataForCustomer(kunId);

    if (kunAmountList.size() > 0) {

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();

        for (ChartData chartData : kunAmountList) {

            Calendar calendar = new GregorianCalendar();
            calendar.setTime(chartData.getChartKunInvoiceDate());

            int month = calendar.get(Calendar.MONTH) + 1;
            int year = calendar.get(Calendar.YEAR);
            String key = String.valueOf(month) + "/" + String.valueOf(year);

            BigDecimal bd = chartData.getChartKunInvoiceAmount().setScale(15, 3);
            String amount = String.valueOf(bd.doubleValue());

            // fill the data
            dataset.setValue(new Double(chartData.getChartKunInvoiceAmount().doubleValue()), key + " " + amount,
                    key + " " + amount);
        }

        String title = "Monthly amount for year 2009";
        PlotOrientation po = PlotOrientation.VERTICAL;
        JFreeChart chart = ChartFactory.createStackedBarChart3D(title, "Month", "Amount", dataset, po, true,
                true, true);

        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setForegroundAlpha(0.5f);
        BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

        AImage chartImage = new AImage("Stacked Bar Chart 3D", bytes);

        Image img = new Image();
        img.setContent(chartImage);
        img.setParent(div_chartArea);

    } else {

        div_chartArea.getChildren().clear();

        Label label = new Label();
        label.setValue("This customer have no data for showing in a chart!");

        label.setParent(div_chartArea);

    }
}

From source file:hudson.plugins.plot.PlotData.java

/**
 * Creates a Chart of the style indicated by getEffStyle() using the given dataset.
 * Defaults to using createLineChart.//  w  w  w .java  2 s.c  om
 */
private JFreeChart createChart(PlotCategoryDataset dataset) {
    String s = getUrlStyle();
    if (s.equalsIgnoreCase("area")) {
        return ChartFactory.createAreaChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("bar")) {
        return ChartFactory.createBarChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("bar3d")) {
        return ChartFactory.createBarChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("line3d")) {
        return ChartFactory.createLineChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("stackedarea")) {
        return ChartFactory.createStackedAreaChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(),
                dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("stackedbar")) {
        return ChartFactory.createStackedBarChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(),
                dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("stackedbar3d")) {
        return ChartFactory.createStackedBarChart3D(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(),
                dataset, PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    if (s.equalsIgnoreCase("waterfall")) {
        return ChartFactory.createWaterfallChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }
    return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
            PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
}

From source file:hudson.plugins.plot.Plot.java

/**
 * Creates a Chart of the style indicated by getEffStyle() using the given
 * dataset. Defaults to using createLineChart.
 *//*  ww w .  ja  va  2 s . c  o m*/
private JFreeChart createChart(PlotCategoryDataset dataset) {
    String s = getUrlStyle();
    if ("area".equalsIgnoreCase(s)) {
        return ChartFactory.createAreaChart(getURLTitle(), /*
                                                            * categoryAxisLabel=
                                                            */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("bar".equalsIgnoreCase(s)) {
        return ChartFactory.createBarChart(getURLTitle(), /*
                                                           * categoryAxisLabel=
                                                           */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("bar3d".equalsIgnoreCase(s)) {
        return ChartFactory.createBarChart3D(getURLTitle(), /*
                                                             * categoryAxisLabel
                                                             * =
                                                             */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("line3d".equalsIgnoreCase(s)) {
        return ChartFactory.createLineChart3D(getURLTitle(), /*
                                                              * categoryAxisLabel
                                                              * =
                                                              */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("lineSimple".equalsIgnoreCase(s)) {
        return ChartFactory.createLineChart(getURLTitle(), /*categoryAxisLabel=*/null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*tooltips=*/true, /*url=*/false);
    }

    if ("stackedarea".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedAreaChart(getURLTitle(), /*
                                                                   * categoryAxisLabel
                                                                   * =
                                                                   */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("stackedbar".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedBarChart(getURLTitle(), /*
                                                                  * categoryAxisLabel
                                                                  * =
                                                                  */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("stackedbar3d".equalsIgnoreCase(s)) {
        return ChartFactory.createStackedBarChart3D(getURLTitle(), /*
                                                                    * categoryAxisLabel
                                                                    * =
                                                                    */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    if ("waterfall".equalsIgnoreCase(s)) {
        return ChartFactory.createWaterfallChart(getURLTitle(), /*
                                                                 * categoryAxisLabel
                                                                 * =
                                                                 */null, getYaxis(), dataset,
                PlotOrientation.VERTICAL, hasLegend(), /*
                                                        * tooltips
                                                        * =
                                                        */
                true, /* url= */false);
    }
    return ChartFactory.createLineChart(getURLTitle(), /* categoryAxisLabel= */
            null, getYaxis(), dataset, PlotOrientation.VERTICAL, hasLegend(), /* tooltips= */true,
            /* url= */false);
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

/**
 *
 *///from   ww  w . j  a v  a 2 s  .  com
protected JFreeChart createStackedBar3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedBarChart3D(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()),
            (String) evaluateExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot();

    StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D(
            bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET
                    : bar3DPlot.getXOffsetDouble().doubleValue(),
            bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET
                    : bar3DPlot.getYOffsetDouble().doubleValue());

    stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
    stackedBarRenderer3D.setBaseItemLabelsVisible(bar3DPlot.getShowLabels());

    categoryPlot.setRenderer(stackedBarRenderer3D);

    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
            bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
            bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(),
            bar3DPlot.getCategoryAxisVerticalTickLabels(), bar3DPlot.getOwnCategoryAxisLineColor(), false,
            (Comparable) evaluateExpression(bar3DPlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(bar3DPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), bar3DPlot.getValueAxisLabelFont(),
            bar3DPlot.getValueAxisLabelColor(), bar3DPlot.getValueAxisTickLabelFont(),
            bar3DPlot.getValueAxisTickLabelColor(), bar3DPlot.getValueAxisTickLabelMask(),
            bar3DPlot.getValueAxisVerticalTickLabels(), bar3DPlot.getOwnValueAxisLineColor(), true,
            (Comparable) evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}