com.github.mikephil.charting.data.DataSet Java Examples
The following examples show how to use
com.github.mikephil.charting.data.DataSet.
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: RealmBaseDataSet.java From MPAndroidChart-Realm with Apache License 2.0 | 6 votes |
@Override public void calcMinMaxY(float fromX, float toX) { if (mValues == null || mValues.isEmpty()) return; mYMax = -Float.MAX_VALUE; mYMin = Float.MAX_VALUE; int indexFrom = getEntryIndex(fromX, Float.NaN, DataSet.Rounding.DOWN); int indexTo = getEntryIndex(toX, Float.NaN, DataSet.Rounding.UP); for (int i = indexFrom; i <= indexTo; i++) { // only recalculate y calcMinMaxY(mValues.get(i)); } }
Example #2
Source File: RealmBaseDataSet.java From MPAndroidChart-Realm with Apache License 2.0 | 6 votes |
@Override public void addEntryOrdered(S e) { if (e == null) return; if (mValues == null) { mValues = new ArrayList<S>(); } calcMinMax(e); if (mValues.size() > 0 && mValues.get(mValues.size() - 1).getX() > e.getX()) { int closestIndex = getEntryIndex(e.getX(), e.getY(), DataSet.Rounding.UP); mValues.add(closestIndex, e); } else { mValues.add(e); } }
Example #3
Source File: BarChart.java From Notification-Analyser with MIT License | 6 votes |
@Override protected void calcMinMax(boolean fixedValues) { super.calcMinMax(fixedValues); // increase deltax by 1 because the bars have a width of 1 mDeltaX++; // extend xDelta to make space for multiple datasets (if ther are one) mDeltaX *= mOriginalData.getDataSetCount(); int maxEntry = 0; for (int i = 0; i < mOriginalData.getDataSetCount(); i++) { DataSet<? extends Entry> set = mOriginalData.getDataSetByIndex(i); if (maxEntry < set.getEntryCount()) maxEntry = set.getEntryCount(); } float groupSpace = mOriginalData.getGroupSpace(); mDeltaX += maxEntry * groupSpace; }
Example #4
Source File: ChartDataSetConfigUtils.java From react-native-mp-android-chart with MIT License | 5 votes |
public static void commonConfig(DataSet dataSet, ReadableMap config) { // Setting main color if (BridgeUtils.validate(config, ReadableType.String, "color")) { dataSet.setColor(Color.parseColor(config.getString("color"))); } if (BridgeUtils.validate(config, ReadableType.Array, "colors")) { dataSet.setColors(BridgeUtils.parseColors(config.getArray("colors"))); } // TODO more config to add: https://github.com/PhilJay/MPAndroidChart/wiki/The-DataSet-class if (BridgeUtils.validate(config, ReadableType.Boolean, "drawValues")) { dataSet.setDrawValues(config.getBoolean("drawValues")); } }
Example #5
Source File: DataSetTest.java From Ticket-Analysis with MIT License | 5 votes |
@Test public void testGetEntryForXValue() { List<Entry> entries = new ArrayList<Entry>(); entries.add(new Entry(10, 10)); entries.add(new Entry(15, 5)); entries.add(new Entry(21, 5)); ScatterDataSet set = new ScatterDataSet(entries, ""); Entry closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.CLOSEST); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.DOWN); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(15, Float.NaN, DataSet.Rounding.DOWN); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(14, Float.NaN, DataSet.Rounding.DOWN); assertEquals(10, closest.getX(), 0.01f); assertEquals(10, closest.getY(), 0.01f); closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.UP); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(21, Float.NaN, DataSet.Rounding.UP); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(21, Float.NaN, DataSet.Rounding.CLOSEST); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); }
Example #6
Source File: HorizontalBarHighlighter.java From Ticket-Analysis with MIT License | 5 votes |
@Override protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) { ArrayList<Highlight> highlights = new ArrayList<>(); //noinspection unchecked List<Entry> entries = set.getEntriesForXValue(xVal); if (entries.size() == 0) { // Try to find closest x-value and take all entries for that x-value final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding); if (closest != null) { //noinspection unchecked entries = set.getEntriesForXValue(closest.getX()); } } if (entries.size() == 0) return highlights; for (Entry e : entries) { MPPointD pixels = mChart.getTransformer( set.getAxisDependency()).getPixelForValues(e.getY(), e.getX()); highlights.add(new Highlight( e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency())); } return highlights; }
Example #7
Source File: ChartHighlighter.java From Ticket-Analysis with MIT License | 5 votes |
/** * An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex. * * @param set * @param dataSetIndex * @param xVal * @param rounding * @return */ protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) { ArrayList<Highlight> highlights = new ArrayList<>(); //noinspection unchecked List<Entry> entries = set.getEntriesForXValue(xVal); if (entries.size() == 0) { // Try to find closest x-value and take all entries for that x-value final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding); if (closest != null) { //noinspection unchecked entries = set.getEntriesForXValue(closest.getX()); } } if (entries.size() == 0) return highlights; for (Entry e : entries) { MPPointD pixels = mChart.getTransformer( set.getAxisDependency()).getPixelForValues(e.getX(), e.getY()); highlights.add(new Highlight( e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency())); } return highlights; }
Example #8
Source File: HorizontalBarHighlighter.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Override protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) { ArrayList<Highlight> highlights = new ArrayList<>(); //noinspection unchecked List<Entry> entries = set.getEntriesForXValue(xVal); if (entries.size() == 0) { // Try to find closest x-value and take all entries for that x-value final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding); if (closest != null) { //noinspection unchecked entries = set.getEntriesForXValue(closest.getX()); } } if (entries.size() == 0) { return highlights; } for (Entry e : entries) { MPPointD pixels = mChart.getTransformer( set.getAxisDependency()).getPixelForValues(e.getY(), e.getX()); highlights.add(new Highlight( e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency())); } return highlights; }
Example #9
Source File: DataSetTest.java From StockChart-MPAndroidChart with MIT License | 5 votes |
@Test public void testGetEntryForXValue() { List<Entry> entries = new ArrayList<Entry>(); entries.add(new Entry(10, 10)); entries.add(new Entry(15, 5)); entries.add(new Entry(21, 5)); ScatterDataSet set = new ScatterDataSet(entries, ""); Entry closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.CLOSEST); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.DOWN); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(15, Float.NaN, DataSet.Rounding.DOWN); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(14, Float.NaN, DataSet.Rounding.DOWN); assertEquals(10, closest.getX(), 0.01f); assertEquals(10, closest.getY(), 0.01f); closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.UP); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(21, Float.NaN, DataSet.Rounding.UP); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(21, Float.NaN, DataSet.Rounding.CLOSEST); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); }
Example #10
Source File: DrawChartActivity.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** callback when a DataSet has been drawn (when lifting the finger) */ @Override public void onDrawFinished(DataSet<?> dataSet) { Log.i(Chart.LOG_TAG, "DataSet drawn. " + dataSet.toSimpleString()); // prepare the legend again chart.getLegendRenderer().computeLegend(chart.getData()); }
Example #11
Source File: BarLineScatterCandleBubbleRenderer.java From Ticket-Analysis with MIT License | 5 votes |
/** * Calculates the minimum and maximum x values as well as the range between them. * * @param chart * @param dataSet */ public void set(BarLineScatterCandleBubbleDataProvider chart, IBarLineScatterCandleBubbleDataSet dataSet) { float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX())); float low = chart.getLowestVisibleX(); float high = chart.getHighestVisibleX(); Entry entryFrom = dataSet.getEntryForXValue(low, Float.NaN, DataSet.Rounding.DOWN); Entry entryTo = dataSet.getEntryForXValue(high, Float.NaN, DataSet.Rounding.UP); min = entryFrom == null ? 0 : dataSet.getEntryIndex(entryFrom); max = entryTo == null ? 0 : dataSet.getEntryIndex(entryTo); range = (int) ((max - min) * phaseX); }
Example #12
Source File: BarLineScatterCandleBubbleRenderer.java From android-kline with Apache License 2.0 | 5 votes |
/** * Calculates the minimum and maximum x values as well as the range between them. * * @param chart * @param dataSet */ public void set(BarLineScatterCandleBubbleDataProvider chart, IBarLineScatterCandleBubbleDataSet dataSet) { float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX())); float low = chart.getLowestVisibleX(); float high = chart.getHighestVisibleX(); Entry entryFrom = dataSet.getEntryForXValue(low, Float.NaN, DataSet.Rounding.DOWN); Entry entryTo = dataSet.getEntryForXValue(high, Float.NaN, DataSet.Rounding.UP); min = entryFrom == null ? 0 : dataSet.getEntryIndex(entryFrom); max = entryTo == null ? 0 : dataSet.getEntryIndex(entryTo); range = (int) ((max - min) * phaseX); }
Example #13
Source File: ChartHighlighter.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex. * * @param set * @param dataSetIndex * @param xVal * @param rounding * @return */ protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) { ArrayList<Highlight> highlights = new ArrayList<>(); //noinspection unchecked List<Entry> entries = set.getEntriesForXValue(xVal); if (entries.size() == 0) { // Try to find closest x-value and take all entries for that x-value final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding); if (closest != null) { //noinspection unchecked entries = set.getEntriesForXValue(closest.getX()); } } if (entries.size() == 0) { return highlights; } for (Entry e : entries) { MPPointD pixels = mChart.getTransformer( set.getAxisDependency()).getPixelForValues(e.getX(), e.getY()); highlights.add(new Highlight( e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency())); } return highlights; }
Example #14
Source File: Chart.java From Notification-Analyser with MIT License | 5 votes |
/** * returns the average value for a specific DataSet (with a specific label) * in the chart * * @param dataSetLabel * @return */ public float getAverage(String dataSetLabel) { DataSet<? extends Entry> ds = mCurrentData.getDataSetByLabel(dataSetLabel, true); return ds.getYValueSum() / ds.getEntryCount(); }
Example #15
Source File: ChartHighlighter.java From android-kline with Apache License 2.0 | 5 votes |
/** * An array of `Highlight` objects corresponding to the selected xValue and dataSetIndex. * * @param set * @param dataSetIndex * @param xVal * @param rounding * @return */ protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) { ArrayList<Highlight> highlights = new ArrayList<>(); //noinspection unchecked List<Entry> entries = set.getEntriesForXValue(xVal); if (entries.size() == 0) { // Try to find closest x-value and take all entries for that x-value final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding); if (closest != null) { //noinspection unchecked entries = set.getEntriesForXValue(closest.getX()); } } if (entries.size() == 0) return highlights; for (Entry e : entries) { MPPointD pixels = mChart.getTransformer( set.getAxisDependency()).getPixelForValues(e.getX(), e.getY()); highlights.add(new Highlight( e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency())); } return highlights; }
Example #16
Source File: HorizontalBarHighlighter.java From android-kline with Apache License 2.0 | 5 votes |
@Override protected List<Highlight> buildHighlights(IDataSet set, int dataSetIndex, float xVal, DataSet.Rounding rounding) { ArrayList<Highlight> highlights = new ArrayList<>(); //noinspection unchecked List<Entry> entries = set.getEntriesForXValue(xVal); if (entries.size() == 0) { // Try to find closest x-value and take all entries for that x-value final Entry closest = set.getEntryForXValue(xVal, Float.NaN, rounding); if (closest != null) { //noinspection unchecked entries = set.getEntriesForXValue(closest.getX()); } } if (entries.size() == 0) return highlights; for (Entry e : entries) { MPPointD pixels = mChart.getTransformer( set.getAxisDependency()).getPixelForValues(e.getY(), e.getX()); highlights.add(new Highlight( e.getX(), e.getY(), (float) pixels.x, (float) pixels.y, dataSetIndex, set.getAxisDependency())); } return highlights; }
Example #17
Source File: DataSetTest.java From android-kline with Apache License 2.0 | 5 votes |
@Test public void testGetEntryForXValue() { List<Entry> entries = new ArrayList<Entry>(); entries.add(new Entry(10, 10)); entries.add(new Entry(15, 5)); entries.add(new Entry(21, 5)); ScatterDataSet set = new ScatterDataSet(entries, ""); Entry closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.CLOSEST); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.DOWN); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(15, Float.NaN, DataSet.Rounding.DOWN); assertEquals(15, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(14, Float.NaN, DataSet.Rounding.DOWN); assertEquals(10, closest.getX(), 0.01f); assertEquals(10, closest.getY(), 0.01f); closest = set.getEntryForXValue(17, Float.NaN, DataSet.Rounding.UP); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(21, Float.NaN, DataSet.Rounding.UP); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); closest = set.getEntryForXValue(21, Float.NaN, DataSet.Rounding.CLOSEST); assertEquals(21, closest.getX(), 0.01f); assertEquals(5, closest.getY(), 0.01f); }
Example #18
Source File: PieChart.java From iMoney with Apache License 2.0 | 5 votes |
/** * Returns the index of the DataSet this x-index belongs to. * * @param xIndex * @return */ public int getDataSetIndexForIndex(int xIndex) { List<? extends DataSet<? extends Entry>> dataSets = mData.getDataSets(); for (int i = 0; i < dataSets.size(); i++) { if (dataSets.get(i).getEntryForXIndex(xIndex) != null) return i; } return -1; }
Example #19
Source File: Chart.java From iMoney with Apache License 2.0 | 5 votes |
/** * Sets a new data object for the chart. The data object contains all values * and information needed for displaying. * * @param data */ public void setData(T data) { if (data == null) { Log.e(LOG_TAG, "Cannot set data for chart. Provided data object is null."); return; } // LET THE CHART KNOW THERE IS DATA mDataNotSet = false; mOffsetsCalculated = false; mData = data; // calculate how many digits are needed calculateFormatter(data.getYMin(), data.getYMax()); for (DataSet<?> set : mData.getDataSets()) { if (set.needsDefaultFormatter()) set.setValueFormatter(mDefaultFormatter); } // let the chart know there is new data notifyDataSetChanged(); if (mLogEnabled) Log.i(LOG_TAG, "Data is set."); }
Example #20
Source File: PieChart.java From Notification-Analyser with MIT License | 5 votes |
/** * Returns the index of the DataSet this x-index belongs to. * * @param xIndex * @return */ public int getDataSetIndexForIndex(int xIndex) { ArrayList<? extends DataSet<? extends Entry>> dataSets = mCurrentData.getDataSets(); for (int i = 0; i < dataSets.size(); i++) { if (dataSets.get(i).getEntryForXIndex(xIndex) != null) return i; } return -1; }
Example #21
Source File: DataRenderer.java From iMoney with Apache License 2.0 | 5 votes |
/** * Applies the required styling (provided by the DataSet) to the value-paint * object. * * @param set */ protected void applyValueTextStyle(DataSet<?> set) { mValuePaint.setColor(set.getValueTextColor()); mValuePaint.setTypeface(set.getValueTypeface()); mValuePaint.setTextSize(set.getValueTextSize()); }
Example #22
Source File: RealmBaseDataSet.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public S getEntryForXIndex(int xIndex, DataSet.Rounding rounding) { int index = getEntryIndex(xIndex, rounding); if (index > -1) return mValues.get(index); return null; }
Example #23
Source File: RealmBaseDataSet.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public int getEntryIndex(int x, DataSet.Rounding rounding) { int low = 0; int high = mValues.size() - 1; int closest = -1; while (low <= high) { int m = (high + low) / 2; if (x == mValues.get(m).getXIndex()) { while (m > 0 && mValues.get(m - 1).getXIndex() == x) m--; return m; } if (x > mValues.get(m).getXIndex()) low = m + 1; else high = m - 1; closest = m; } if (closest != -1) { int closestXIndex = mValues.get(closest).getXIndex(); if (rounding == DataSet.Rounding.UP) { if (closestXIndex < x && closest < mValues.size() - 1) { ++closest; } } else if (rounding == DataSet.Rounding.DOWN) { if (closestXIndex > x && closest > 0) { --closest; } } } return closest; }
Example #24
Source File: RealmBaseDataSet.java From Stayfit with Apache License 2.0 | 5 votes |
@Override public void addEntryOrdered(S e) { if (e == null) return; float val = e.getVal(); if (mValues == null) { mValues = new ArrayList<S>(); } if (mValues.size() == 0) { mYMax = val; mYMin = val; } else { if (mYMax < val) mYMax = val; if (mYMin > val) mYMin = val; } if (mValues.size() > 0 && mValues.get(mValues.size() - 1).getXIndex() > e.getXIndex()) { int closestIndex = getEntryIndex(e.getXIndex(), DataSet.Rounding.UP); mValues.add(closestIndex, e); return; } mValues.add(e); }
Example #25
Source File: RealmBaseDataSet.java From MPAndroidChart-Realm with Apache License 2.0 | 5 votes |
@Override public S getEntryForXValue(float xValue, float closestToY, DataSet.Rounding rounding) { int index = getEntryIndex(xValue, closestToY, rounding); if (index > -1) return mValues.get(index); return null; }
Example #26
Source File: DrawChartActivity.java From Stayfit with Apache License 2.0 | 5 votes |
/** callback when a DataSet has been drawn (when lifting the finger) */ @Override public void onDrawFinished(DataSet<?> dataSet) { Log.i(Chart.LOG_TAG, "DataSet drawn. " + dataSet.toSimpleString()); // prepare the legend again mChart.getLegendRenderer().computeLegend(mChart.getData()); }
Example #27
Source File: RealmBaseDataSet.java From NetKnight with Apache License 2.0 | 5 votes |
@Override public S getEntryForXIndex(int xIndex, DataSet.Rounding rounding) { int index = getEntryIndex(xIndex, rounding); if (index > -1) return mValues.get(index); return null; }
Example #28
Source File: RealmBaseDataSet.java From NetKnight with Apache License 2.0 | 5 votes |
@Override public void addEntryOrdered(S e) { if (e == null) return; float val = e.getVal(); if (mValues == null) { mValues = new ArrayList<S>(); } if (mValues.size() == 0) { mYMax = val; mYMin = val; } else { if (mYMax < val) mYMax = val; if (mYMin > val) mYMin = val; } if (mValues.size() > 0 && mValues.get(mValues.size() - 1).getXIndex() > e.getXIndex()) { int closestIndex = getEntryIndex(e.getXIndex(), DataSet.Rounding.UP); mValues.add(closestIndex, e); return; } mValues.add(e); }
Example #29
Source File: BarLineScatterCandleBubbleRenderer.java From StockChart-MPAndroidChart with MIT License | 5 votes |
/** * Calculates the minimum and maximum x values as well as the range between them. * * @param chart * @param dataSet */ public void set(BarLineScatterCandleBubbleDataProvider chart, IBarLineScatterCandleBubbleDataSet dataSet) { float phaseX = Math.max(0.f, Math.min(1.f, mAnimator.getPhaseX())); float low = chart.getLowestVisibleX(); float high = chart.getHighestVisibleX(); Entry entryFrom = dataSet.getEntryForXValue(low, Float.NaN, DataSet.Rounding.DOWN); Entry entryTo = dataSet.getEntryForXValue(high, Float.NaN, DataSet.Rounding.UP); min = entryFrom == null ? 0 : dataSet.getEntryIndex(entryFrom); max = entryTo == null ? 0 : dataSet.getEntryIndex(entryTo); range = (int) ((max - min) * phaseX); }
Example #30
Source File: LineChartRenderer.java From Stayfit with Apache License 2.0 | 4 votes |
/** * Draws a normal line. * * @param c * @param dataSet */ protected void drawLinear(Canvas c, ILineDataSet dataSet) { int entryCount = dataSet.getEntryCount(); int dataSetIndex = mChart.getLineData().getIndexOfDataSet(dataSet); Transformer trans = mChart.getTransformer(dataSet.getAxisDependency()); float phaseX = mAnimator.getPhaseX(); float phaseY = mAnimator.getPhaseY(); mRenderPaint.setStyle(Paint.Style.STROKE); Canvas canvas = null; // if the data-set is dashed, draw on bitmap-canvas if (dataSet.isDashedLineEnabled()) { canvas = mBitmapCanvas; } else { canvas = c; } Entry entryFrom = dataSet.getEntryForXIndex((mMinX < 0) ? 0 : mMinX, DataSet.Rounding.DOWN); Entry entryTo = dataSet.getEntryForXIndex(mMaxX, DataSet.Rounding.UP); int minx = Math.max(dataSet.getEntryIndex(entryFrom), 0); int maxx = Math.min(dataSet.getEntryIndex(entryTo) + 1, entryCount); int range = (maxx - minx) * 4 - 4; LineBuffer buffer = mLineBuffers[dataSetIndex]; buffer.setPhases(phaseX, phaseY); buffer.limitFrom(minx); buffer.limitTo(maxx); buffer.feed(dataSet); trans.pointValuesToPixel(buffer.buffer); // more than 1 color if (dataSet.getColors().size() > 1) { for (int j = 0; j < range; j += 4) { if (!mViewPortHandler.isInBoundsRight(buffer.buffer[j])) break; // make sure the lines don't do shitty things outside // bounds if (!mViewPortHandler.isInBoundsLeft(buffer.buffer[j + 2]) || (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 1]) && !mViewPortHandler .isInBoundsBottom(buffer.buffer[j + 3])) || (!mViewPortHandler.isInBoundsTop(buffer.buffer[j + 1]) && !mViewPortHandler .isInBoundsBottom(buffer.buffer[j + 3]))) continue; // get the color that is set for this line-segment mRenderPaint.setColor(dataSet.getColor(j / 4 + minx)); canvas.drawLine(buffer.buffer[j], buffer.buffer[j + 1], buffer.buffer[j + 2], buffer.buffer[j + 3], mRenderPaint); } } else { // only one color per dataset mRenderPaint.setColor(dataSet.getColor()); // c.drawLines(buffer.buffer, mRenderPaint); canvas.drawLines(buffer.buffer, 0, range, mRenderPaint); } mRenderPaint.setPathEffect(null); // if drawing filled is enabled if (dataSet.isDrawFilledEnabled() && entryCount > 0) { drawLinearFill(c, dataSet, minx, maxx, trans); } }