List of usage examples for org.jfree.chart.renderer.category StatisticalBarRenderer StatisticalBarRenderer
public StatisticalBarRenderer()
From source file:org.jfree.chart.demo.StatisticalBarChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setAutoRangeIncludesZero(false); StatisticalBarRenderer statisticalbarrenderer = new StatisticalBarRenderer(); statisticalbarrenderer.setErrorIndicatorPaint(Color.black); statisticalbarrenderer.setIncludeBaseInRange(false); categoryplot.setRenderer(statisticalbarrenderer); statisticalbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); statisticalbarrenderer.setBaseItemLabelsVisible(true); statisticalbarrenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER)); return jfreechart; }
From source file:org.jfree.graphics2d.demo.SVGBarChartDemo1.java
/** * Creates a sample chart.// ww w .ja v a 2s . c o m * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setDrawBarOutline(false); renderer.setErrorIndicatorPaint(Color.black); renderer.setIncludeBaseInRange(false); plot.setRenderer(renderer); // ensure the current theme is applied to the renderer just added ChartUtilities.applyCurrentTheme(chart); renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultItemLabelPaint(Color.yellow); renderer.setDefaultPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER)); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); return chart; }
From source file:com.orsonpdf.demo.PDFBarChartDemo1.java
/** * Creates a sample chart./*from ww w . j a v a 2s . c o m*/ * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", "Type", "Value", dataset, PlotOrientation.VERTICAL, true, false, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setDrawBarOutline(false); renderer.setErrorIndicatorPaint(Color.black); renderer.setIncludeBaseInRange(false); plot.setRenderer(renderer); // ensure the current theme is applied to the renderer just added ChartUtilities.applyCurrentTheme(chart); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.yellow); renderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER)); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); return chart; }
From source file:org.jfree.graphics2d.demo.CanvasBarChartDemo1.java
/** * Creates a sample chart./*from ww w . j a v a 2 s . c o m*/ * * @param dataset a dataset. * * @return The chart. */ private static JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart("Statistical Bar Chart Demo 1", // chart title "Type", // domain axis label "Value", // range axis label dataset); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setDrawBarOutline(false); renderer.setErrorIndicatorPaint(Color.black); renderer.setIncludeBaseInRange(false); plot.setRenderer(renderer); // ensure the current theme is applied to the renderer just added ChartUtilities.applyCurrentTheme(chart); renderer.setDefaultItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setDefaultItemLabelsVisible(true); renderer.setDefaultItemLabelPaint(Color.yellow); renderer.setDefaultPositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.INSIDE6, TextAnchor.BOTTOM_CENTER)); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); return chart; }
From source file:org.jfree.chart.demo.StatisticalBarChartDemo.java
/** * Creates a new demo./* w ww. j ava 2 s. c o m*/ * * @param title the frame title. */ public StatisticalBarChartDemo(final String title) { super(title); final StatisticalCategoryDataset dataset = createDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.05d); // percentage of space between categories final ValueAxis yAxis = new NumberAxis("Value"); // define the plot final CategoryItemRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Statistical Bar Chart Demo", new Font("Helvetica", Font.BOLD, 14), plot, true); //chart.setBackgroundPaint(Color.white); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.aksw.iguana.reborn.charts.datasets.StatisticalBarChartDemo.java
/** * Creates a new demo./*from ww w . j a v a 2 s .co m*/ * * @param title * the frame title. * @throws DocumentException * @throws FileNotFoundException */ public StatisticalBarChartDemo(final String title) throws FileNotFoundException, DocumentException { super(title); final StatisticalCategoryDataset dataset = createDataset(); final CategoryAxis xAxis = new CategoryAxis("Type"); xAxis.setLowerMargin(0.01d); // percentage of space before first bar xAxis.setUpperMargin(0.01d); // percentage of space after last bar xAxis.setCategoryMargin(0.05d); // percentage of space between // categories final ValueAxis yAxis = new NumberAxis("Value"); // define the plot final CategoryItemRenderer renderer = new StatisticalBarRenderer(); final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); final JFreeChart chart = new JFreeChart("Statistical Bar Chart Demo", new Font("Helvetica", Font.BOLD, 14), plot, true); ChartUtilities2.saveChartAsPDF(new File("/home/raven/tmp/foo.pdf"), chart, 1000, 300); // chart.setBackgroundPaint(Color.white); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:ui.results.ResultChartPanel.java
/** * Construct new Result panel// w w w.ja v a 2s . com */ public ResultChartPanel() { // The charting objects dataset = new DefaultStatisticalCategoryDataset(); upper = new DefaultCategoryDataset(); lower = new DefaultCategoryDataset(); // The Renderers lineRenderer0 = new LineAndShapeRenderer(); lineRenderer1 = new LineAndShapeRenderer(); lineRenderer2 = new LineAndShapeRenderer(); lineRenderer0.setSeriesPaint(0, lowerColor); lineRenderer1.setSeriesPaint(0, mspColor); lineRenderer2.setSeriesPaint(0, upperColor); lineRenderer0.setSeriesShapesVisible(0, false); lineRenderer1.setSeriesShapesVisible(0, false); lineRenderer2.setSeriesShapesVisible(0, false); barRenderer = new StatisticalBarRenderer(); barRenderer.setSeriesPaint(0, mspColor); // The Plot: begin as a line plot CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(new CategoryAxis("Datasets")); plot.setRangeAxis(new NumberAxis("MSP")); plot.setRenderer(0, lineRenderer0); plot.setRenderer(1, lineRenderer1); plot.setRenderer(2, lineRenderer2); plot.setDataset(0, lower); plot.setDataset(1, dataset); plot.setDataset(2, upper); // Adding the new plot chart = new JFreeChart(plot); panel = new ChartPanel(chart); // Listening to changes //dataset.addChangeListener(chart.getPlot()); chart.getPlot().addChangeListener(chart); chart.addChangeListener(panel); ((CategoryPlot) chart.getPlot()).getRangeAxis().setAutoRange(true); // Choice panel: choicing between line and bar chart JPanel choicePanel = createChoicePanel(); // Doing the interface setLayout(new BorderLayout()); add(choicePanel, BorderLayout.NORTH); add(panel, BorderLayout.CENTER); setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Chart")); // size stuff //setPreferredSize(new Dimension(500, 400)); }
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:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo1.java
/** * Creates a sample chart.//from w ww.ja v a2s. c om * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); // renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo2.java
/** * Creates a sample chart.//from w w w. j av a2 s . co m * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }