org.jfree.data.xy.XYBarDataset Java Examples
The following examples show how to use
org.jfree.data.xy.XYBarDataset.
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: HistogramChartFactory.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example #2
Source File: XYBarDatasetTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); DefaultXYDataset d2 = new DefaultXYDataset(); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d2.addSeries("S1", data2); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); XYBarDataset bd2 = new XYBarDataset(d2, 5.0); assertTrue(bd1.equals(bd2)); assertTrue(bd2.equals(bd1)); }
Example #3
Source File: XYBarChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); // create the chart... return ChartFactory.createXYBarChart( "XY Bar Chart", // chart title "Domain", false, "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); }
Example #4
Source File: XYBarDatasetTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); DefaultXYDataset d2 = new DefaultXYDataset(); double[] x2 = new double[] {1.0, 2.0, 3.0}; double[] y2 = new double[] {4.0, 5.0, 6.0}; double[][] data2 = new double[][] {x2, y2}; d2.addSeries("S1", data2); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); XYBarDataset bd2 = new XYBarDataset(d2, 5.0); assertTrue(bd1.equals(bd2)); assertTrue(bd2.equals(bd1)); }
Example #5
Source File: HistogramChartFactory.java From old-mzmine3 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example #6
Source File: HistogramChartFactory.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
public static JFreeChart createHistogram(XYSeries series, double barwidth, String yAxisLabel) { XYSeriesCollection xydata = new XYSeriesCollection(series); XYBarDataset dataset = new XYBarDataset(xydata, barwidth); JFreeChart chart = ChartFactory.createXYBarChart("", yAxisLabel, false, "n", dataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = chart.getXYPlot(); chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); xybarrenderer.setDrawBarOutline(false); return chart; }
Example #7
Source File: XYBarChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); // create the chart... return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset, true); }
Example #8
Source File: XYBarRendererTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ @Test public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #9
Source File: XYBarChartTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset); }
Example #10
Source File: XYBarChartTest.java From buffer_bci with GNU General Public License v3.0 | 5 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset); }
Example #11
Source File: XYBarRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #12
Source File: XYBarDatasetTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { DefaultXYDataset d1 = new DefaultXYDataset(); double[] x1 = new double[] {1.0, 2.0, 3.0}; double[] y1 = new double[] {4.0, 5.0, 6.0}; double[][] data1 = new double[][] {x1, y1}; d1.addSeries("S1", data1); XYBarDataset bd1 = new XYBarDataset(d1, 5.0); assertTrue(bd1 instanceof PublicCloneable); }
Example #13
Source File: XYBarRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #14
Source File: XYBarRendererTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ @Test public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #15
Source File: XYBarChartTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset); }
Example #16
Source File: ChartFactory.java From graylog-plugin-aggregates with GNU General Public License v3.0 | 5 votes |
public static JFreeChart generateTimeSeriesChart(String title, List<HistoryAggregateItem> history, String timespan, Calendar cal) throws ParseException { TimeSeries series = initializeSeries(timespan, cal, history); TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); IntervalXYDataset idataset = new XYBarDataset(dataset, 1); JFreeChart chart = org.jfree.chart.ChartFactory.createXYBarChart( title, // Title "Date/time", // X-axis Label true, "Hits", // Y-axis Label idataset, // Dataset PlotOrientation.VERTICAL, true, // Show legend true, // Use tooltips false // Generate URLs ); chart.setBackgroundPaint(Color.WHITE); chart.setBorderPaint(Color.BLACK); XYPlot plot = (XYPlot)chart.getPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.getRenderer().setSeriesPaint(0, Color.BLUE); plot.setDomainGridlinePaint(Color.GRAY); plot.setRangeGridlinePaint(Color.GRAY); chart.removeLegend(); return chart; }
Example #17
Source File: XYBarRendererTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ @Test public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #18
Source File: XYBarChartTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset); }
Example #19
Source File: XYBarRendererTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ @Test public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #20
Source File: XYBarChartTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Create a horizontal bar chart with sample data in the range -3 to +3. * * @return The chart. */ private static JFreeChart createChart() { XYSeries series1 = new XYSeries("Series 1"); series1.add(1.0, 1.0); series1.add(2.0, 2.0); series1.add(3.0, 3.0); IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( series1), 1.0); return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, "Range", dataset); }
Example #21
Source File: XYBarRendererTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * A check for the datasetIndex and seriesIndex fields in the LegendItem * returned by the getLegendItem() method. */ @Test public void testGetLegendItemSeriesIndex() { XYSeriesCollection d1 = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); XYSeries s2 = new XYSeries("S2"); s2.add(1.0, 1.1); d1.addSeries(s1); d1.addSeries(s2); XYSeriesCollection d2 = new XYSeriesCollection(); XYSeries s3 = new XYSeries("S3"); s3.add(1.0, 1.1); XYSeries s4 = new XYSeries("S4"); s4.add(1.0, 1.1); XYSeries s5 = new XYSeries("S5"); s5.add(1.0, 1.1); d2.addSeries(s3); d2.addSeries(s4); d2.addSeries(s5); XYBarRenderer r = new XYBarRenderer(); XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, new XYBarDataset(d2, 2.0)); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example #22
Source File: ExtendedIsotopePatternDataSet.java From mzmine2 with GNU General Public License v2.0 | 2 votes |
public XYBarDataset getBarDataset(double mergeWidth) { return new XYBarDataset((XYSeriesCollection) this, mergeWidth); }
Example #23
Source File: ExtendedIsotopePatternDataSet.java From mzmine3 with GNU General Public License v2.0 | 2 votes |
public XYBarDataset getBarDataset(double mergeWidth) { return new XYBarDataset((XYSeriesCollection) this, mergeWidth); }