|
2 | 2 | package com.github.mikephil.charting.charts; |
3 | 3 |
|
4 | 4 | import android.content.Context; |
| 5 | +import android.content.res.TypedArray; |
5 | 6 | import android.graphics.Canvas; |
6 | 7 | import android.graphics.Paint; |
7 | 8 | import android.graphics.RectF; |
8 | 9 | import android.graphics.Typeface; |
9 | 10 | import android.util.AttributeSet; |
10 | 11 |
|
| 12 | +import com.github.mikephil.charting.R; |
11 | 13 | import com.github.mikephil.charting.components.XAxis; |
12 | 14 | import com.github.mikephil.charting.data.PieData; |
13 | 15 | import com.github.mikephil.charting.highlight.Highlight; |
14 | 16 | import com.github.mikephil.charting.highlight.PieHighlighter; |
15 | 17 | import com.github.mikephil.charting.interfaces.datasets.IPieDataSet; |
16 | 18 | import com.github.mikephil.charting.renderer.PieChartRenderer; |
| 19 | +import com.github.mikephil.charting.renderer.PieChartRendererFixCover; |
17 | 20 | import com.github.mikephil.charting.utils.MPPointF; |
18 | 21 | import com.github.mikephil.charting.utils.Utils; |
19 | 22 |
|
|
26 | 29 | */ |
27 | 30 | public class PieChart extends PieRadarChartBase<PieData> { |
28 | 31 |
|
| 32 | + private String mode; |
| 33 | + |
29 | 34 | /** |
30 | 35 | * rect object that represents the bounds of the piechart, needed for |
31 | 36 | * drawing the circle |
@@ -110,13 +115,24 @@ public PieChart(Context context, AttributeSet attrs) { |
110 | 115 |
|
111 | 116 | public PieChart(Context context, AttributeSet attrs, int defStyle) { |
112 | 117 | super(context, attrs, defStyle); |
| 118 | + getAttrs(attrs); |
113 | 119 | } |
114 | 120 |
|
| 121 | + private void getAttrs(AttributeSet attrs) { |
| 122 | + if (attrs != null) { |
| 123 | + TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PieChart); |
| 124 | + mode = a.getString(R.styleable.PieChart_mp_chart_out_value_place_mode); |
| 125 | + a.recycle(); |
| 126 | + } |
| 127 | + ((PieChartRendererFixCover) mRenderer).setMode(mode); |
| 128 | + } |
| 129 | + |
| 130 | + |
115 | 131 | @Override |
116 | 132 | protected void init() { |
117 | 133 | super.init(); |
118 | 134 |
|
119 | | - mRenderer = new PieChartRenderer(this, mAnimator, mViewPortHandler); |
| 135 | + mRenderer = new PieChartRendererFixCover(this, mAnimator, mViewPortHandler); |
120 | 136 | mXAxis = null; |
121 | 137 |
|
122 | 138 | mHighlighter = new PieHighlighter(this); |
|
0 commit comments