Skip to content

Commit 7e986b2

Browse files
committed
Fix PieChart values overlap
1 parent c0ee877 commit 7e986b2

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.24.0"
5+
id 'org.jetbrains.kotlin.android'
56
}
67

78
ext {
@@ -39,6 +40,7 @@ android {
3940

4041
dependencies {
4142
implementation 'androidx.annotation:annotation:1.6.0'
43+
implementation 'androidx.core:core-ktx:1.9.0'
4244
testImplementation 'junit:junit:4.13.2'
4345
}
4446

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,18 +2,21 @@
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.util.AttributeSet;
1011

12+
import com.github.mikephil.charting.R;
1113
import com.github.mikephil.charting.components.XAxis;
1214
import com.github.mikephil.charting.data.PieData;
1315
import com.github.mikephil.charting.highlight.Highlight;
1416
import com.github.mikephil.charting.highlight.PieHighlighter;
1517
import com.github.mikephil.charting.interfaces.datasets.IPieDataSet;
1618
import com.github.mikephil.charting.renderer.PieChartRenderer;
19+
import com.github.mikephil.charting.renderer.PieChartRendererFixCover;
1720
import com.github.mikephil.charting.utils.MPPointF;
1821
import com.github.mikephil.charting.utils.Utils;
1922

@@ -26,6 +29,8 @@
2629
*/
2730
public class PieChart extends PieRadarChartBase<PieData> {
2831

32+
private String mode;
33+
2934
/**
3035
* rect object that represents the bounds of the piechart, needed for
3136
* drawing the circle
@@ -110,13 +115,24 @@ public PieChart(Context context, AttributeSet attrs) {
110115

111116
public PieChart(Context context, AttributeSet attrs, int defStyle) {
112117
super(context, attrs, defStyle);
118+
getAttrs(attrs);
113119
}
114120

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+
115131
@Override
116132
protected void init() {
117133
super.init();
118134

119-
mRenderer = new PieChartRenderer(this, mAnimator, mViewPortHandler);
135+
mRenderer = new PieChartRendererFixCover(this, mAnimator, mViewPortHandler);
120136
mXAxis = null;
121137

122138
mHighlighter = new PieHighlighter(this);

0 commit comments

Comments
 (0)