List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:net.sf.dynamicreports.design.transformation.chartcustomizer.ShowPercentagesCustomizer.java
@Override public void customize(JFreeChart chart, ReportParameters reportParameters) { if (chart.getPlot() instanceof CategoryPlot) { if (chart.getCategoryPlot().getDataset() != null) { CategoryDataset dataset;/* ww w . j av a2s . c om*/ if (!(chart.getCategoryPlot().getRenderer() instanceof GroupedStackedBarRenderer)) { dataset = new PercentageCategoryDataset(chart.getCategoryPlot().getDataset()); } else { dataset = new PercentageGroupedCategoryDataset(chart.getCategoryPlot().getDataset()); } chart.getCategoryPlot().setDataset(dataset); } if (StringUtils.isBlank(chart.getCategoryPlot().getRangeAxis().getLabel())) { chart.getCategoryPlot().getRangeAxis().setLabel("%"); } } }
From source file:ca.sqlpower.wabit.swingui.chart.effect.BarChartAnimatorFactory.java
public boolean canAnimate(JFreeChart chart) { if (!(chart.getPlot() instanceof CategoryPlot)) { return false; }// w w w . j a v a2s . c om CategoryPlot cplot = chart.getCategoryPlot(); if (cplot.getDatasetCount() != 1) { return false; } if (!(cplot.getDataset() instanceof DefaultCategoryDataset)) { return false; } return true; }
From source file:org.apache.qpid.disttest.charting.chartbuilder.StatisticalBarChartBuilder.java
@Override public JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) { CategoryAxis xAxis = new CategoryAxis(xAxisTitle); ValueAxis yAxis = new NumberAxis(yAxisTitle); CategoryItemRenderer renderer = new StatisticalBarRenderer(); CategoryPlot plot = new CategoryPlot((StatisticalCategoryDataset) dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart(title, new Font("Arial", Font.PLAIN, 10), plot, true); chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); return chart; }
From source file:gov.nih.nci.caintegrator.application.geneexpression.GeneExpressionPlotServiceImpl.java
private void customizeAxisMargin(JFreeChart chart) { CategoryAxis axis = chart.getCategoryPlot().getDomainAxis(); axis.setLowerMargin(LOWER_MARGIN);/*from www . j av a2s .c o m*/ axis.setCategoryMargin(CATEGORY_MARGIN); axis.setUpperMargin(UPPER_MARGIN); }
From source file:javaapplication2.BarChart3D.java
public BarChart3D(String applicationTitle, String chartTitle) throws ClassNotFoundException, SQLException, IOException { super(applicationTitle); JFreeChart barChart = ChartFactory.createBarChart3D(chartTitle, "Notas", "Porcentagem de votos.", createDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = barChart.getCategoryPlot(); plot.getRangeAxis().setRange(0, 100); ChartPanel chartPanel = new ChartPanel(barChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); setContentPane(chartPanel);//from w w w .ja v a 2 s . co m this.setExtendedState(BarChart3D.MAXIMIZED_BOTH); //ChartUtilities.saveChartAsJPEG(new File("C:/Users/Public/Pictures/Barchart.jpg"), barChart, 956, 538); }
From source file:net.sf.dynamicreports.test.jasper.chart.AreaChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from www. j ava2 s .c om JFreeChart chart = getChart("summary.chart1", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", AreaRenderer.class, categoryPlot.getRenderer().getClass()); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions() .getLabelPosition(RectangleEdge.LEFT); Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart2", 0); axis = chart.getCategoryPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:net.sf.dynamicreports.test.jasper.chart.StackedAreaChartTest.java
@Override public void test() { super.test(); numberOfPagesTest(1);//from ww w. j a v a2 s .c om JFreeChart chart = getChart("summary.chart1", 0); Axis axis = chart.getCategoryPlot().getDomainAxis(); CategoryPlot categoryPlot = chart.getCategoryPlot(); Assert.assertEquals("renderer", StackedAreaRenderer.class, categoryPlot.getRenderer().getClass()); Assert.assertEquals("category label", "category", axis.getLabel()); Assert.assertEquals("category label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("category label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); CategoryLabelPosition labelPosition = chart.getCategoryPlot().getDomainAxis().getCategoryLabelPositions() .getLabelPosition(RectangleEdge.LEFT); Assert.assertEquals("plot label rotation", (45d / 180) * Math.PI, labelPosition.getAngle()); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); chart = getChart("summary.chart2", 0); axis = chart.getCategoryPlot().getRangeAxis(); Assert.assertEquals("value label", "value", axis.getLabel()); Assert.assertEquals("value label color", Color.BLUE, axis.getLabelPaint()); Assert.assertEquals("value label font", new Font("Arial", Font.BOLD, 10), axis.getLabelFont()); Assert.assertEquals("tick label color", Color.CYAN, axis.getTickLabelPaint()); Assert.assertEquals("tick label font", new Font("Arial", Font.ITALIC, 10), axis.getTickLabelFont()); Assert.assertEquals("tick label mask", "10.00", ((NumberAxis) axis).getNumberFormatOverride().format(10)); Assert.assertEquals("line color", Color.LIGHT_GRAY, axis.getAxisLinePaint()); Assert.assertEquals("range min value", 1d, ((ValueAxis) axis).getLowerBound()); Assert.assertEquals("range max value", 15d, ((ValueAxis) axis).getUpperBound()); }
From source file:org.pentaho.chart.plugin.jfreechart.chart.bar.JFreeCylinderBarChartGenerator.java
/** * Creates cylinder bar chart and creates range axis for it. </p> * * @param chartDocContext Current chart's document context * @param data Current chart data * @return Returns JFreeChart object that is a layered bar chart. *//*from www . j a v a2 s . c o m*/ protected JFreeChart doCreateChart(final ChartDocumentContext chartDocContext, final ChartTableModel data) { final JFreeChart chart = createChart(chartDocContext, data, JFreeBarChartTypes.DEFAULT); final CylinderRenderer renderer = new CylinderRenderer(); chart.getCategoryPlot().setRenderer(renderer); /* * Doing all the render stuff and then off to create range axis. * NOTE: The chart object will be updated. */ createRangeAxis(chartDocContext, data, chart); return chart; }
From source file:org.pentaho.plugin.jfreereport.reportcharts.AreaChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final CategoryPlot cpl = chart.getCategoryPlot(); cpl.getDomainAxis().setCategoryMargin(0.0); final CategoryItemRenderer renderer = cpl.getRenderer(); if ((isStacked()) && renderAsPercentages && (renderer instanceof StackedAreaRenderer)) { final StackedAreaRenderer sbr = (StackedAreaRenderer) renderer; sbr.setRenderAsPercentages(true); }//w w w . j a v a 2s. c o m }
From source file:org.pentaho.plugin.jfreereport.reportcharts.LineChartExpression.java
protected void configureChart(final JFreeChart chart) { super.configureChart(chart); final CategoryPlot cpl = chart.getCategoryPlot(); final CategoryItemRenderer renderer = cpl.getRenderer(); renderer.setStroke(translateLineStyle(lineWidth, lineStyle)); if (renderer instanceof LineAndShapeRenderer) { final LineAndShapeRenderer shapeRenderer = (LineAndShapeRenderer) renderer; shapeRenderer.setShapesVisible(isMarkersVisible()); shapeRenderer.setBaseShapesFilled(isMarkersVisible()); }/*from w w w. j a v a 2 s. c o m*/ }