protected void drawCenterText(Canvas c){
  CharSequence centerText=mChart.getCenterText();
  if (mChart.isDrawCenterTextEnabled() && centerText != null) {
    MPPointF center=mChart.getCenterCircleBox();
    MPPointF offset=mChart.getCenterTextOffset();
    float x=center.x + offset.x;
    float y=center.y + offset.y;
    float innerRadius=mChart.isDrawHoleEnabled() && !mChart.isDrawSlicesUnderHoleEnabled() ? mChart.getRadius() * (mChart.getHoleRadius() / 100f) : mChart.getRadius();
    RectF holeRect=mRectBuffer[0];
    holeRect.left=x - innerRadius;
    holeRect.top=y - innerRadius;
    holeRect.right=x + innerRadius;
    holeRect.bottom=y + innerRadius;
    RectF boundingRect=mRectBuffer[1];
    boundingRect.set(holeRect);
    float radiusPercent=mChart.getCenterTextRadiusPercent() / 100f;
    if (radiusPercent > 0.0) {
      boundingRect.inset((boundingRect.width() - boundingRect.width() * radiusPercent) / 2.f,(boundingRect.height() - boundingRect.height() * radiusPercent) / 2.f);
    }
    if (!centerText.equals(mCenterTextLastValue) || !boundingRect.equals(mCenterTextLastBounds)) {
      mCenterTextLastBounds.set(boundingRect);
      mCenterTextLastValue=centerText;
      float width=mCenterTextLastBounds.width();
      mCenterTextLayout=new StaticLayout(centerText,0,centerText.length(),mCenterTextPaint,(int)Math.max(Math.ceil(width),1.f),Layout.Alignment.ALIGN_CENTER,1.f,0.f,false);
    }
    float layoutHeight=mCenterTextLayout.getHeight();
    c.save();
    if (Build.VERSION.SDK_INT >= 18) {
      Path path=mDrawCenterTextPathBuffer;
      path.reset();
      path.addOval(holeRect,Path.Direction.CW);
      c.clipPath(path);
    }
    c.translate(boundingRect.left,boundingRect.top + (boundingRect.height() - layoutHeight) / 2.f);
    mCenterTextLayout.draw(c);
    c.restore();
    MPPointF.recycleInstance(center);
    MPPointF.recycleInstance(offset);
  }
}

protected void drawCenterText ( Canvas c ) { CharSequence centerText = mChart . getCenterText ( ) ; if ( mChart . isDrawCenterTextEnabled ( ) && centerText != null ) { MPPointF center = mChart . getCenterCircleBox ( ) ; MPPointF offset = mChart . getCenterTextOffset ( ) ; float x = center . x + offset . x ; float y = center . y + offset . y ; float innerRadius = mChart . isDrawHoleEnabled ( ) && ! mChart . isDrawSlicesUnderHoleEnabled ( ) ? mChart . getRadius ( ) * ( mChart . getHoleRadius ( ) / 100f ) : mChart . getRadius ( ) ; RectF holeRect = mRectBuffer [ 0 ] ; holeRect . left = x - innerRadius ; holeRect . top = y - innerRadius ; holeRect . right = x + innerRadius ; holeRect . bottom = y + innerRadius ; RectF boundingRect = mRectBuffer [ 1 ] ; boundingRect . set ( holeRect ) ; float radiusPercent = mChart . getCenterTextRadiusPercent ( ) / 100f ; if ( radiusPercent > 0.0 ) { boundingRect . inset ( ( boundingRect . width ( ) - boundingRect . width ( ) * radiusPercent ) / 2.f , ( boundingRect . height ( ) - boundingRect . height ( ) * radiusPercent ) / 2.f ) ; } if ( ! centerText . equals ( mCenterTextLastValue ) || ! boundingRect . equals ( mCenterTextLastBounds ) ) { mCenterTextLastBounds . set ( boundingRect ) ; mCenterTextLastValue = centerText ; float width = mCenterTextLastBounds . width ( ) ; mCenterTextLayout = new StaticLayout ( centerText , 0 , centerText . length ( ) , mCenterTextPaint , ( int ) Math . max ( Math . ceil ( width ) , 1.f ) , Layout . Alignment . ALIGN_CENTER , 1.f , 0.f , false ) ; } float layoutHeight = mCenterTextLayout . getHeight ( ) ; c . save ( ) ; if ( Build . VERSION . SDK_INT >= 18 ) { Path path = mDrawCenterTextPathBuffer ; path . reset ( ) ; path . addOval ( holeRect , Path . Direction . CW ) ; c . clipPath ( path ) ; } c . translate ( boundingRect . left , boundingRect . top + ( boundingRect . height ( ) - layoutHeight ) / 2.f ) ; mCenterTextLayout . draw ( c ) ; c . restore ( ) ; MPPointF . recycleInstance ( center ) ; MPPointF . recycleInstance ( offset ) ; } }
draws the unit text in the center of the pie chart makes most sense when center - hole is enabled
