Skip to content

Commit 7b1f9b3

Browse files
committed
Fix PieChart values overlap
1 parent f6cfbdb commit 7b1f9b3

File tree

4 files changed

+822
-1
lines changed

4 files changed

+822
-1
lines changed

MPChartLib/build.gradle

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

78
ext {
@@ -43,6 +44,7 @@ android {
4344

4445
dependencies {
4546
implementation 'androidx.annotation:annotation:1.7.0'
47+
implementation 'androidx.core:core-ktx:1.9.0'
4648
testImplementation 'junit:junit:4.13.2'
4749
}
4850

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

@@ -30,6 +33,8 @@
3033
*/
3134
public class PieChart extends PieRadarChartBase<PieData> {
3235

36+
private String mode;
37+
3338
/**
3439
* rect object that represents the bounds of the piechart, needed for
3540
* drawing the circle
@@ -114,13 +119,24 @@ public PieChart(Context context, AttributeSet attrs) {
114119

115120
public PieChart(Context context, AttributeSet attrs, int defStyle) {
116121
super(context, attrs, defStyle);
122+
getAttrs(attrs);
117123
}
118124

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

123-
mRenderer = new PieChartRenderer(this, mAnimator, mViewPortHandler);
139+
mRenderer = new PieChartRendererFixCover(this, mAnimator, mViewPortHandler);
124140
mXAxis = null;
125141

126142
mHighlighter = new PieHighlighter(this);

0 commit comments

Comments
 (0)