org.jfree.data.xy.XYSeries Java Examples
The following examples show how to use
org.jfree.data.xy.XYSeries.
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 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 #2
Source File: RegressionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks the results of a power regression on sample dataset 2 AFTER * converting it to an XYSeries. */ 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 #3
Source File: RegressionTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Checks the results of a power regression on sample dataset 1 AFTER * converting it to an XYSeries. */ @Test public void testPowerRegression1b() { 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[] result = Regression.getPowerRegression(ds, 0); assertEquals(0.91045813, result[0], 0.0000001); assertEquals(0.88918346, result[1], 0.0000001); }
Example #4
Source File: DatasetUtilitiesTest.java From ccu-historian with GNU General Public License v3.0 | 6 votes |
/** * Check the findYValue() method with a dataset that is not sorted. */ @Test public void testFindYValueNonSorted() { XYSeries series = new XYSeries("S1", false); XYSeriesCollection dataset = new XYSeriesCollection(series); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 100.0))); series.add(1.0, 5.0); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); series.add(0.0, 10.0); series.add(4.0, 20.0); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, -0.5))); assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 0.0), EPSILON); assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); assertEquals(15.0, DatasetUtilities.findYValue(dataset, 0, 2.0), EPSILON); assertEquals(20.0, DatasetUtilities.findYValue(dataset, 0, 4.0), EPSILON); assertEquals(17.5, DatasetUtilities.findYValue(dataset, 0, 3.0), EPSILON); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 5.0))); }
Example #5
Source File: XYSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the indexOf() method. */ public void testIndexOf() { XYSeries s1 = new XYSeries("S1"); XYSeries s2 = new XYSeries("S2"); XYSeriesCollection dataset = new XYSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); XYSeries s2b = new XYSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); }
Example #6
Source File: TimeSeriesChartTests.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); XYDataset dataset = new XYSeriesCollection(series1); // create the chart... return ChartFactory.createTimeSeriesChart( "XY Line Chart", // chart title "Domain", "Range", dataset, // data true, // include legend true, // tooltips true // urls ); }
Example #7
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the add() method for an UNSORTED series. */ public void testAdd() { XYSeries series = new XYSeries("Series", false, true); series.add(5.0, 5.50); series.add(5.1, 5.51); series.add(6.0, 6.6); series.add(3.0, 3.3); series.add(4.0, 4.4); series.add(2.0, 2.2); series.add(1.0, 1.1); assertEquals(5.5, series.getY(0).doubleValue(), EPSILON); assertEquals(5.51, series.getY(1).doubleValue(), EPSILON); assertEquals(6.6, series.getY(2).doubleValue(), EPSILON); assertEquals(3.3, series.getY(3).doubleValue(), EPSILON); assertEquals(4.4, series.getY(4).doubleValue(), EPSILON); assertEquals(2.2, series.getY(5).doubleValue(), EPSILON); assertEquals(1.1, series.getY(6).doubleValue(), EPSILON); }
Example #8
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Check that the item bounds are determined correctly when there is a * maximum item count. */ public void testSetMaximumItemCount3() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.add(4.0, 4.4); s1.add(5.0, 5.5); s1.add(6.0, 6.6); s1.setMaximumItemCount(2); assertEquals(5.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(6.0, s1.getX(1).doubleValue(), EPSILON); assertEquals(5.0, s1.getMinX(), EPSILON); assertEquals(6.0, s1.getMaxX(), EPSILON); assertEquals(5.5, s1.getMinY(), EPSILON); assertEquals(6.6, s1.getMaxY(), EPSILON); }
Example #9
Source File: XYStepChartTest.java From buffer_bci 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 #10
Source File: SwingChartGestureDemo.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 #11
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 #12
Source File: RegressionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks the results of an OLS regression on sample dataset 1 AFTER * converting it to an XYSeries. */ 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); }
Example #13
Source File: XYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testMapDatasetToRangeAxis() { 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 yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(22, yAxis2); // add a second dataset XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); assertEquals(yAxis, plot.getRangeAxisForDataset(99)); // now map the dataset to the second xAxis plot.mapDatasetToRangeAxis(99, 22); assertEquals(yAxis2, plot.getRangeAxisForDataset(99)); }
Example #14
Source File: XYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testDomainMarkerIndices() { 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); // add a second dataset, plotted against a second x axis XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); NumberAxis xAxis2 = new NumberAxis("X2"); plot.setDomainAxis(1, xAxis2); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); plot.setRenderer(99, renderer2); plot.mapDatasetToDomainAxis(99, 1); ValueMarker xMarker1 = new ValueMarker(123); plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND); assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains( xMarker1)); }
Example #15
Source File: XYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
@Test public void testRangeMarkerIndices() { 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); // add a second dataset, plotted against a second axis XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); plot.setRenderer(99, renderer2); plot.mapDatasetToRangeAxis(99, 1); ValueMarker yMarker1 = new ValueMarker(123); plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND); assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1)); }
Example #16
Source File: XYPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
@Test public void testDomainMarkerIndices() { 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); // add a second dataset, plotted against a second x axis XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); NumberAxis xAxis2 = new NumberAxis("X2"); plot.setDomainAxis(1, xAxis2); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); plot.setRenderer(99, renderer2); plot.mapDatasetToDomainAxis(99, 1); ValueMarker xMarker1 = new ValueMarker(123); plot.addDomainMarker(99, xMarker1, Layer.FOREGROUND); assertTrue(plot.getDomainMarkers(99, Layer.FOREGROUND).contains( xMarker1)); }
Example #17
Source File: XYSeriesCollectionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some tests for the indexOf() method. */ public void testIndexOf() { XYSeries s1 = new XYSeries("S1"); XYSeries s2 = new XYSeries("S2"); XYSeriesCollection dataset = new XYSeriesCollection(); assertEquals(-1, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s1); assertEquals(0, dataset.indexOf(s1)); assertEquals(-1, dataset.indexOf(s2)); dataset.addSeries(s2); assertEquals(0, dataset.indexOf(s1)); assertEquals(1, dataset.indexOf(s2)); dataset.removeSeries(s1); assertEquals(-1, dataset.indexOf(s1)); assertEquals(0, dataset.indexOf(s2)); XYSeries s2b = new XYSeries("S2"); assertEquals(0, dataset.indexOf(s2b)); }
Example #18
Source File: DatasetUtilitiesTest.java From buffer_bci 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 #19
Source File: PolarPlotTest.java From SIMVA-SoS with Apache License 2.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 #20
Source File: XYPlotTest.java From buffer_bci with GNU General Public License v3.0 | 6 votes |
@Test public void testGetRendererForDataset2() { 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); // add a second dataset XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset2); // by default, the renderer with index 0 is used assertEquals(renderer, plot.getRendererForDataset(dataset2)); // add a second renderer with the same index as dataset2, now it will // be used XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); plot.setRenderer(99, renderer); assertEquals(renderer2, plot.getRendererForDataset(dataset2)); }
Example #21
Source File: XYStepAreaChartTest.java From openstock 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 #22
Source File: DatasetUtilitiesTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
/** * Check the findYValue() method with a dataset that is in ascending order * of x-values. */ @Test public void testFindYValue() { XYSeries series = new XYSeries("S1"); XYSeriesCollection dataset = new XYSeriesCollection(series); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 100.0))); series.add(1.0, 5.0); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); series.add(2.0, 10.0); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); assertEquals(6.25, DatasetUtilities.findYValue(dataset, 0, 1.25), EPSILON); assertEquals(7.5, DatasetUtilities.findYValue(dataset, 0, 1.5), EPSILON); assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 2.0), EPSILON); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 3.0))); }
Example #23
Source File: LogAxisTest.java From ccu-historian 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 #24
Source File: DatasetUtilitiesTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Check the findYValue() method with a dataset that is in ascending order * of x-values. */ @Test public void testFindYValue() { XYSeries series = new XYSeries("S1"); XYSeriesCollection dataset = new XYSeriesCollection(series); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 100.0))); series.add(1.0, 5.0); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); series.add(2.0, 10.0); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); assertEquals(6.25, DatasetUtilities.findYValue(dataset, 0, 1.25), EPSILON); assertEquals(7.5, DatasetUtilities.findYValue(dataset, 0, 1.5), EPSILON); assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 2.0), EPSILON); assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 3.0))); }
Example #25
Source File: FXCombinedChartGestureDemo.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 #26
Source File: RegressionTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks the results of a power regression on sample dataset 1 AFTER * converting it to an XYSeries. */ public void testPowerRegression1b() { 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[] result = Regression.getPowerRegression(ds, 0); assertEquals(0.91045813, result[0], 0.0000001); assertEquals(0.88918346, result[1], 0.0000001); }
Example #27
Source File: DatasetUtilitiesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Creates a sample dataset for testing purposes. * * @return A sample dataset. */ private TableXYDataset createTableXYDataset1() { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.0); s1.add(2.0, 2.0); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(1.0, -2.0); s2.add(2.0, -1.0); dataset.addSeries(s2); return dataset; }
Example #28
Source File: FXCombinedChartGestureDemo.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 #29
Source File: LogAxisTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Checks that the auto-range for the range axis on an XYPlot is * working as expected. */ 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, PlotOrientation.VERTICAL, false, false, false ); 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 #30
Source File: XYPlotTest.java From SIMVA-SoS with Apache License 2.0 | 6 votes |
@Test public void testRangeMarkerIndices() { 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); // add a second dataset, plotted against a second axis XYSeriesCollection dataset2 = new XYSeriesCollection(); dataset2.addSeries(new XYSeries("Series in dataset 2")); plot.setDataset(99, dataset); NumberAxis yAxis2 = new NumberAxis("Y2"); plot.setRangeAxis(1, yAxis2); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); plot.setRenderer(99, renderer2); plot.mapDatasetToRangeAxis(99, 1); ValueMarker yMarker1 = new ValueMarker(123); plot.addRangeMarker(99, yMarker1, Layer.FOREGROUND); assertTrue(plot.getRangeMarkers(99, Layer.FOREGROUND).contains(yMarker1)); }