Added getters and setters, included value drawing for BarChart. Did refactoring.

This commit is contained in:
Philipp Jahoda 2014-04-30 00:13:31 +02:00
parent f3063438c4
commit 4c0e3ddeb0
9 changed files with 352 additions and 133 deletions

View file

@ -43,7 +43,7 @@ public class BarChartActivity extends Activity implements OnSeekBarChangeListene
// mChart.setDrawFilled(true);
// mChart.setRoundedYLegend(false);
// mChart.setStartAtZero(true);
mChart.setDrawValues(false);
mChart.setDrawYValues(false);
mChart.set3DEnabled(false);
// mChart.setSpacePercent(20, 10);
mChart.setYLegendCount(5);
@ -72,10 +72,10 @@ public class BarChartActivity extends Activity implements OnSeekBarChangeListene
break;
}
case R.id.actionToggleValues: {
if (mChart.isDrawValuesEnabled())
mChart.setDrawValues(false);
if (mChart.isDrawYValuesEnabled())
mChart.setDrawYValues(false);
else
mChart.setDrawValues(true);
mChart.setDrawYValues(true);
mChart.invalidate();
break;
}

View file

@ -41,7 +41,7 @@ public class LineChartActivity extends Activity implements OnSeekBarChangeListen
// mChart.setDrawFilled(true);
// mChart.setRoundedYLegend(false);
// mChart.setStartAtZero(true);
mChart.setDrawValues(false);
mChart.setDrawYValues(false);
mChart.setLineWidth(5f);
mChart.setCircleSize(5f);
// mChart.setSpacePercent(20, 10);
@ -71,10 +71,10 @@ public class LineChartActivity extends Activity implements OnSeekBarChangeListen
break;
}
case R.id.actionToggleValues: {
if (mChart.isDrawValuesEnabled())
mChart.setDrawValues(false);
if (mChart.isDrawYValuesEnabled())
mChart.setDrawYValues(false);
else
mChart.setDrawValues(true);
mChart.setDrawYValues(true);
mChart.invalidate();
break;
}

View file

