Java Code Examples for org.jfree.chart.ChartFactory#createBarChart3D()

The following examples show how to use org.jfree.chart.ChartFactory#createBarChart3D() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BarChart3DBuilder.java    From qpid-broker-j with Apache License 2.0 6 votes vote down vote up
@Override
protected JFreeChart createCategoryChart(String title, String xAxisTitle,
        String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation,
        boolean showLegend, boolean showToolTips, boolean showUrls)
{
    JFreeChart chart = ChartFactory.createBarChart3D(title,
            xAxisTitle,
            yAxisTitle,
            (CategoryDataset)dataset,
            plotOrientation,
            showLegend,
            showToolTips,
            showUrls);

    return chart;
}
 
Example 2
Source File: CommonBarChartAction.java    From bamboobsc with Apache License 2.0 6 votes vote down vote up
private void fillChart(String title, String categoryLabel, String valueLabel, 
		List<String> names, List<Float> values, List<String> colors, boolean horizontal) throws Exception {
	DefaultCategoryDataset data=new DefaultCategoryDataset();
	for (int ix=0; ix<names.size(); ix++) {			
		data.addValue(values.get(ix), "", names.get(ix));			
	}		
       this.chart=ChartFactory.createBarChart3D(
       		title, // title
       		categoryLabel,
       		valueLabel, 
       		data, 
       		( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL ),
       		false,
       		false, 
       		false);		
       CategoryPlot plot=(CategoryPlot)this.chart.getPlot();
       CategoryAxis categoryAxis=plot.getDomainAxis();   
       categoryAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) );
       categoryAxis.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 9) );
       NumberAxis numberAxis=(NumberAxis)plot.getRangeAxis();
       numberAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9) );
       this.setPlotColor(plot, names, colors);
       this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9) ) );		
}
 
Example 3
Source File: BarChart3DTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createBarChart3D() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S",
            "C", data);

    // create the chart...
    return ChartFactory.createBarChart3D("Bar Chart 3D", "Domain", "Range",
            dataset, true);

}
 
Example 4
Source File: BarChart3DTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Create a horizontal bar chart with sample data in the range -3 to +3.
 *
 * @return The chart.
 */
private static JFreeChart createBarChart3D() {

    // create a dataset...
    Number[][] data = new Integer[][]
        {{new Integer(-3), new Integer(-2)},
         {new Integer(-1), new Integer(1)},
         {new Integer(2), new Integer(3)}};

    CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", 
            "C", data);

    // create the chart...
    return ChartFactory.createBarChart3D("Bar Chart 3D", "Domain", "Range",
            dataset, PlotOrientation.HORIZONTAL, true, true, true);

}
 
Example 5
Source File: StatisticChart.java    From BART with MIT License 5 votes vote down vote up
public static JPanel createBarChart(String title,String category,String value,CategoryDataset dataset)   {
    JFreeChart barChart = ChartFactory
            .createBarChart3D(title, 
                    category, value, dataset, 
                    PlotOrientation.VERTICAL, true, true, false);
    ChartPanel panel = new ChartPanel(barChart);
    panel.setPreferredSize(new Dimension(700, 440));
    return panel;
}
 
Example 6
Source File: BarChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 5 votes vote down vote up
public JFreeChart computeCategoryChart( final CategoryDataset categoryDataset ) {
  final PlotOrientation orientation = computePlotOrientation();

  final JFreeChart chart;
  if ( isThreeD() ) {
    if ( isStacked() ) {
      chart = ChartFactory.createStackedBarChart3D( computeTitle(),
        getCategoryAxisLabel(), getValueAxisLabel(),
        categoryDataset, orientation, isShowLegend(),
        false, false );
    } else {
      chart = ChartFactory.createBarChart3D( computeTitle(),
        getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset,
        orientation, isShowLegend(), false, false );
    }
    chart.getCategoryPlot().setDomainAxis( new FormattedCategoryAxis3D( getCategoryAxisLabel(),
      getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale() ) );
  } else {
    if ( isStacked() ) {
      chart = ChartFactory.createStackedBarChart( computeTitle(),
        getCategoryAxisLabel(), getValueAxisLabel(),
        categoryDataset, orientation, isShowLegend(),
        false, false );
    } else {
      chart = ChartFactory.createBarChart( computeTitle(),
        getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset,
        orientation, isShowLegend(), false, false );
    }
    chart.getCategoryPlot().setDomainAxis( new FormattedCategoryAxis( getCategoryAxisLabel(),
      getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale() ) );
  }

  final CategoryPlot plot = (CategoryPlot) chart.getPlot();
  configureLogarithmicAxis( plot );

  return chart;
}
 
