Java Code Examples for org.jfree.data.xy.XYSeriesCollection#addSeries()
The following examples show how to use
org.jfree.data.xy.XYSeriesCollection#addSeries() .
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: SwingChartGestureDemo.java From old-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 2
Source File: CurveGraphPanel.java From EccPlayground with Apache License 2.0 | 6 votes |
public static CurveGraphPanel getInstance() { if (INSTANCE == null) { eccSeries = new XYSeries("ecc", false); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(eccSeries); JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, dataset, PlotOrientation.VERTICAL, false, true, false); INSTANCE = new CurveGraphPanel(chart); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); renderer.setSeriesPaint(2, Color.BLACK); } return INSTANCE; }
Example 3
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 4
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 5
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 6
Source File: MarketDepthModel.java From computational-economy with GNU General Public License v3.0 | 6 votes |
public XYDataset getMarketDepthDataset(final Currency currency, final Currency commodityCurrency) { final XYSeries series = new XYSeries(commodityCurrency.getIso4217Code() + " ask"); final Iterator<MarketOrder> iterator = ApplicationContext.getInstance().getMarketOrderDAO() .getIteratorThreadsafe(currency, commodityCurrency); 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: XYDotRendererTest.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); XYDotRenderer r = new XYDotRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example 8
Source File: StandardXYItemRendererTests.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); StandardXYItemRenderer r = new StandardXYItemRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*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: AdminJFreeChartController.java From Spring-MVC-Blueprints with MIT License | 5 votes |
private XYDataset createSampleData() { Random random = new Random(); XYSeriesCollection xySeriesCollection = new XYSeriesCollection(); for (int i = 0; i < 64; i++) { series.add(random.nextGaussian(), random.nextGaussian()); } xySeriesCollection.addSeries(series); return xySeriesCollection; }
Example 10
Source File: XYDifferenceRendererTest.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); XYDifferenceRenderer r = new XYDifferenceRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example 11
Source File: StandardXYSeriesLabelGeneratorTest.java From SIMVA-SoS with Apache License 2.0 | 5 votes |
/** * Some checks for the generalLabel() method. */ @Test public void testGenerateLabel() { StandardXYSeriesLabelGenerator g = new StandardXYSeriesLabelGenerator("Series {0}"); XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(new XYSeries("1")); dataset.addSeries(new XYSeries("2")); assertEquals("Series 1", g.generateLabel(dataset, 0)); assertEquals("Series 2", g.generateLabel(dataset, 1)); }
Example 12
Source File: XYLineAndShapeRendererTest.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); XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example 13
Source File: XYDotRendererTest.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); XYDotRenderer r = new XYDotRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*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: GUIUtils.java From egads with GNU General Public License v3.0 | 5 votes |
/** * Creates a dataset. * @return the dataset. */ public XYDataset createDataset(DataSequence ds, String label) { XYSeries observations = new XYSeries(label); int n = ds.size(); for (int i = 0; i < n; i++) { observations.add(i, ds.get(i).value); } XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(observations); return collection; }
Example 15
Source File: DatasetUtilitiesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the iterateRangeBounds() method. */ public void testIterateRangeBounds3() { // an empty dataset should return a null range XYSeriesCollection dataset = new XYSeriesCollection(); Range r = DatasetUtilities.iterateRangeBounds(dataset); assertNull(r); XYSeries s1 = new XYSeries("S1"); dataset.addSeries(s1); r = DatasetUtilities.iterateRangeBounds(dataset); assertNull(r); // a dataset with a single value s1.add(1.0, 1.23); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); // null is ignored s1.add(2.0, null); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); // Double.NaN DOESN'T mess things up s1.add(3.0, Double.NaN); r = DatasetUtilities.iterateRangeBounds(dataset); assertEquals(1.23, r.getLowerBound(), EPSILON); assertEquals(1.23, r.getUpperBound(), EPSILON); }
Example 16
Source File: XYLineAndShapeRendererTest.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); XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*JFreeChart chart =*/ new JFreeChart(plot); LegendItem li = r.getLegendItem(1, 2); assertEquals("S5", li.getLabel()); assertEquals(1, li.getDatasetIndex()); assertEquals(2, li.getSeriesIndex()); }
Example 17
Source File: StandardXYItemRendererTest.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); StandardXYItemRenderer r = new StandardXYItemRenderer(); XYPlot plot = new XYPlot(d1, new NumberAxis("x"), new NumberAxis("y"), r); plot.setDataset(1, d2); /*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: CombinedDomainXYPlotTests.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { // create dataset 1... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; }
Example 19
Source File: CombinedRangeXYPlotTest.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; }
Example 20
Source File: CombinedDomainXYPlotTest.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates a sample dataset. * * @return Series 1. */ private XYDataset createDataset1() { // create dataset 1... XYSeries series1 = new XYSeries("Series 1"); series1.add(10.0, 12353.3); series1.add(20.0, 13734.4); series1.add(30.0, 14525.3); series1.add(40.0, 13984.3); series1.add(50.0, 12999.4); series1.add(60.0, 14274.3); series1.add(70.0, 15943.5); series1.add(80.0, 14845.3); series1.add(90.0, 14645.4); series1.add(100.0, 16234.6); series1.add(110.0, 17232.3); series1.add(120.0, 14232.2); series1.add(130.0, 13102.2); series1.add(140.0, 14230.2); series1.add(150.0, 11235.2); XYSeries series2 = new XYSeries("Series 2"); series2.add(10.0, 15000.3); series2.add(20.0, 11000.4); series2.add(30.0, 17000.3); series2.add(40.0, 15000.3); series2.add(50.0, 14000.4); series2.add(60.0, 12000.3); series2.add(70.0, 11000.5); series2.add(80.0, 12000.3); series2.add(90.0, 13000.4); series2.add(100.0, 12000.6); series2.add(110.0, 13000.3); series2.add(120.0, 17000.2); series2.add(130.0, 18000.2); series2.add(140.0, 16000.2); series2.add(150.0, 17000.2); XYSeriesCollection collection = new XYSeriesCollection(); collection.addSeries(series1); collection.addSeries(series2); return collection; }