org.jfree.data.xy.XYSeriesCollection Java Examples
The following examples show how to use
org.jfree.data.xy.XYSeriesCollection.
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: XYPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
@Test public void testMapDatasetToDomainAxis() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); NumberAxis xAxis2 = new NumberAxis("X2"); plot.setDomainAxis(11, xAxis2); // add a second dataset XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); assertEquals(xAxis, plot.getDomainAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToDomainAxis(99, 11); assertEquals(xAxis2, plot.getDomainAxisForDataset(99)); }
Example #2
Source File: XYPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * A test to reproduce a bug in serialization: the domain and/or range * markers for a plot are not being serialized. */ @Test public void testSerialization4() { XYSeriesCollection dataset = new XYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart("Test Chart", "Domain Axis", "Range Axis", dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND); plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND); plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND); JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart); assertEquals(chart, chart2); try { chart2.createBufferedImage(300, 200); } catch (Exception e) { fail("No exception should be thrown."); } }
Example #3
Source File: StandardXYItemRendererTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * A check to ensure that an item that falls outside the plot's data area * does NOT generate an item entity. */ public void testNoDisplayedItem() { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries s1 = new XYSeries("S1"); s1.add(10.0, 10.0); dataset.addSeries(s1); JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", dataset, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setRenderer(new StandardXYItemRenderer()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setRange(0.0, 5.0); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setRange(0.0, 5.0); BufferedImage image = new BufferedImage(200 , 100, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = image.createGraphics(); ChartRenderingInfo info = new ChartRenderingInfo(); chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info); g2.dispose(); EntityCollection ec = info.getEntityCollection(); assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), XYItemEntity.class)); }
Example #4
Source File: FXChartGestureDemo.java From mzmine3 with GNU General Public License v2.0 | 6 votes |
/** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset. */ private static XYDataset createDataset() { XYSeriesCollection data = new XYSeriesCollection(); Random r = new Random(System.currentTimeMillis()); for (int i = 0; i < 3; i++) { XYSeries s = new XYSeries("Series" + i); for (int x = 0; x < 100; x++) { double v = r.nextGaussian() * (i + 1); s.add(x, v); } data.addSeries(s); } return data; }
Example #5
Source File: DatasetUtilitiesTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Creates a dataset for testing. * * @return A dataset. */ private XYDataset createXYDataset1() { XYSeries series1 = new XYSeries("S1"); series1.add(1.0, 100.0); series1.add(2.0, 101.0); series1.add(3.0, 102.0); XYSeries series2 = new XYSeries("S2"); series2.add(1.0, 103.0); series2.add(2.0, null); series2.add(3.0, 105.0); XYSeriesCollection result = new XYSeriesCollection(); result.addSeries(series1); result.addSeries(series2); result.setIntervalWidth(0.0); return result; }
Example #6
Source File: MarketDepthModel.java From computational-economy with GNU General Public License v3.0 | 6 votes |
public XYDataset getMarketDepthDataset(final Currency currency, final GoodType goodType) { final XYSeries series = new XYSeries(goodType + " ask"); final Iterator<MarketOrder> iterator = ApplicationContext.getInstance().getMarketOrderDAO() .getIteratorThreadsafe(currency, goodType); double volume = 0.0; while (iterator.hasNext()) { final MarketOrder marketOrder = iterator.next(); volume += marketOrder.getAmount(); // volume available at that price per unit or less series.add(marketOrder.getPricePerUnit(), volume); } final XYSeriesCollection dataset = new XYSeriesCollection(); dataset.removeAllSeries(); dataset.addSeries(series); return dataset; }
Example #7
Source File: LogAxisTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example #8
Source File: RegressionTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Checks the results of a power regression on sample dataset 2 AFTER * converting it to an XYSeries. */ @Test public void testPowerRegression2b() { double[][] data = createSampleData2(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 10; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result = Regression.getPowerRegression(ds, 0); assertEquals(106.1241681, result[0], 0.0000001); assertEquals(-0.8466615, result[1], 0.0000001); }
Example #9
Source File: LogAxisTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example #10
Source File: CombinedRangeXYPlotTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { // create dataset 2... XYSeries series2 = new XYSeries("Series 3"); series2.add(10.0, 16853.2); series2.add(20.0, 19642.3); series2.add(30.0, 18253.5); series2.add(40.0, 15352.3); series2.add(50.0, 13532.0); series2.add(100.0, 12635.3); series2.add(110.0, 13998.2); series2.add(120.0, 11943.2); series2.add(130.0, 16943.9); series2.add(140.0, 17843.2); series2.add(150.0, 16495.3); series2.add(160.0, 17943.6); series2.add(170.0, 18500.7); series2.add(180.0, 19595.9); return new XYSeriesCollection(series2); }
Example #11
Source File: XYPlotTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getRendererForDataset() method. */ public void testGetRendererForDataset() { XYDataset d0 = new XYSeriesCollection(); XYDataset d1 = new XYSeriesCollection(); XYDataset d2 = new XYSeriesCollection(); XYDataset d3 = new XYSeriesCollection(); // not used by plot XYItemRenderer r0 = new XYLineAndShapeRenderer(); XYItemRenderer r2 = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(); plot.setDataset(0, d0); plot.setDataset(1, d1); plot.setDataset(2, d2); plot.setRenderer(0, r0); // no renderer 1 plot.setRenderer(2, r2); assertEquals(r0, plot.getRendererForDataset(d0)); assertEquals(r0, plot.getRendererForDataset(d1)); assertEquals(r2, plot.getRendererForDataset(d2)); assertEquals(null, plot.getRendererForDataset(d3)); assertEquals(null, plot.getRendererForDataset(null)); }
Example #12
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 #13
Source File: SwingChartGestureDemo.java From mzmine2 with GNU General Public License v2.0 | 6 votes |
/** * Creates a dataset, consisting of two series of monthly data. * * @return the dataset. */ private static XYDataset createDataset() { XYSeriesCollection data = new XYSeriesCollection(); Random r = new Random(System.currentTimeMillis()); for (int i = 0; i < 3; i++) { XYSeries s = new XYSeries("Series" + i); for (int x = 0; x < 100; x++) { double v = r.nextGaussian() * (i + 1); s.add(x, v); } data.addSeries(s); } return data; }
Example #14
Source File: LogAxisTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example #15
Source File: NumberAxisTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange2() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); assertEquals(0.9, axis.getLowerBound(), EPSILON); assertEquals(3.1, axis.getUpperBound(), EPSILON); }
Example #16
Source File: XYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testRendererIndices() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); assertEquals(renderer, plot.getRenderer(0)); // we should be able to give a renderer an arbitrary index XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); plot.setRenderer(20, renderer2); assertEquals(2, plot.getRendererCount()); assertEquals(renderer2, plot.getRenderer(20)); assertEquals(20, plot.getIndexOf(renderer2)); }
Example #17
Source File: XYStepAreaChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); }
Example #18
Source File: XYPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
@Test public void testMapDatasetToDomainAxis() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); NumberAxis xAxis2 = new NumberAxis("X2"); plot.setDomainAxis(11, xAxis2); // add a second dataset XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); assertEquals(xAxis, plot.getDomainAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToDomainAxis(99, 11); assertEquals(xAxis2, plot.getDomainAxisForDataset(99)); }
Example #19
Source File: XYLineAndShapeRendererTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Check that the renderer is calculating the domain bounds correctly. */ @Test public void testFindDomainBounds() { XYSeriesCollection dataset = RendererXYPackageUtils.createTestXYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); Range bounds = domainAxis.getRange(); assertFalse(bounds.contains(0.9)); assertTrue(bounds.contains(1.0)); assertTrue(bounds.contains(2.0)); assertFalse(bounds.contains(2.10)); }
Example #20
Source File: XYPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
@Test public void testAxisLocationIndices() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); NumberAxis xAxis2 = new NumberAxis("X2"); NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setDomainAxis(99, xAxis2); plot.setRangeAxis(99, yAxis2); plot.setDomainAxisLocation(99, AxisLocation.BOTTOM_OR_RIGHT); assertEquals(AxisLocation.BOTTOM_OR_RIGHT, plot.getDomainAxisLocation(99)); plot.setRangeAxisLocation(99, AxisLocation.BOTTOM_OR_LEFT); assertEquals(AxisLocation.BOTTOM_OR_LEFT, plot.getRangeAxisLocation(99)); }
Example #21
Source File: PolarPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getLegendItems() method. */ @Test public void testGetLegendItems() { XYSeriesCollection d = new XYSeriesCollection(); d.addSeries(new XYSeries("A")); d.addSeries(new XYSeries("B")); DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); PolarPlot plot = new PolarPlot(); plot.setDataset(d); plot.setRenderer(r); LegendItemCollection items = plot.getLegendItems(); assertEquals(2, items.getItemCount()); LegendItem item1 = items.get(0); assertEquals("A", item1.getLabel()); LegendItem item2 = items.get(1); assertEquals("B", item2.getLabel()); }
Example #22
Source File: DatasetUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Creates a dataset for testing. * * @return A dataset. */ private XYDataset createXYDataset1() { XYSeries series1 = new XYSeries("S1"); series1.add(1.0, 100.0); series1.add(2.0, 101.0); series1.add(3.0, 102.0); XYSeries series2 = new XYSeries("S2"); series2.add(1.0, 103.0); series2.add(2.0, null); series2.add(3.0, 105.0); XYSeriesCollection result = new XYSeriesCollection(); result.addSeries(series1); result.addSeries(series2); result.setIntervalWidth(0.0); return result; }
Example #23
Source File: XYAreaChartTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Replaces the dataset and checks that it has changed as expected. */ public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); }
Example #24
Source File: XYLineAndShapeRendererTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Check that the renderer is calculating the domain bounds correctly. */ @Test public void testFindDomainBounds() { XYSeriesCollection dataset = RendererXYPackageUtils.createTestXYSeriesCollection(); JFreeChart chart = ChartFactory.createXYLineChart( "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); Range bounds = domainAxis.getRange(); assertFalse(bounds.contains(0.9)); assertTrue(bounds.contains(1.0)); assertTrue(bounds.contains(2.0)); assertFalse(bounds.contains(2.10)); }
Example #25
Source File: XYPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Datasets are now stored in a Map, and it should be possible to assign * them an arbitrary key (index). */ @Test public void testDatasetIndices() { XYDataset dataset = new XYSeriesCollection(); NumberAxis xAxis = new NumberAxis("X"); NumberAxis yAxis = new NumberAxis("Y"); XYItemRenderer renderer = new DefaultXYItemRenderer(); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); assertEquals(dataset, plot.getDataset(0)); XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); // we should be able to give a dataset an arbitrary index plot.setDataset(99, dataset2); assertEquals(2, plot.getDatasetCount()); assertEquals(dataset2, plot.getDataset(99)); assertEquals(0, plot.indexOf(dataset)); assertEquals(99, plot.indexOf(dataset2)); }
Example #26
Source File: XYLineChartTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Replaces the dataset and checks that it has changed as expected. */ @Test public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); }
Example #27
Source File: ScatterPlotTest.java From ECG-Viewer with GNU General Public License v2.0 | 6 votes |
/** * Replaces the dataset and checks that it has changed as expected. */ @Test public void testReplaceDataset() { // create a dataset... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 10.0); series1.add(20.0, 20.0); series1.add(30.0, 30.0); XYDataset dataset = new XYSeriesCollection(series1); LocalListener l = new LocalListener(); this.chart.addChangeListener(l); XYPlot plot = (XYPlot) this.chart.getPlot(); plot.setDataset(dataset); assertEquals(true, l.flag); ValueAxis axis = plot.getRangeAxis(); Range range = axis.getRange(); assertTrue("Expecting the lower bound of the range to be around 10: " + range.getLowerBound(), range.getLowerBound() <= 10); assertTrue("Expecting the upper bound of the range to be around 30: " + range.getUpperBound(), range.getUpperBound() >= 30); }
Example #28
Source File: LogAxisTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Checks that the auto-range for the domain axis on an XYPlot is * working as expected. */ @Test public void testXYAutoRange1() { XYSeries series = new XYSeries("Series 1"); series.add(1.0, 1.0); series.add(2.0, 2.0); series.add(3.0, 3.0); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", dataset); XYPlot plot = (XYPlot) chart.getPlot(); LogAxis axis = new LogAxis("Log(Y)"); plot.setRangeAxis(axis); assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); }
Example #29
Source File: XYStepChartTest.java From ccu-historian with GNU General Public License v3.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); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createXYStepChart( "Step Chart", // chart title "Domain", "Range", dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips true // urls ); }
Example #30
Source File: RegressionTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
/** * Checks the results of an OLS regression on sample dataset 1 AFTER * converting it to an XYSeries. */ @Test public void testOLSRegression1b() { double[][] data = createSampleData1(); XYSeries series = new XYSeries("Test"); for (int i = 0; i < 11; i++) { series.add(data[i][0], data[i][1]); } XYDataset ds = new XYSeriesCollection(series); double[] result2 = Regression.getOLSRegression(ds, 0); assertEquals(.25680930, result2[0], 0.0000001); assertEquals(0.72792106, result2[1], 0.0000001); }