Example 7
Source File: BarChartDataPlugin.java    From ramus with GNU General Public License v3.0 4 votes vote down vote up
@Override
public JFreeChart createChart(Element element, ChartSource source) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    Attribute key = source.getAttributeProperty(BAR_ATTRIBUTE_KEY);

    List<Attribute> attributes = source
            .getPropertyAttributes(BAR_ATTRIBUTE_VALUE_PREFIX);

    for (Element e : source.getElements()) {
        Object keyValue = engine.getAttribute(e, key);
        if (keyValue != null) {
            for (Attribute attribute : attributes) {
                Object value = engine.getAttribute(e, attribute);
                if (value != null) {
                    double v = new EObject(value).doubleValue();
                    dataset.addValue(v, attribute.getName(), new EObject(
                            keyValue).stringValue());
                }
            }
        }
    }

    JFreeChart chart = ChartFactory
            .createBarChart3D(
                    element.getName(),
                    source.getProperty(BAR_CATEGORY_AXIS_LABEL),
                    source.getProperty(BAR_VALUE_AXIS_LABEL),
                    dataset,
                    (BAR_ORIENTATION_HORIZONTAL.equals(source
                            .getProperty(BAR_ORIENTATION))) ? PlotOrientation.HORIZONTAL
                            : PlotOrientation.VERTICAL, true, true, true);

    GradientPaint gradientpaint0 = new GradientPaint(0.0F, 0.0F, new Color(
            0, 0, 250), 0.0F, 0.0F, new Color(136, 136, 255));

    BarRenderer3D r = (BarRenderer3D) chart.getCategoryPlot().getRenderer();
    r.setSeriesPaint(0, gradientpaint0);

    return chart;
}
 
Example 8
Source File: DefaultChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createBar3DChart() throws JRException 
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createBarChart3D(
					evaluateTextExpression(getChart().getTitleExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
					(CategoryDataset)getDataset(),
					getPlot().getOrientationValue().getOrientation(),
					isShowLegend(),
					true,
					false );

		configureChart(jfreeChart);

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

		BarRenderer3D barRenderer3D =
			new BarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);

		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		barRenderer3D.setBaseItemLabelsVisible( isShowLabels );
		if (isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();

			barRenderer3D.setBaseItemLabelFont(
				fontUtil.getAwtFont(
					getFont(itemLabel == null ? null : itemLabel.getFont()), 
					getLocale()
					)
				);
			
			if (itemLabel != null)
			{
				if (itemLabel.getColor() != null)
				{
					barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if (itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
					barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}

		categoryPlot.setRenderer(barRenderer3D);
		
		// Handle the axis formating for the category axis
		configureAxis(categoryPlot.getDomainAxis(), bar3DPlot.getCategoryAxisLabelFont(),
				bar3DPlot.getCategoryAxisLabelColor(), bar3DPlot.getCategoryAxisTickLabelFont(),
				bar3DPlot.getCategoryAxisTickLabelColor(), bar3DPlot.getCategoryAxisTickLabelMask(), bar3DPlot.getCategoryAxisVerticalTickLabels(),
				bar3DPlot.getCategoryAxisLineColor(), 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.getValueAxisLineColor(), true,
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()),
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression()));
				
		return jfreeChart;
	}
 
Example 9
Source File: GenericChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createBar3DChart() throws JRException 
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createBarChart3D(
					evaluateTextExpression(getChart().getTitleExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
					(CategoryDataset)getDataset(),
					getPlot().getOrientationValue().getOrientation(),
					isShowLegend(),
					true,
					false );

		configureChart(jfreeChart, getPlot());

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

		BarRenderer3D barRenderer3D =
			new BarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);

		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		barRenderer3D.setBaseItemLabelsVisible( isShowLabels );
		if (isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();
			Integer baseFontSize = (Integer)getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.BASEFONT_SIZE);
			JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
			barRenderer3D.setBaseItemLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));
			
			if (itemLabel != null)
			{
				if (itemLabel.getColor() != null)
				{
					barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if (itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
					barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}

		categoryPlot.setRenderer(barRenderer3D);
		
		// 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;
	}
 
Example 10
Source File: SimpleChartTheme.java    From jasperreports with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected JFreeChart createBar3DChart() throws JRException 
	{
		ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
		JFreeChart jfreeChart =
			ChartFactory.createBarChart3D(
					evaluateTextExpression(getChart().getTitleExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getCategoryAxisLabelExpression()),
					evaluateTextExpression(((JRBar3DPlot)getPlot()).getValueAxisLabelExpression()),
					(CategoryDataset)getDataset(),
					getPlot().getOrientationValue().getOrientation(),
					isShowLegend(),
					true,
					false );

		configureChart(jfreeChart, getPlot());

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

		BarRenderer3D barRenderer3D =
			new BarRenderer3D(
				bar3DPlot.getXOffsetDouble() == null ? BarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(),
				bar3DPlot.getYOffsetDouble() == null ? BarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()
				);

		boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
		barRenderer3D.setBaseItemLabelsVisible( isShowLabels );
		if (isShowLabels)
		{
			JRItemLabel itemLabel = bar3DPlot.getItemLabel();
			JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : new JRBaseFont(getChart(), null);
			barRenderer3D.setBaseItemLabelFont(getFontUtil().getAwtFont(font, getLocale()));
			if (itemLabel != null)
			{
				if (itemLabel.getColor() != null)
				{
					barRenderer3D.setBaseItemLabelPaint(itemLabel.getColor());
				}
				else
				{
					barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
				}
//				categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
//				if (itemLabel.getMask() != null)
//				{
//					barRenderer3D.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
//							StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
//							new DecimalFormat(itemLabel.getMask())));
//				}
//				else
//				{
					barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
//				}
			}
			else
			{
				barRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator)getLabelGenerator());
				barRenderer3D.setBaseItemLabelPaint(getChart().getForecolor());
			}
		}

		categoryPlot.setRenderer(barRenderer3D);
		
		// 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(), getDomainAxisSettings(),
				(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(), getRangeAxisSettings(),
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMinValueExpression()), 
				(Comparable<?>)evaluateExpression(bar3DPlot.getRangeAxisMaxValueExpression())
				);
		
		return jfreeChart;
	}