Skip to content

Commit 6af5355

Browse files
committed
Fix PieChart values overlap
1 parent ec8028d commit 6af5355

File tree

4 files changed

+825
-1
lines changed

4 files changed

+825
-1
lines changed

MPChartLib/build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ plugins {
33
id 'maven-publish'
44
id 'kotlin-android'
55
id "com.vanniktech.maven.publish" version "0.30.0"
6+
id 'org.jetbrains.kotlin.android'
67
}
78

89
ext {
@@ -47,6 +48,7 @@ android {
4748

4849
dependencies {
4950
implementation 'androidx.annotation:annotation:1.9.1'
51+
implementation 'androidx.core:core-ktx:1.9.0'
5052
testImplementation 'junit:junit:4.13.2'
5153
}
5254

MPChartLib/src/main/java/com/github/mikephil/charting/charts/PieChart.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,23 @@
22
package com.github.mikephil.charting.charts;
33

44
import android.content.Context;
5+
import android.content.res.TypedArray;
56
import android.graphics.Canvas;
67
import android.graphics.Paint;
78
import android.graphics.RectF;
89
import android.graphics.Typeface;
910
import android.text.TextUtils;
1011
import android.util.AttributeSet;
1112

13+
import com.github.mikephil.charting.R;
1214
import com.github.mikephil.charting.components.XAxis;
1315
import com.github.mikephil.charting.data.PieData;
1416
import com.github.mikephil.charting.data.PieEntry;
1517
import com.github.mikephil.charting.highlight.Highlight;
1618
import com.github.mikephil.charting.highlight.PieHighlighter;
1719
import com.github.mikephil.charting.interfaces.datasets.IPieDataSet;
1820
import com.github.mikephil.charting.renderer.PieChartRenderer;
21+
import com.github.mikephil.charting.renderer.PieChartRendererFixCover;
1922
import com.github.mikephil.charting.utils.MPPointF;
2023
import com.github.mikephil.charting.utils.Utils;
2124

@@ -29,6 +32,8 @@
2932
*/
3033
public class PieChart extends PieRadarChartBase<PieData> {
3134

35+
private String mode;
36+
3237
/**
3338
* rect object that represents the bounds of the piechart, needed for
3439
* drawing the circle
@@ -113,13 +118,24 @@ public PieChart(Context context, AttributeSet attrs) {
113118

114119
public PieChart(Context context, AttributeSet attrs, int defStyle) {
115120
super(context, attrs, defStyle);
121+
getAttrs(attrs);
116122
}
117123

124+
private void getAttrs(AttributeSet attrs) {
125+
if (attrs != null) {
126+
TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.PieChart);
127+
mode = a.getString(R.styleable.PieChart_mp_chart_out_value_place_mode);
128+
a.recycle();
129+
}
130+
((PieChartRendererFixCover) mRenderer).setMode(mode);
131+
}
132+
133+
118134
@Override
119135
protected void init() {
120136
super.init();
121137

122-
mRenderer = new PieChartRenderer(this, mAnimator, mViewPortHandler);
138+
mRenderer = new PieChartRendererFixCover(this, mAnimator, mViewPortHandler);
123139
mXAxis = null;
124140

125141
mHighlighter = new PieHighlighter(this);

0 commit comments

Comments
 (0)