Java Code Examples for org.jfree.data.xy.XYSeries#add()
The following examples show how to use
org.jfree.data.xy.XYSeries#add() .
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: 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 2
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the getMinY() method. */ public void testGetMinY() { XYSeries s1 = new XYSeries("S1"); assertTrue(Double.isNaN(s1.getMinY())); s1.add(1.0, 1.1); assertEquals(1.1, s1.getMinY(), EPSILON); s1.add(2.0, 2.2); assertEquals(1.1, s1.getMinY(), EPSILON); s1.add(Double.NaN, 99.9); assertEquals(1.1, s1.getMinY(), EPSILON); s1.add(-1.0, -1.1); assertEquals(-1.1, s1.getMinY(), EPSILON); s1.add(0.0, null); assertEquals(-1.1, s1.getMinY(), EPSILON); }
Example 3
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 6 votes |
/** * Some checks for the updateByIndex() method. */ public void testUpdateByIndex2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, Double.NaN); assertTrue(Double.isNaN(s1.getMinY())); assertTrue(Double.isNaN(s1.getMaxY())); s1.updateByIndex(0, new Double(1.0)); assertEquals(1.0, s1.getMinY(), EPSILON); assertEquals(1.0, s1.getMaxY(), EPSILON); s1.updateByIndex(0, new Double(2.0)); assertEquals(2.0, s1.getMinY(), EPSILON); assertEquals(2.0, s1.getMaxY(), EPSILON); s1.add(-1.0, -1.0); s1.updateByIndex(0, new Double(0.0)); assertEquals(0.0, s1.getMinY(), EPSILON); assertEquals(2.0, s1.getMaxY(), EPSILON); }
Example 4
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 5
Source File: XYDataSetCollectorFunction.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 6 votes |
public void itemsAdvanced( final ReportEvent event ) { if ( FunctionUtilities.isDefinedPrepareRunLevel( this, event ) ) { final Object domainValue = getDataRow().get( getDomainColumn() ); if ( domainValue == null ) { return; } if ( !( domainValue instanceof Number ) ) { return; } final Number x = (Number) domainValue; for ( int i = 0; i < seriesNames.size(); i++ ) { String sn = (String) seriesNames.get( i ); final Object o = getDataRow().get( sn ); if ( o instanceof Number ) { Number y = (Number) o; final XYSeries o1 = (XYSeries) series.get( sn ); o1.add( x, y ); } } } }
Example 6
Source File: CombinedDomainXYPlotTest.java From openstock with GNU General Public License v3.0 | 6 votes |
/** * Creates a sample dataset. * * @return Series 2. */ private XYDataset createDataset2() { 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 7
Source File: DatasetUtilitiesTest.java From SIMVA-SoS with Apache License 2.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 8
Source File: DefaultTableXYDatasetTests.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() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.1); s1.add(2.0, 2.2); d1.addSeries(s1); DefaultTableXYDataset d2 = new DefaultTableXYDataset(); XYSeries s2 = new XYSeries("Series 1", true, false); s2.add(1.0, 1.1); s2.add(2.0, 2.2); d2.addSeries(s2); assertTrue(d1.equals(d2)); assertTrue(d2.equals(d1)); s1.add(3.0, 3.3); assertFalse(d1.equals(d2)); s2.add(3.0, 3.3); assertTrue(d1.equals(d2)); }
Example 9
Source File: XYStepAreaRendererTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ public void testDrawWithNullInfo() { boolean success = false; try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepAreaRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); success = true; } catch (NullPointerException e) { e.printStackTrace(); success = false; } assertTrue(success); }
Example 10
Source File: XYBoxAnnotationTest.java From ECG-Viewer with GNU General Public License v2.0 | 5 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown. */ public void testDrawWithNullInfo() { try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYLineAndShapeRenderer()); plot.addAnnotation(new XYBoxAnnotation(10.0, 12.0, 3.0, 4.0, new BasicStroke(1.2f), Color.red, Color.blue)); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); } catch (NullPointerException e) { fail("No exception should be triggered."); } }
Example 11
Source File: XYAreaRenderer2Test.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Draws the chart with a <code>null</code> info object to make sure that * no exceptions are thrown (particularly by code in the renderer). */ @Test public void testDrawWithNullInfo() { try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, 15.5); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, 9.5); s2.add(20.0, 3.5); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYAreaRenderer2()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); } catch (NullPointerException e) { fail("No exception should be thrown."); } }
Example 12
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Some checks for the addOrUpdate() method for an UNSORTED series. */ public void testAddOrUpdate2() { XYSeries series = new XYSeries("Series", false, true); series.add(5.0, 5.5); 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); series.addOrUpdate(new Double(3.0), new Double(33.3)); series.addOrUpdate(new Double(2.0), new Double(22.2)); assertEquals(33.3, series.getY(2).doubleValue(), EPSILON); assertEquals(22.2, series.getY(4).doubleValue(), EPSILON); }
Example 13
Source File: XYSeriesTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Check that the maximum item count can be applied retrospectively. */ public void testSetMaximumItemCount2() { XYSeries s1 = new XYSeries("S1"); s1.add(1.0, 1.1); s1.add(2.0, 2.2); s1.add(3.0, 3.3); s1.setMaximumItemCount(2); assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); }
Example 14
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 15
Source File: XYDotRendererTest.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); 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 16
Source File: TableXYDatasetTests.java From astor with GNU General Public License v2.0 | 5 votes |
/** * Creates a series for testing. * * @return A series. */ private XYSeries createSeriesB() { XYSeries s = new XYSeries("B", true, false); s.add(1.0, null); s.add(2.0, 2.2); return s; }
Example 17
Source File: XYStepRendererTest.java From ccu-historian with GNU General Public License v3.0 | 5 votes |
/** * Draws the chart with a <code>null</code> value in the dataset to make * sure that no exceptions are thrown. */ @Test public void testDrawWithNullValue() { try { DefaultTableXYDataset dataset = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(5.0, 5.0); s1.add(10.0, null); s1.add(15.0, 9.5); s1.add(20.0, 7.5); dataset.addSeries(s1); XYSeries s2 = new XYSeries("Series 2", true, false); s2.add(5.0, 5.0); s2.add(10.0, 15.5); s2.add(15.0, null); s2.add(20.0, null); dataset.addSeries(s2); XYPlot plot = new XYPlot(dataset, new NumberAxis("X"), new NumberAxis("Y"), new XYStepRenderer()); JFreeChart chart = new JFreeChart(plot); /* BufferedImage image = */ chart.createBufferedImage(300, 200, null); } catch (NullPointerException e) { fail("No exception should be thrown."); } }
Example 18
Source File: DatasetUtilitiesTest.java From openstock with GNU General Public License v3.0 | 5 votes |
/** * Some checks for the iterateRangeBounds() method. */ @Test 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 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: JPanelProfil.java From Course_Generator with GNU General Public License v3.0 | 4 votes |
/** * Update the profil chart */ public void RefreshProfilChart() { if (track == null) return; if (track.data.isEmpty()) return; // -- Clear all series if (datasetProfil.getSeriesCount() > 0) datasetProfil.removeAllSeries(); XYPlot plot = chartProfil.getXYPlot(); plot.clearDomainMarkers(); // -- Populate the serie XYSeries serie1 = new XYSeries("Elevation/Distance"); int cmpt = 1; for (CgData r : track.data) { double x = r.getTotal(settings.Unit) / 1000; double y = r.getElevation(settings.Unit); serie1.add(x, y); if (((r.getTag() & CgConst.TAG_MARK) != 0) & showProfilMarker) { Marker m = new ValueMarker(x); m.setPaint(Color.GRAY); m.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); m.setLabel(String.valueOf(cmpt)); m.setLabelOffset(new RectangleInsets(5, 0, 0, 2)); m.setLabelAnchor(RectangleAnchor.TOP_RIGHT); m.setLabelTextAnchor(TextAnchor.TOP_LEFT); plot.addDomainMarker(m); cmpt++; } } datasetProfil.addSeries(serie1); if (track.getMaxElev(settings.Unit) > track.getMinElev(settings.Unit)) { // XYPlot plot = chart.getXYPlot(); ValueAxis axisY = plot.getRangeAxis(); axisY.setRange(Math.floor(track.getMinElev(settings.Unit) / 100.0) * 100.0, Math.ceil(track.getMaxElev(settings.Unit) / 100.0) * 100.0); } }