Skip to content

Commit

Permalink
Fixed issue concerning transparent circle when animating (issue #543).
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilJay committed Apr 12, 2015
1 parent 4341890 commit aa7cbce
Showing 1 changed file with 22 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public PieChartRenderer(PieChart chart, ChartAnimator animator,
mTransparentCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mTransparentCirclePaint.setColor(Color.WHITE);
mTransparentCirclePaint.setStyle(Style.FILL);

mCenterTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCenterTextPaint.setColor(Color.BLACK);
mCenterTextPaint.setTextSize(Utils.convertDpToPixel(12f));
Expand All @@ -69,7 +69,7 @@ public PieChartRenderer(PieChart chart, ChartAnimator animator,
public Paint getPaintHole() {
return mHolePaint;
}

public Paint getPaintTransparentCircle() {
return mTransparentCirclePaint;
}
Expand All @@ -86,19 +86,19 @@ public void initBuffers() {

@Override
public void drawData(Canvas c) {

if (mDrawBitmap == null
|| ((int) mViewPortHandler.getChartHeight() != mDrawBitmap.getHeight())) {
mDrawBitmap = Bitmap.createBitmap((int) mViewPortHandler.getChartWidth(),
(int) mViewPortHandler.getChartHeight(), Bitmap.Config.ARGB_8888);
mBitmapCanvas = new Canvas(mDrawBitmap);
}
// Paint p = new Paint();
// p.setStyle(Paint.Style.FILL);
// p.setColor(Color.BLACK);
// c.drawRect(mChart.getCircleBox(), p);

// Paint p = new Paint();
// p.setStyle(Paint.Style.FILL);
// p.setColor(Color.BLACK);
// c.drawRect(mChart.getCircleBox(), p);

mDrawBitmap.eraseColor(Color.TRANSPARENT);

PieData pieData = mChart.getData();
Expand Down Expand Up @@ -200,8 +200,9 @@ public void drawValues(Canvas c) {
/ mChart.getYValueSum() * 100f : entries.get(j).getVal();

String val = dataSet.getValueFormatter().getFormattedValue(value);

float lineHeight = Utils.calcTextHeight(mValuePaint, val) + Utils.convertDpToPixel(4f);

float lineHeight = Utils.calcTextHeight(mValuePaint, val)
+ Utils.convertDpToPixel(4f);

boolean drawYVals = dataSet.isDrawValuesEnabled();

Expand Down Expand Up @@ -244,11 +245,12 @@ protected void drawHole(Canvas c) {
float transparentCircleRadius = mChart.getTransparentCircleRadius();
float holeRadius = mChart.getHoleRadius();
float radius = mChart.getRadius();

PointF center = mChart.getCenterCircleBox();

if (transparentCircleRadius > holeRadius) {


PointF center = mChart.getCenterCircleBox();

if (transparentCircleRadius > holeRadius && mAnimator.getPhaseX() >= 1f
&& mAnimator.getPhaseY() >= 1f) {

int color = mTransparentCirclePaint.getColor();

// make transparent
Expand All @@ -257,10 +259,10 @@ protected void drawHole(Canvas c) {
// draw the transparent-circle
mBitmapCanvas.drawCircle(center.x, center.y,
radius / 100 * transparentCircleRadius, mTransparentCirclePaint);
mTransparentCirclePaint.setColor(color);
}

mTransparentCirclePaint.setColor(color);
}

// draw the hole-circle
mBitmapCanvas.drawCircle(center.x, center.y,
radius / 100 * holeRadius, mHolePaint);
Expand Down

0 comments on commit aa7cbce

Please sign in to comment.