for (IDataSet set : chart.getData().getDataSets()) { if (set instanceof LineDataSet) set.setDrawValues(!set.isDrawValuesEnabled()); for (IDataSet set : chart.getData().getDataSets()) { if (set instanceof BarDataSet) set.setDrawValues(!set.isDrawValuesEnabled());
/** * Returns true if the DataSet values should be drawn, false if not. * * @param set * @return */ protected boolean shouldDrawValues(IDataSet set) { return set.isVisible() && (set.isDrawValuesEnabled() || set.isDrawIconsEnabled()); }
/** * Sets the color of the value-text (color in which the value-labels are * drawn) for all DataSets this data object contains. * * @param color */ public void setValueTextColor(int color) { for (IDataSet set : mDataSets) { set.setValueTextColor(color); } }
/** * Adjusts the minimum and maximum values based on the given DataSet. * * @param d */ protected void calcMinMax(T d) { if (mYMax < d.getYMax()) mYMax = d.getYMax(); if (mYMin > d.getYMin()) mYMin = d.getYMin(); if (mXMax < d.getXMax()) mXMax = d.getXMax(); if (mXMin > d.getXMin()) mXMin = d.getXMin(); if (d.getAxisDependency() == AxisDependency.LEFT) { if (mLeftAxisMax < d.getYMax()) mLeftAxisMax = d.getYMax(); if (mLeftAxisMin > d.getYMin()) mLeftAxisMin = d.getYMin(); } else { if (mRightAxisMax < d.getYMax()) mRightAxisMax = d.getYMax(); if (mRightAxisMin > d.getYMin()) mRightAxisMin = d.getYMin(); } }
mLeftAxisMax = firstLeft.getYMax(); mLeftAxisMin = firstLeft.getYMin(); if (dataSet.getAxisDependency() == AxisDependency.LEFT) { if (dataSet.getYMin() < mLeftAxisMin) mLeftAxisMin = dataSet.getYMin(); if (dataSet.getYMax() > mLeftAxisMax) mLeftAxisMax = dataSet.getYMax(); mRightAxisMax = firstRight.getYMax(); mRightAxisMin = firstRight.getYMin(); if (dataSet.getAxisDependency() == AxisDependency.RIGHT) { if (dataSet.getYMin() < mRightAxisMin) mRightAxisMin = dataSet.getYMin(); if (dataSet.getYMax() > mRightAxisMax) mRightAxisMax = dataSet.getYMax();
List<Integer> clrs = dataSet.getColors(); int entryCount = dataSet.getEntryCount(); dataSet.getForm(), dataSet.getFormSize(), dataSet.getFormLineWidth(), dataSet.getFormLineDashEffect(), clrs.get(j) )); dataSet.getLabel(), Legend.LegendForm.NONE, Float.NaN, dataSet.getForm(), dataSet.getFormSize(), dataSet.getFormLineWidth(), dataSet.getFormLineDashEffect(), clrs.get(j) )); dataSet.getLabel(), Legend.LegendForm.NONE, Float.NaN, dataSet.getForm(), dataSet.getFormSize(), dataSet.getFormLineWidth(), dataSet.getFormLineDashEffect(),
set.setDrawValues(!set.isDrawValuesEnabled()); set.setDrawIcons(!set.isDrawIconsEnabled());
@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; }
set.setDrawValues(!set.isDrawValuesEnabled()); set.setValueTextColor(Color.WHITE); set.setDrawValues(!set.isDrawValuesEnabled()); set.setValueTextColor(Color.WHITE); set.setDrawValues(!set.isDrawValuesEnabled()); set.setValueTextColor(Color.WHITE); set.setDrawValues(!set.isDrawValuesEnabled()); set.setValueTextColor(Color.WHITE); set.setDrawValues(!set.isDrawValuesEnabled()); set.setValueTextColor(Color.WHITE);
/** * Enables / disables drawing values (value-text) for all DataSets this data * object contains. * * @param enabled */ public void setDrawValues(boolean enabled) { for (IDataSet set : mDataSets) { set.setDrawValues(enabled); } }
/** * Adds an Entry to the DataSet at the specified index. * Entries are added to the end of the list. * * @param e * @param dataSetIndex */ public void addEntry(Entry e, int dataSetIndex) { if (mDataSets.size() > dataSetIndex && dataSetIndex >= 0) { IDataSet set = mDataSets.get(dataSetIndex); // add the entry to the dataset if (!set.addEntry(e)) return; calcMinMax(e, set.getAxisDependency()); } else { Log.e("addEntry", "Cannot add Entry because dataSetIndex too high or too low."); } }
/** * Returns the DataSet that contains the provided Entry, or null, if no * DataSet contains this Entry. * * @param e * @return */ public T getDataSetForEntry(Entry e) { if (e == null) return null; for (int i = 0; i < mDataSets.size(); i++) { T set = mDataSets.get(i); for (int j = 0; j < set.getEntryCount(); j++) { if (e.equalTo(set.getEntryForXValue(e.getX(), e.getY()))) return set; } } return null; }
/** * Returns the first DataSet from the datasets-array that has it's dependency on the right axis. * Returns null if no DataSet with right dependency could be found. * * @return */ public T getFirstRight(List<T> sets) { for (T dataSet : sets) { if (dataSet.getAxisDependency() == AxisDependency.RIGHT) return dataSet; } return null; }
/** * Returns the total entry count across all DataSet objects this data object contains. * * @return */ public int getEntryCount() { int count = 0; for (T set : mDataSets) { count += set.getEntryCount(); } return count; }
/** * draws all MarkerViews on the highlighted positions */ protected void drawMarkers(Canvas canvas) { // if there is no marker view or drawing marker is disabled if (mMarker == null || !isDrawMarkersEnabled() || !valuesToHighlight()) return; for (int i = 0; i < mIndicesToHighlight.length; i++) { Highlight highlight = mIndicesToHighlight[i]; IDataSet set = mData.getDataSetByHighlight(highlight); Entry e = mData.getEntryForHighlight(highlight); if (e == null) continue; int entryIndex = set.getEntryIndex(e); // make sure entry not null if (entryIndex > set.getEntryCount() * mAnimator.getPhaseX()) continue; float[] pos = getMarkerPosition(highlight); // check bounds if (!mViewPortHandler.isInBounds(pos[0], pos[1])) continue; // callbacks to update the content mMarker.refreshContent(e, highlight); // draw the marker mMarker.draw(canvas, pos[0], pos[1]); } }
/** * Calc minimum and maximum y-values over all DataSets. * Tell DataSets to recalculate their min and max y-values, this is only needed for autoScaleMinMax. * * @param fromX the x-value to start the calculation from * @param toX the x-value to which the calculation should be performed */ public void calcMinMaxY(float fromX, float toX) { for (T set : mDataSets) { set.calcMinMaxY(fromX, toX); } // apply the new data calcMinMax(); }
/** * Get the Entry for a corresponding highlight object * * @param highlight * @return the entry that is highlighted */ @Override public Entry getEntryForHighlight(Highlight highlight) { if (highlight.getDataIndex() >= getAllData().size()) return null; ChartData data = getDataByIndex(highlight.getDataIndex()); if (highlight.getDataSetIndex() >= data.getDataSetCount()) return null; // The value of the highlighted entry could be NaN - // if we are not interested in highlighting a specific value. List<Entry> entries = data.getDataSetByIndex(highlight.getDataSetIndex()) .getEntriesForXValue(highlight.getX()); for (Entry entry : entries) if (entry.getY() == highlight.getY() || Float.isNaN(highlight.getY())) return entry; return null; }
/** * Returns all colors used across all DataSet objects this object * represents. * * @return */ public int[] getColors() { if (mDataSets == null) return null; int clrcnt = 0; for (int i = 0; i < mDataSets.size(); i++) { clrcnt += mDataSets.get(i).getColors().size(); } int[] colors = new int[clrcnt]; int cnt = 0; for (int i = 0; i < mDataSets.size(); i++) { List<Integer> clrs = mDataSets.get(i).getColors(); for (Integer clr : clrs) { colors[cnt] = clr; cnt++; } } return colors; }
final Entry entry = dataSet.getEntryForIndex(index); sliceangle * index * phaseX + mChart.getRotationAngle(), pOut); mHighlightBuffer.add(new Highlight(index, entry.getY(), pOut.x, pOut.y, i, dataSet.getAxisDependency()));
List<Integer> clrs = dataSet.getColors(); int entryCount = dataSet.getEntryCount(); dataSet.getForm(), dataSet.getFormSize(), dataSet.getFormLineWidth(), dataSet.getFormLineDashEffect(), clrs.get(j) )); dataSet.getLabel(), Legend.LegendForm.NONE, Float.NaN, dataSet.getForm(), dataSet.getFormSize(), dataSet.getFormLineWidth(), dataSet.getFormLineDashEffect(), clrs.get(j) )); dataSet.getLabel(), Legend.LegendForm.NONE, Float.NaN, dataSet.getForm(), dataSet.getFormSize(), dataSet.getFormLineWidth(), dataSet.getFormLineDashEffect(),