Java Code Examples for com.github.mikephil.charting.data.LineData#removeEntry()
The following examples show how to use
com.github.mikephil.charting.data.LineData#removeEntry() .
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: DynamicalAddingActivity.java From StockChart-MPAndroidChart with MIT License | 6 votes |
private void removeLastEntry() { LineData data = chart.getData(); if (data != null) { ILineDataSet set = data.getDataSetByIndex(0); if (set != null) { Entry e = set.getEntryForXValue(set.getEntryCount() - 1, Float.NaN); data.removeEntry(e, 0); // or remove by index // mData.removeEntryByXValue(xIndex, dataSetIndex); data.notifyDataChanged(); chart.notifyDataSetChanged(); chart.invalidate(); } } }
Example 2
Source File: TickChart.java From android-kline with Apache License 2.0 | 5 votes |
public void refreshData(float price) { if (price <= 0 || price == mLastPrice) { return; } mLastPrice = price; LineData data = mChart.getData(); if (data != null) { ILineDataSet setSell = data.getDataSetByIndex(DATA_SET_PRICE); if (setSell == null) { setSell = createSet(TYPE_FULL); data.addDataSet(setSell); } data.removeEntry(setSell.getEntryCount(), DATA_SET_PRICE); Entry entry = new Entry(setSell.getEntryCount(), price); data.addEntry(entry, DATA_SET_PRICE); ILineDataSet paddingSet = data.getDataSetByIndex(DATA_SET_PADDING); if (paddingSet == null) { paddingSet = createSet(TYPE_DASHED); data.addDataSet(paddingSet); } int count = paddingSet.getEntryCount(); paddingSet.clear(); for (int i = 0; i < count; i++) { paddingSet.addEntry(new Entry(setSell.getEntryCount() + i, price)); } Highlight chartHighlighter = new Highlight(setSell.getEntryCount() + paddingSet.getEntryCount(), price, DATA_SET_PADDING); mChart.highlightValue(chartHighlighter); data.notifyDataChanged(); mChart.notifyDataSetChanged(); mChart.invalidate(); } }
Example 3
Source File: TickChart.java From android-kline with Apache License 2.0 | 4 votes |
public void addEntry(HisData hisData) { hisData = DataUtils.calculateHisData(hisData, mList); LineData data = mChart.getData(); if (data != null) { ILineDataSet setSell = data.getDataSetByIndex(DATA_SET_PRICE); if (setSell == null) { setSell = createSet(TYPE_FULL); data.addDataSet(setSell); } ILineDataSet aveSet = data.getDataSetByIndex(DATA_SET_AVE); if (aveSet == null) { aveSet = createSet(DATA_SET_AVE); data.addDataSet(aveSet); } int index = mList.indexOf(hisData); if (index >= 0) { mList.remove(hisData); data.removeEntry(index, DATA_SET_PRICE); data.removeEntry(index, DATA_SET_AVE); } mList.add(hisData); float price = (float) hisData.getClose(); data.addEntry(new Entry(setSell.getEntryCount(), price), DATA_SET_PRICE); data.addEntry(new Entry(setSell.getEntryCount(), (float) hisData.getAvePrice()), DATA_SET_AVE); ILineDataSet paddingSet = data.getDataSetByIndex(DATA_SET_PADDING); if (paddingSet == null) { paddingSet = createSet(TYPE_DASHED); data.addDataSet(paddingSet); } int count = paddingSet.getEntryCount(); if (count > PADDING_COUNT && index < 0) { count--; } paddingSet.clear(); for (int i = 0; i < count; i++) { paddingSet.addEntry(new Entry(setSell.getEntryCount() + i, price)); } Highlight chartHighlighter = new Highlight(setSell.getEntryCount() + paddingSet.getEntryCount(), price, DATA_SET_PADDING); mChart.highlightValue(chartHighlighter); data.notifyDataChanged(); mChart.notifyDataSetChanged(); mChart.invalidate(); } }
Example 4
Source File: DynamicalAddingActivity.java From Stayfit with Apache License 2.0 | 4 votes |
private void removeLastEntry() { LineData data = mChart.getData(); if(data != null) { ILineDataSet set = data.getDataSetByIndex(0); if (set != null) { Entry e = set.getEntryForXIndex(set.getEntryCount() - 1); data.removeEntry(e, 0); // or remove by index // mData.removeEntry(xIndex, dataSetIndex); mChart.notifyDataSetChanged(); mChart.invalidate(); } } }