/** * Highlights any y-value at the given x-value in the given DataSet. * Provide -1 as the dataSetIndex to undo all highlighting. * This method will call the listener. * @param x The x-value to highlight * @param dataSetIndex The dataset index to search in */ public void highlightValue(float x, int dataSetIndex) { highlightValue(x, dataSetIndex, true); }
/** * default constructor for initialization in code */ public Chart(Context context) { super(context); init(); }
/** * Resets all custom offsets set via setViewPortOffsets(...) method. Allows * the chart to again calculate all offsets automatically. */ public void resetViewPortOffsets() { mCustomViewPortEnabled = false; calculateOffsets(); }
/** * updates the view rotation depending on the given touch position, also * takes the starting angle into consideration * * @param x * @param y */ public void updateGestureRotation(float x, float y) { mChart.setRotationAngle(mChart.getAngleForPoint(x, y) - mStartAngle); }
/** * sets the starting angle of the rotation, this is only used by the touch * listener, x and y is the touch position * * @param x * @param y */ public void setGestureStartAngle(float x, float y) { mStartAngle = mChart.getAngleForPoint(x, y) - mChart.getRawRotationAngle(); }
/** * Saves the current state of the chart to the gallery as a PNG image. * NOTE: Needs permission WRITE_EXTERNAL_STORAGE * * @param fileName e.g. "my_image" * @return returns true if saving was successful, false if not */ public boolean saveToGallery(String fileName) { return saveToGallery(fileName, "", "MPAndroidChart-Library Save", Bitmap.CompressFormat.PNG, 40); }
@Override public void onAnimationUpdate(ValueAnimator animation) { postInvalidate(); } });
/** * Returns a recyclable MPPointF instance. * * @return */ @Override public MPPointF getCenterOfView() { return getCenter(); }
/** * Setting this to true will set the layer-type HARDWARE for the view, false * will set layer-type SOFTWARE. * * @param enabled */ public void setHardwareAccelerationEnabled(boolean enabled) { if (enabled) setLayerType(View.LAYER_TYPE_HARDWARE, null); else setLayerType(View.LAYER_TYPE_SOFTWARE, null); }
@Override public void onAnimationUpdate(ValueAnimator animation) { // ViewCompat.postInvalidateOnAnimation(Chart.this); postInvalidate(); } });
@Override public void setPaint(Paint p, int which) { super.setPaint(p, which); switch (which) { case PAINT_GRID_BACKGROUND: mGridBackgroundPaint = p; break; } }
@Override public Paint getPaint(int which) { Paint p = super.getPaint(which); if (p != null) return p; switch (which) { case PAINT_GRID_BACKGROUND: return mGridBackgroundPaint; } return null; }
@Override protected void calcMinMax() { calcAngles(); }
/** * Highlights the value at the given x-value and y-value in the given DataSet. * Provide -1 as the dataSetIndex to undo all highlighting. * This method will call the listener. * @param x The x-value to highlight * @param y The y-value to highlight. Supply `NaN` for "any" * @param dataSetIndex The dataset index to search in */ public void highlightValue(float x, float y, int dataSetIndex) { highlightValue(x, y, dataSetIndex, true); }
/** * even more awesome constructor */ public Chart(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); init(); }
/** * Saves the current state of the chart to the gallery as a JPEG image. The * filename and compression can be set. 0 == maximum compression, 100 = low * compression (high quality). NOTE: Needs permission WRITE_EXTERNAL_STORAGE * * @param fileName e.g. "my_image" * @param quality e.g. 50, min = 0, max = 100 * @return returns true if saving was successful, false if not */ public boolean saveToGallery(String fileName, int quality) { return saveToGallery(fileName, "", "MPAndroidChart-Library Save", Bitmap.CompressFormat.PNG, quality); }
/** * Highlights any y-value at the given x-value in the given DataSet. * Provide -1 as the dataSetIndex to undo all highlighting. * @param x The x-value to highlight * @param dataSetIndex The dataset index to search in * @param callListener Should the listener be called for this change */ public void highlightValue(float x, int dataSetIndex, boolean callListener) { highlightValue(x, Float.NaN, dataSetIndex, callListener); }
/** * constructor for initialization in xml */ public Chart(Context context, AttributeSet attrs) { super(context, attrs); init(); }
/** * Highlights the values represented by the provided Highlight object * This method *will not* call the listener. * * @param highlight contains information about which entry should be highlighted */ public void highlightValue(Highlight highlight) { highlightValue(highlight, false); }