Java Code Examples for com.github.mikephil.charting.data.ScatterDataSet#addEntryOrdered()
The following examples show how to use
com.github.mikephil.charting.data.ScatterDataSet#addEntryOrdered() .
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: DataSetTest.java From StockChart-MPAndroidChart with MIT License | 2 votes |
@Test public void testAddRemoveEntry() { List<Entry> entries = new ArrayList<Entry>(); entries.add(new Entry(10, 10)); entries.add(new Entry(15, 2)); entries.add(new Entry(21, 5)); ScatterDataSet set = new ScatterDataSet(entries, ""); assertEquals(3, set.getEntryCount()); set.addEntryOrdered(new Entry(5, 1)); assertEquals(4, set.getEntryCount()); assertEquals(5, set.getXMin(), 0.01f); assertEquals(21, set.getXMax(), 0.01f); assertEquals(1f, set.getYMin(), 0.01f); assertEquals(10f, set.getYMax(), 0.01f); assertEquals(5, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(1, set.getEntryForIndex(0).getY(), 0.01f); set.addEntryOrdered(new Entry(20, 50)); assertEquals(5, set.getEntryCount()); assertEquals(20, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(50, set.getEntryForIndex(3).getY(), 0.01f); assertTrue(set.removeEntry(3)); assertEquals(4, set.getEntryCount()); assertEquals(21, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(5, set.getEntryForIndex(3).getY(), 0.01f); assertEquals(5, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(1, set.getEntryForIndex(0).getY(), 0.01f); assertTrue(set.removeFirst()); assertEquals(3, set.getEntryCount()); assertEquals(10, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(10, set.getEntryForIndex(0).getY(), 0.01f); set.addEntryOrdered(new Entry(15, 3)); assertEquals(4, set.getEntryCount()); assertEquals(15, set.getEntryForIndex(1).getX(), 0.01f); assertEquals(3, set.getEntryForIndex(1).getY(), 0.01f); assertEquals(21, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(5, set.getEntryForIndex(3).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(3, set.getEntryCount()); assertEquals(15, set.getEntryForIndex(2).getX(), 0.01f); assertEquals(2, set.getEntryForIndex(2).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(2, set.getEntryCount()); assertTrue(set.removeLast()); assertEquals(1, set.getEntryCount()); assertEquals(10, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(10, set.getEntryForIndex(0).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(0, set.getEntryCount()); assertFalse(set.removeLast()); assertFalse(set.removeFirst()); }
Example 2
Source File: DataSetTest.java From Ticket-Analysis with MIT License | 2 votes |
@Test public void testAddRemoveEntry() { List<Entry> entries = new ArrayList<Entry>(); entries.add(new Entry(10, 10)); entries.add(new Entry(15, 2)); entries.add(new Entry(21, 5)); ScatterDataSet set = new ScatterDataSet(entries, ""); assertEquals(3, set.getEntryCount()); set.addEntryOrdered(new Entry(5, 1)); assertEquals(4, set.getEntryCount()); assertEquals(5, set.getXMin(), 0.01f); assertEquals(21, set.getXMax(), 0.01f); assertEquals(1f, set.getYMin(), 0.01f); assertEquals(10f, set.getYMax(), 0.01f); assertEquals(5, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(1, set.getEntryForIndex(0).getY(), 0.01f); set.addEntryOrdered(new Entry(20, 50)); assertEquals(5, set.getEntryCount()); assertEquals(20, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(50, set.getEntryForIndex(3).getY(), 0.01f); assertTrue(set.removeEntry(3)); assertEquals(4, set.getEntryCount()); assertEquals(21, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(5, set.getEntryForIndex(3).getY(), 0.01f); assertEquals(5, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(1, set.getEntryForIndex(0).getY(), 0.01f); assertTrue(set.removeFirst()); assertEquals(3, set.getEntryCount()); assertEquals(10, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(10, set.getEntryForIndex(0).getY(), 0.01f); set.addEntryOrdered(new Entry(15, 3)); assertEquals(4, set.getEntryCount()); assertEquals(15, set.getEntryForIndex(1).getX(), 0.01f); assertEquals(3, set.getEntryForIndex(1).getY(), 0.01f); assertEquals(21, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(5, set.getEntryForIndex(3).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(3, set.getEntryCount()); assertEquals(15, set.getEntryForIndex(2).getX(), 0.01f); assertEquals(2, set.getEntryForIndex(2).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(2, set.getEntryCount()); assertTrue(set.removeLast()); assertEquals(1, set.getEntryCount()); assertEquals(10, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(10, set.getEntryForIndex(0).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(0, set.getEntryCount()); assertFalse(set.removeLast()); assertFalse(set.removeFirst()); }
Example 3
Source File: DataSetTest.java From android-kline with Apache License 2.0 | 2 votes |
@Test public void testAddRemoveEntry() { List<Entry> entries = new ArrayList<Entry>(); entries.add(new Entry(10, 10)); entries.add(new Entry(15, 2)); entries.add(new Entry(21, 5)); ScatterDataSet set = new ScatterDataSet(entries, ""); assertEquals(3, set.getEntryCount()); set.addEntryOrdered(new Entry(5, 1)); assertEquals(4, set.getEntryCount()); assertEquals(5, set.getXMin(), 0.01f); assertEquals(21, set.getXMax(), 0.01f); assertEquals(1f, set.getYMin(), 0.01f); assertEquals(10f, set.getYMax(), 0.01f); assertEquals(5, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(1, set.getEntryForIndex(0).getY(), 0.01f); set.addEntryOrdered(new Entry(20, 50)); assertEquals(5, set.getEntryCount()); assertEquals(20, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(50, set.getEntryForIndex(3).getY(), 0.01f); assertTrue(set.removeEntry(3)); assertEquals(4, set.getEntryCount()); assertEquals(21, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(5, set.getEntryForIndex(3).getY(), 0.01f); assertEquals(5, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(1, set.getEntryForIndex(0).getY(), 0.01f); assertTrue(set.removeFirst()); assertEquals(3, set.getEntryCount()); assertEquals(10, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(10, set.getEntryForIndex(0).getY(), 0.01f); set.addEntryOrdered(new Entry(15, 3)); assertEquals(4, set.getEntryCount()); assertEquals(15, set.getEntryForIndex(1).getX(), 0.01f); assertEquals(3, set.getEntryForIndex(1).getY(), 0.01f); assertEquals(21, set.getEntryForIndex(3).getX(), 0.01f); assertEquals(5, set.getEntryForIndex(3).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(3, set.getEntryCount()); assertEquals(15, set.getEntryForIndex(2).getX(), 0.01f); assertEquals(2, set.getEntryForIndex(2).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(2, set.getEntryCount()); assertTrue(set.removeLast()); assertEquals(1, set.getEntryCount()); assertEquals(10, set.getEntryForIndex(0).getX(), 0.01f); assertEquals(10, set.getEntryForIndex(0).getY(), 0.01f); assertTrue(set.removeLast()); assertEquals(0, set.getEntryCount()); assertFalse(set.removeLast()); assertFalse(set.removeFirst()); }