@ -68,8 +68,8 @@ public class MultipleChartsActivity extends Activity {
mPieChart.setData(xvalsSmall, small);
mPieChart.setColorTemplate(new ColorTemplate(ColorTemplate.getColors(this, ColorTemplate.FRESH_COLORS)));
// mChart3.highlightValues(new int[] {0, 1, 2, 3, 4} );
mPieChart.setDrawValues(true);
mPieChart.setDrawXVals(false);
mPieChart.setDrawYValues(true);
mPieChart.setDrawXValues(false);
mBarChart3D.setData(xvalsLarge, large);
mBarChart3D.setColorTemplate(new ColorTemplate(ColorTemplate.getColors(this, ColorTemplate.LIBERTY_COLORS)));

View file

@ -41,12 +41,12 @@ public class PieChartActivity extends Activity implements OnSeekBarChangeListene
mChart = (PieChart) findViewById(R.id.chart1);
mChart.setColorTemplate(new ColorTemplate(ColorTemplate.getColors(this, ColorTemplate.COLORFUL_COLORS)));
mChart.setDrawValues(true);
mChart.setDrawYValues(true);
mChart.setDrawCenterText(true);
mChart.setDescription("This is a description.");
mChart.setDrawHoleEnabled(true);
mChart.setDrawXVals(true);
mChart.setDrawXValues(true);
mChart.setTouchEnabled(true);
mChart.setUsePercentValues(false);
mChart.setOnChartValueSelectedListener(this);
@ -71,10 +71,10 @@ public class PieChartActivity extends Activity implements OnSeekBarChangeListene
switch (item.getItemId()) {
case R.id.actionToggleValues: {
if (mChart.isDrawValuesEnabled())
mChart.setDrawValues(false);
if (mChart.isDrawYValuesEnabled())
mChart.setDrawYValues(false);
else
mChart.setDrawValues(true);
mChart.setDrawYValues(true);
mChart.invalidate();
break;
}
@ -103,10 +103,10 @@ public class PieChartActivity extends Activity implements OnSeekBarChangeListene
break;
}
case R.id.actionToggleXVals: {
if (mChart.isDrawXValsEnabled())
mChart.setDrawXVals(false);
if (mChart.isDrawXValuesEnabled())
mChart.setDrawXValues(false);
else
mChart.setDrawXVals(true);
mChart.setDrawXValues(true);
mChart.invalidate();
break;
}

View file

@ -102,12 +102,12 @@ public class BarChart extends BarLineChartBase {
// increase deltax by 1 because the bars have a width of 1
mDeltaX++;
}
private RectF mBarRect = new RectF();
@Override
protected void drawData() {
ArrayList<Path> topPaths = new ArrayList<Path>();
ArrayList<Path> sidePaths = new ArrayList<Path>();
@ -200,11 +200,83 @@ public class BarChart extends BarLineChartBase {
}
}
@Override
protected void drawValues() {
// if values are drawn
if (mDrawYValues && mYVals.size() < mMaxVisibleCount * mScaleX) {
float[] valuePoints = new float[mYVals.size() * 2];
for (int i = 0; i < valuePoints.length; i += 2) {
valuePoints[i] = i / 2 + 0.5f; // add 0.5f too keep the values
// centered on top of the bars
valuePoints[i + 1] = mYVals.get(i / 2);
}
transformPointArray(valuePoints);
for (int i = 0; i < valuePoints.length; i += 2) {
mDrawCanvas.drawText(
mFormatValue.format(mYVals.get(i / 2)),
valuePoints[i], valuePoints[i + 1] - 12, mValuePaint);
}
}
}
@Override
public void highlightValues(int[] indices) {
super.highlightValues(indices);
}
/**
* sets the skew (default 0.3f), the skew indicates how much the 3D effect
* of the chart is turned to the right
*
* @param skew
*/
public void setSkew(float skew) {
this.mSkew = skew;
}
/**
* returns the skew value that indicates how much the 3D effect is turned to
* the right
*
* @return
*/
public float getSkew() {
return mSkew;
}
/**
* set the depth of the chart (default 0.3f), the depth indicates how much
* the 3D effect of the chart goes back
*
* @param depth
*/
public void setDepth(float depth) {
this.mDepth = depth;
}
/**
* returhs the depth, which indicates how much the 3D effect goes back
*
* @return
*/
public float getDepth() {
return mDepth;
}
/**
* returns the space between bars in percent of the whole width of one value
*
* @return
*/
public float getBarSpace() {
return mBarSpace * 100f;
}
/**
* sets the space between the bars in percent of the total bar width
*
@ -232,8 +304,22 @@ public class BarChart extends BarLineChartBase {
return m3DEnabled;
}
@Override
protected void drawValues() {
/**
* returns the top colors that define the color of the top 3D effect path
*
* @return
*/
public int[] getTopColors() {
return mTopColors;
}
/**
* returns the side colors that define the color of the side 3D effect path
*
* @return
*/
public int[] getSideColors() {
return mSideColors;
}
@Override

View file

@ -61,10 +61,19 @@ public abstract class BarLineChartBase extends Chart {
/** if true, the y-legend will always start at zero */
protected boolean mStartAtZero = true;
/** paint object for the grid lines */
protected Paint mGridPaint;
/** paint object for the (by default) lightgrey background of the grid */
protected Paint mGridBackgroundPaint;
/** paint for the line surrounding the chart */
protected Paint mOutLinePaint;
/** paint for the x-legend values */
protected Paint mXLegendPaint;
/** paint for the y-legend values */
protected Paint mYLegendPaint;
public BarLineChartBase(Context context, AttributeSet attrs, int defStyle) {
@ -116,8 +125,9 @@ public abstract class BarLineChartBase extends Chart {
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
if(mDataNotSet) return;
if (mDataNotSet)
return;
long starttime = System.currentTimeMillis();
@ -244,7 +254,7 @@ public abstract class BarLineChartBase extends Chart {
@Override
protected void calcMinMax() {
super.calcMinMax(); // calc min and max in the super class
// additional handling for space (default 10% space)
float spaceTop = (mYMax - mYChartMin) / 100f * 10f;
@ -486,29 +496,6 @@ public abstract class BarLineChartBase extends Chart {
}
}
@Override
protected void drawValues() {
// if values are drawn
if (mDrawValues && mYVals.size() < mMaxVisibleCount * mScaleX) {
float[] valuePoints = new float[mYVals.size() * 2];
for (int i = 0; i < valuePoints.length; i += 2) {
valuePoints[i] = i / 2;
valuePoints[i + 1] = mYVals.get(i / 2);
}
transformPointArray(valuePoints);
for (int i = 0; i < valuePoints.length; i += 2) {
mDrawCanvas.drawText(
mFormatValue.format(mYVals.get(i / 2)),
valuePoints[i], valuePoints[i + 1] - 12, mValuePaint);
}
}
}
/**
* determines how much space (in percent of the total range) is left between
* the loweset value of the chart and its bottom (bottomSpace) and the
@ -518,22 +505,23 @@ public abstract class BarLineChartBase extends Chart {
* @param bottomSpace
* @param topSpace
*/
// public void setSpacePercent(int bottomSpace, int topSpace) {
// mYSpacePercentBottom = bottomSpace;
// mYSpacePercentTop = topSpace;
// }
// public void setSpacePercent(int bottomSpace, int topSpace) {
// mYSpacePercentBottom = bottomSpace;
// mYSpacePercentTop = topSpace;
// }
/**
* sets the effective range of y-values the chart can display
*
* @param minY
* @param maxY
*/
public void setYRange(float minY, float maxY) {
mYChartMin = minY;
mYChartMax = maxY;
mDeltaY = mYChartMax - mYChartMin;
prepareMatrix();
prepareYLegend();
}
@ -694,9 +682,32 @@ public abstract class BarLineChartBase extends Chart {
width = 3.0f;
mGridWidth = width;
}
@Override
protected void highlightValues(int[] indices) {
super.highlightValues(indices);
}
@Override
public void setPaint(Paint p, int which) {
super.setPaint(p, which);
switch (which) {
case PAINT_GRID:
mGridPaint = p;
break;
case PAINT_GRID_BACKGROUND:
mGridBackgroundPaint = p;
break;
case PAINT_OUTLINE:
mOutLinePaint = p;
break;
case PAINT_XLEGEND:
mXLegendPaint = p;
break;
case PAINT_YLEGEND:
mYLegendPaint = p;
break;
}
}
}

View file

@ -116,8 +116,8 @@ public abstract class Chart extends View {
/** if true, touch gestures are enabled on the chart */
protected boolean mTouchEnabled = true;
/** if true, values are drawn on the chart */
protected boolean mDrawValues = true;
/** if true, y-values are drawn on the chart */
protected boolean mDrawYValues = true;
/** this rectangle defines the area in which graph values can be drawn */
protected Rect mContentRect;
@ -486,16 +486,18 @@ public abstract class Chart extends View {
* @param indices
*/
protected void highlightValues(int[] indices) {
if(mSelectionListener != null) {
if(indices[0] == -1) mSelectionListener.onNothingSelected();
else {
if (mSelectionListener != null) {
if (indices[0] == -1)
mSelectionListener.onNothingSelected();
else {
float[] values = new float[indices.length];
for(int i = 0; i < values.length; i++) values[i] = getYValue(indices[i]);
for (int i = 0; i < values.length; i++)
values[i] = getYValue(indices[i]);
// notify the listener
mSelectionListener.onValuesSelected(values, indices);
}
@ -736,13 +738,14 @@ public abstract class Chart extends View {
}
/**
* set this to true to draw values on the chart NOTE: if more than 100
* values are on the screen, values will not be drawn, even if enabled
* set this to true to draw y-values on the chart NOTE (for bar and
* linechart): if "maxvisiblecount" is reached, no values will be drawn even
* if this is enabled
*
* @param enabled
*/
public void setDrawValues(boolean enabled) {
this.mDrawValues = enabled;
public void setDrawYValues(boolean enabled) {
this.mDrawYValues = enabled;
}
// /**
@ -803,22 +806,31 @@ public abstract class Chart extends View {
mMarkerView.layout(0, 0, mDrawCanvas.getWidth(), mDrawCanvas.getHeight());
}
/**
* returns the view that is set as a marker view for the chartv
*
* @return
*/
public View getMarkerView() {
return mMarkerView;
}
/** paint for the lines of the linechart */
public static final int PAINT_LINE = 1;
/** paint for the filled surface / area of the linechart */
public static final int PAINT_LINE_FILLED = 2;
public static final int PAINT_FILLED = 2;
/** paint for the grid lines */
/** paint for the grid lines (only line and barchart) */
public static final int PAINT_GRID = 3;
/** paint for the grid background */
/** paint for the grid background (only line and barchart) */
public static final int PAINT_GRID_BACKGROUND = 4;
/** paint for the y-legend values */
/** paint for the y-legend values (only line and barchart) */
public static final int PAINT_YLEGEND = 5;
/** paint for the x-legend values */
/** paint for the x-legend values (only line and barchart) */
public static final int PAINT_XLEGEND = 6;
/**
@ -827,21 +839,27 @@ public abstract class Chart extends View {
*/
public static final int PAINT_INFO = 7;
/** paint for the value text that is displayed above each value */
/** paint for the value text */
public static final int PAINT_VALUES = 8;
/** paint for the outer circle */
/** paint for the outer circle (linechart) */
public static final int PAINT_CIRCLES_OUTER = 9;
/** paint for the inner circle */
/** paint for the inner circle (linechart) */
public static final int PAINT_CIRCLES_INNER = 10;
/** paint for the description text in the bottom right corner */
public static final int PAINT_DESCRIPTION = 11;
/** paint for the line surrounding the chart */
/** paint for the line surrounding the chart (only line and barchart) */
public static final int PAINT_OUTLINE = 12;
/** paint for the hole in the middle of the pie chart */
public static final int PAINT_HOLE = 13;
/** paint for the text in the middle of the pie chart */
public static final int PAINT_CENTER_TEXT = 14;
/**
* set a new paint object for the specified parameter in the chart e.g.
* Chart.PAINT_LINE
@ -877,12 +895,12 @@ public abstract class Chart extends View {
// }
/**
* returns true if value drawing is enabled, false if not
* returns true if y-value drawing is enabled, false if not
*
* @return
*/
public boolean isDrawValuesEnabled() {
return mDrawValues;
public boolean isDrawYValuesEnabled() {
return mDrawYValues;
}
/**
@ -917,9 +935,10 @@ public abstract class Chart extends View {
public float getPercentOfTotal(float val) {
return val / mYValueSum * 100f;
}
/**
* set a selection listener for the chart
*
* @param l
*/
public void setOnChartValueSelectedListener(OnChartValueSelectedListener l) {

View file

@ -1,3 +1,4 @@
package com.github.mikephil.charting;
import android.content.Context;
@ -8,28 +9,35 @@ import android.graphics.Path;
import android.util.AttributeSet;
public class LineChart extends BarLineChartBase {
/** the radius of the circle-shaped value indicators */
protected float mCircleSize = 4f;
protected float mCircleSize = 4f;
/** the width of the drawn data lines */
protected float mLineWidth = 1f;
/** if true, the data will also be drawn filled */
protected boolean mDrawFilled = false;
/** if true, drawing circles is enabled */
protected boolean mDrawCircles = true;
/** paint for the lines of the chart */
protected Paint mLinePaint;
/** paint for the filled are (if enabled) below the chart line */
protected Paint mFilledPaint;
/** paint for the outer circle of the value indicators */
protected Paint mCirclePaintOuter;
/** paint for the inner circle of the value indicators */
protected Paint mCirclePaintInner;
public LineChart(Context context) {
super(context);
}
public LineChart(Context context, AttributeSet attrs) {
super(context, attrs);
}
@ -37,13 +45,13 @@ public class LineChart extends BarLineChartBase {
public LineChart(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
protected void init() {
super.init();
mCircleSize = Utils.convertDpToPixel(mCircleSize);
mLinePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mLinePaint.setStrokeWidth(mLineWidth);
mLinePaint.setStyle(Paint.Style.STROKE);
@ -53,8 +61,8 @@ public class LineChart extends BarLineChartBase {
mFilledPaint = new Paint();
mFilledPaint.setStyle(Paint.Style.FILL);
mFilledPaint.setColor(mColorDarkBlue);
mFilledPaint.setAlpha(130); // alpha ~55%
mFilledPaint.setAlpha(130); // alpha ~55%
mCirclePaintOuter = new Paint(Paint.ANTI_ALIAS_FLAG);
// mCirclePaint.setStrokeWidth(5f);
mCirclePaintOuter.setStyle(Paint.Style.FILL);
@ -64,15 +72,16 @@ public class LineChart extends BarLineChartBase {
mCirclePaintInner.setStyle(Paint.Style.FILL);
mCirclePaintInner.setColor(Color.WHITE);
}
@Override
protected void prepareDataPaints(ColorTemplate ct) {
if(ct == null) return;
if (ct == null)
return;
mDrawPaints = new Paint[ct.getColors().size()];
for(int i = 0; i < ct.getColors().size(); i++) {
for (int i = 0; i < ct.getColors().size(); i++) {
mDrawPaints[i] = new Paint(Paint.ANTI_ALIAS_FLAG);
mDrawPaints[i].setStrokeWidth(mLineWidth);
mDrawPaints[i].setStyle(Style.STROKE);
@ -121,13 +130,36 @@ public class LineChart extends BarLineChartBase {
}
}
@Override
protected void drawValues() {
// if values are drawn
if (mDrawYValues && mYVals.size() < mMaxVisibleCount * mScaleX) {
float[] valuePoints = new float[mYVals.size() * 2];
for (int i = 0; i < valuePoints.length; i += 2) {
valuePoints[i] = i / 2;
valuePoints[i + 1] = mYVals.get(i / 2);
}
transformPointArray(valuePoints);
for (int i = 0; i < valuePoints.length; i += 2) {
mDrawCanvas.drawText(
mFormatValue.format(mYVals.get(i / 2)),
valuePoints[i], valuePoints[i + 1] - 12, mValuePaint);
}
}
}
/**
* draws the circle value indicators
*/
@Override
protected void drawAdditional() {
// if drawing circles is enabled
// if drawing circles is enabled
if (mDrawCircles) {
float[] positions = new float[mYVals.size() * 2];
@ -140,41 +172,55 @@ public class LineChart extends BarLineChartBase {
transformPointArray(positions);
for (int i = 0; i < positions.length; i += 2) {
mDrawCanvas.drawCircle(positions[i], positions[i + 1], mCircleSize, mCirclePaintOuter);
mDrawCanvas.drawCircle(positions[i], positions[i + 1], mCircleSize / 2, mCirclePaintInner);
mDrawCanvas.drawCircle(positions[i], positions[i + 1], mCircleSize,
mCirclePaintOuter);
mDrawCanvas.drawCircle(positions[i], positions[i + 1], mCircleSize / 2,
mCirclePaintInner);
}
}
}
@Override
public void highlightValues(int[] indices) {
super.highlightValues(indices);
}
/**
* set this to true to enable the drawing of circle indicators
*
* @param enabled
*/
public void setDrawCircles(boolean enabled) {
this.mDrawCircles = enabled;
}
/**
* returns true if drawing circles is enabled, false if not
*
* @return
*/
public boolean isDrawCirclesEnabled() {
return mDrawCircles;
}
}
/**
* sets the size (radius) of the circle shpaed value indicators, default size = 4f
* sets the size (radius) of the circle shpaed value indicators, default
* size = 4f
*
* @param size
*/
public void setCircleSize(float size) {
mCircleSize = Utils.convertDpToPixel(size);
}
/**
* returns the circlesize
*
* @param size
*/
public float getCircleSize(float size) {
return Utils.convertPixelsToDp(mCircleSize);
}
/**
* set if the chartdata should be drawn as a line or filled default = line /
@ -186,7 +232,6 @@ public class LineChart extends BarLineChartBase {
public void setDrawFilled(boolean filled) {
mDrawFilled = filled;
}
/**
* returns true if filled drawing is enabled, false if not
@ -198,8 +243,8 @@ public class LineChart extends BarLineChartBase {
}
/**
* set the line width of the chart (min = 0.5f, max = 10f); default 1f
* NOTE: thinner line == better performance, thicker line == worse performance
* set the line width of the chart (min = 0.5f, max = 10f); default 1f NOTE:
* thinner line == better performance, thicker line == worse performance
*
* @param width
*/
@ -210,7 +255,36 @@ public class LineChart extends BarLineChartBase {
if (width > 10.0f)
width = 10.0f;
mLineWidth = width;
mLinePaint.setStrokeWidth(mLineWidth);
}
/**
* returns the width of the drawn chart line
*
* @return
*/
public float getLineWidth() {
return mLineWidth;
}
@Override
public void setPaint(Paint p, int which) {
super.setPaint(p, which);
switch (which) {
case PAINT_FILLED:
mFilledPaint = p;
break;
case PAINT_LINE:
mLinePaint = p;
break;
case PAINT_CIRCLES_INNER:
mCirclePaintInner = p;
break;
case PAINT_CIRCLES_OUTER:
mCirclePaintOuter = p;
break;
}
}
}

View file

@ -57,7 +57,7 @@ public class PieChart extends Chart {
* slices
*/
private boolean mDrawXVals = true;
/**
* if set to true, all values show up in percent instead of their real value
*/
@ -118,7 +118,7 @@ public class PieChart extends Chart {
mListener = new PieChartTouchListener(this);
// for the piechart, drawing values is enabled
mDrawValues = true;
mDrawYValues = true;
}
@Override
@ -356,7 +356,8 @@ public class PieChart extends Chart {
float textheight = lines.length * lineHeight;
for (int i = 0; i < lines.length; i++) {
mDrawCanvas.drawText(lines[lines.length - i - 1], c.x, c.y - textheight/2 + lineHeight * i,
mDrawCanvas.drawText(lines[lines.length - i - 1], c.x, c.y - textheight / 2
+ lineHeight * i,
mCenterTextPaint);
}
}
@ -366,7 +367,7 @@ public class PieChart extends Chart {
protected void drawValues() {
// if neither xvals nor yvals are drawn, return
if (!mDrawXVals && !mDrawValues)
if (!mDrawXVals && !mDrawYValues)
return;
PointF center = getCenter();
@ -396,14 +397,16 @@ public class PieChart extends Chart {
// y += 10;
// x += 3;
// }
String val = "";
if(mUsePercentValues) val = mFormatValue.format(getPercentOfTotal(mYVals.get(i))) + " %";
else val = mFormatValue.format(mYVals.get(i));
if (mUsePercentValues)
val = mFormatValue.format(getPercentOfTotal(mYVals.get(i))) + " %";
else
val = mFormatValue.format(mYVals.get(i));
// draw everything, depending on settings
if (mDrawXVals && mDrawValues) {
if (mDrawXVals && mDrawYValues) {
// use ascent and descent to calculate the new line position,
// 1.6f is the line spacing
@ -415,10 +418,10 @@ public class PieChart extends Chart {
mDrawCanvas.drawText(mXVals.get(i), x,
y + lineHeight, mValuePaint);
} else if (mDrawXVals && !mDrawValues) {
} else if (mDrawXVals && !mDrawYValues) {
mDrawCanvas.drawText(mXVals.get(i), x, y, mValuePaint);
} else if (!mDrawXVals && mDrawValues) {
} else if (!mDrawXVals && mDrawYValues) {
mDrawCanvas.drawText(val, x, y, mValuePaint);
}
}
@ -457,7 +460,7 @@ public class PieChart extends Chart {
@Override
public void highlightValues(int[] indices) {
super.highlightValues(indices);
mIndicesToHightlight = indices;
invalidate();
}
@ -558,9 +561,10 @@ public class PieChart extends Chart {
public void setCenterText(String text) {
mCenterText = text;
}
/**
* returns the text that is drawn in the center of the pie-chart
*
* @return
*/
public String getCenterText() {
@ -585,17 +589,19 @@ public class PieChart extends Chart {
public boolean isDrawCenterTextEnabled() {
return mDrawCenterText;
}
/**
* set this to true to draw percent values instead of the actual values
*
* @param enabled
*/
public void setUsePercentValues(boolean enabled) {
mUsePercentValues = enabled;
}
/**
* returns true if drawing percent values is enabled
*
* @return
*/
public boolean isUsePercentValuesEnabled() {
@ -607,7 +613,7 @@ public class PieChart extends Chart {
*
* @param enabled
*/
public void setDrawXVals(boolean enabled) {
public void setDrawXValues(boolean enabled) {
mDrawXVals = enabled;
}
@ -616,7 +622,7 @@ public class PieChart extends Chart {
*
* @return
*/
public boolean isDrawXValsEnabled() {
public boolean isDrawXValuesEnabled() {
return mDrawXVals;
}
@ -644,6 +650,15 @@ public class PieChart extends Chart {
return Math.min(mContentRect.width(), mContentRect.height());
}
/**
* returns the circlebox, the boundingbox of the pie-chart slices
*
* @return
*/
public RectF getCircleBox() {
return mCircleBox;
}
/**
* returns the angle relative to the chart center for the given point on the
* chart in degrees. The angle is always between 0 and 360°, 0° is EAST
@ -709,4 +724,18 @@ public class PieChart extends Chart {
return dist;
}
@Override
public void setPaint(Paint p, int which) {
super.setPaint(p, which);
switch (which) {
case PAINT_HOLE:
mHolePaint = p;
break;
case PAINT_CENTER_TEXT:
mCenterTextPaint = p;
break;
}
}
}