List of usage examples for org.jfree.chart.renderer.category StackedBarRenderer3D setBaseItemLabelGenerator
@Override public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator)
From source file:org.jfree.chart.demo.StackedBarChart3DDemo2.java
private JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("Stacked Bar Chart 3D Demo 2", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer(); stackedbarrenderer3d.setRenderAsPercentages(true); stackedbarrenderer3d.setDrawBarOutline(false); stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%"))); stackedbarrenderer3d.setBaseItemLabelsVisible(true); stackedbarrenderer3d//from www . j a v a 2s . co m .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); return jfreechart; }
From source file:org.jfree.chart.demo.StackedBarChart3DDemo4.java
private JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D("Stacked Bar Chart 3D Demo 4", "Category", "Value", categorydataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer(); stackedbarrenderer3d.setRenderAsPercentages(true); stackedbarrenderer3d.setDrawBarOutline(false); stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%"))); stackedbarrenderer3d.setBaseItemLabelsVisible(true); stackedbarrenderer3d// ww w . ja v a 2 s .c o m .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); return jfreechart; }
From source file:org.sonar.plugins.scmstats.charts.StackedBarChart3D.java
private JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createStackedBarChart3D(null, "Authors", "Activity", categorydataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setNumberFormatOverride(new DecimalFormat("0%")); StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer(); stackedbarrenderer3d.setRenderAsPercentages(true); stackedbarrenderer3d.setDrawBarOutline(false); stackedbarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%"))); stackedbarrenderer3d.setBaseItemLabelsVisible(true); stackedbarrenderer3d//from w w w . j av a2 s .c o m .setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d .setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); stackedbarrenderer3d.setSeriesPaint(0, Color.decode("#66CD00")); stackedbarrenderer3d.setSeriesPaint(1, Color.decode("#4F94CD")); stackedbarrenderer3d.setSeriesPaint(2, Color.decode("#FF4040")); return jfreechart; }
From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java
/** * *//*from w w w. ja va2 s. c o m*/ 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; }
From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java
/** * *///from w w w. j a v a 2 s. co m 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(), 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; }
From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java
/** * *//*from ww w. j a v a 2 s. c o m*/ protected JFreeChart createStackedBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedBarChart3D( 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(); StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(), bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels(); stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); stackedBarRenderer3D.setBaseItemLabelFont( fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null) { if (itemLabel.getColor() != null) { stackedBarRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { stackedBarRenderer3D.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 // { stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } 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.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; }
From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java
/** * *///from w w w . jav a 2 s .c om protected JFreeChart createStackedBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedBarChart3D( 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(); StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(), bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels(); stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); stackedBarRenderer3D.setBaseItemLabelFont( getFontUtil().getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null) { if (itemLabel.getColor() != null) { stackedBarRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { stackedBarRenderer3D.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 // { stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } 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; }
From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java
/** * *///from w w w. j av a 2s .c om protected JFreeChart createStackedBar3DChart() throws JRException { ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme()); JFreeChart jfreeChart = ChartFactory.createStackedBarChart3D( 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(); StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D( bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET : bar3DPlot.getXOffsetDouble(), bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET : bar3DPlot.getYOffsetDouble()); boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels(); stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels); if (isShowLabels) { JRItemLabel itemLabel = bar3DPlot.getItemLabel(); stackedBarRenderer3D.setBaseItemLabelFont( getFontUtil().getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale())); if (itemLabel != null) { if (itemLabel.getColor() != null) { stackedBarRenderer3D.setBaseItemLabelPaint(itemLabel.getColor()); } else { stackedBarRenderer3D.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 // { stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); // } } else { stackedBarRenderer3D.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator()); stackedBarRenderer3D.setBaseItemLabelPaint(getChart().getForecolor()); } } 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(), 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; }