Java Code Examples for org.jfree.chart.ChartFactory#createStackedBarChart()
The following examples show how to use
org.jfree.chart.ChartFactory#createStackedBarChart() .
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: SubCategoryAxisTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * A check for the NullPointerException in bug 2275695. */ @Test public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("There should be no exception."); } }
Example 2
Source File: SubCategoryAxisTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * A check for the NullPointerException in bug 2275695. */ @Test public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("There should be no exception."); } }
Example 3
Source File: SubCategoryAxisTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * A check for the NullPointerException in bug 2275695. */ @Test public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("There should be no exception."); } }
Example 4
Source File: DefaultChartService.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
private JFreeChart getStackedBarChart( BaseChart chart, CategoryDataset dataSet, boolean horizontal ) { JFreeChart stackedBarChart = ChartFactory.createStackedBarChart( chart.getName(), chart.getDomainAxisLabel(), chart.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, !chart.isHideLegend(), false, false ); setBasicConfig( stackedBarChart, chart ); CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot(); plot.setOrientation( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL ); plot.setRenderer( getStackedBarRenderer() ); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); return stackedBarChart; }
Example 5
Source File: ChartImageGenerator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
private JFreeChart getStackedBarChart( final Visualization visualization, CategoryDataset dataSet, boolean horizontal ) { JFreeChart stackedBarChart = ChartFactory.createStackedBarChart( visualization.getName(), visualization.getDomainAxisLabel(), visualization.getRangeAxisLabel(), dataSet, PlotOrientation.VERTICAL, !visualization.isHideLegend(), false, false ); setBasicConfig( stackedBarChart, visualization ); CategoryPlot plot = (CategoryPlot) stackedBarChart.getPlot(); plot.setOrientation( horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL ); plot.setRenderer( getStackedBarRenderer() ); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions( CategoryLabelPositions.UP_45 ); return stackedBarChart; }
Example 6
Source File: ChartJFreeChartOutputHistogram.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void createChart(final IScope scope) { super.createChart(scope); jfreedataset.add(0, new DefaultCategoryDataset()); PlotOrientation orientation = PlotOrientation.VERTICAL; if (reverse_axes) { orientation = PlotOrientation.HORIZONTAL; } if (style.equals(IKeyword.THREE_D)) { chart = ChartFactory.createBarChart(getName(), null, null, null, orientation, true, true, false); } else if (style.equals(IKeyword.STACK)) { chart = ChartFactory.createStackedBarChart(getName(), null, null, null, orientation, true, true, false); } else { chart = ChartFactory.createBarChart(getName(), null, null, null, orientation, true, true, false); } }
Example 7
Source File: SubCategoryAxisTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * A check for the NullPointerException in bug 2275695. */ @Test public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("There should be no exception."); } }
Example 8
Source File: SubCategoryAxisTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A check for the NullPointerException in bug 2275695. */ public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, true); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); boolean success = false; try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); success = true; } catch (Exception e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example 9
Source File: StackedBarChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a stacked bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // 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.createStackedBarChart( "Stacked Bar Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.HORIZONTAL, true, // include legend true, true ); }
Example 10
Source File: SubCategoryAxisTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * A check for the NullPointerException in bug 2275695. */ @Test public void test2275695() { JFreeChart chart = ChartFactory.createStackedBarChart("Test", "Category", "Value", null, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); try { BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); g2.dispose(); } catch (Exception e) { fail("There should be no exception."); } }
Example 11
Source File: StackedBarChartTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Create a stacked bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { 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); return ChartFactory.createStackedBarChart("Stacked Bar Chart", "Domain", "Range", dataset, true); }
Example 12
Source File: BarChartExpression.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
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 13
Source File: SchedulePlanningPanel.java From opencards with BSD 2-Clause "Simplified" License | 4 votes |
public SchedulePlanningPanel() { setLayout(new BorderLayout()); // setup the stacked bar chart dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createStackedBarChart( null, // chart title Utils.getRB().getString("CardTableModel.stats.weekSchedule"), // domain axis label // "# cards", // range axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // legend true, // tooltips false // urls ); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); //green renderer.setItemMargin(0.0); Paint greenPaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); renderer.setSeriesPaint(1, greenPaint); renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); //blue Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF)); renderer.setSeriesPaint(0, bluePaint); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); // Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88)); // renderer.setSeriesPaint(1, p2); // renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // // Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); // renderer.setSeriesPaint(2, p3); // renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer); valueAxis = plot.getRangeAxis(); TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits(); valueAxis.setStandardTickUnits(units); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); add(chartPanel, BorderLayout.CENTER); rebuildPanel(new HashSet<CardFile>()); }
Example 14
Source File: LTMStateGraphPanel.java From opencards with BSD 2-Clause "Simplified" License | 4 votes |
public LTMStateGraphPanel() { setLayout(new BorderLayout()); // setup the stacked bar chart dataset = new DefaultCategoryDataset(); final JFreeChart chart = ChartFactory.createStackedBarChart( null, // chart title Utils.getRB().getString("CardTableModel.stats.learnsuccess"), // domain axis label // "# cards", // range axis label null, // range axis label dataset, // data PlotOrientation.VERTICAL, // the plot orientation false, // legend true, // tooltips false // urls ); StackedBarRenderer renderer = new StackedBarRenderer(); renderer.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); renderer.setItemMargin(0.0); Paint bluePaint = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), 0.0f, 0.0f, new Color(0x88, 0x88, 0xFF)); renderer.setSeriesPaint(0, bluePaint); renderer.setSeriesToolTipGenerator(0, new StandardCategoryToolTipGenerator()); // Paint p2 = new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), 0.0f, 0.0f, new Color(0xFF, 0x88, 0x88)); // renderer.setSeriesPaint(1, p2); // renderer.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); // // Paint p3 = new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), 0.0f, 0.0f, new Color(0x88, 0xFF, 0x88)); // renderer.setSeriesPaint(2, p3); // renderer.setSeriesToolTipGenerator(2, new StandardCategoryToolTipGenerator()); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setRenderer(renderer); valueAxis = plot.getRangeAxis(); TickUnits units = (TickUnits) NumberAxis.createIntegerTickUnits(); valueAxis.setStandardTickUnits(units); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPopupMenu(null); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); add(chartPanel, BorderLayout.CENTER); rebuildPanel(new HashSet<CardFile>()); learnedPerfectly = Utils.getRB().getString("CardTableModel.stats.perfect"); learnedNotYet = Utils.getRB().getString("CardTableModel.stats.notatall"); learnedNaJa = Utils.getRB().getString("CardTableModel.stats.well"); }