Skip to content

Commit bdc3485

Browse files
committed
Fixed issue concerning RadarChart offsets (issue PhilJay#679).
1 parent 78ca707 commit bdc3485

4 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎MPChartExample/src/com/xxmassdeveloper/mpchartexample/BarChartActivity.java‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import com.github.mikephil.charting.data.filter.Approximator;
3333
import com.github.mikephil.charting.data.filter.Approximator.ApproximatorType;
3434
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
35-
import com.github.mikephil.charting.utils.ColorTemplate;
3635
import com.github.mikephil.charting.utils.Highlight;
3736
import com.github.mikephil.charting.utils.ValueFormatter;
3837
import com.xxmassdeveloper.mpchartexample.custom.MyValueFormatter;

‎MPChartExample/src/com/xxmassdeveloper/mpchartexample/RadarChartActivitry.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ public boolean onOptionsItemSelected(MenuItem item) {
130130
}
131131
case R.id.actionToggleXLabels: {
132132
mChart.getXAxis().setEnabled(!mChart.getXAxis().isEnabled());
133+
mChart.notifyDataSetChanged();
133134
mChart.invalidate();
134135
break;
135136
}

‎MPChartLib/src/com/github/mikephil/charting/charts/PieRadarChartBase.java‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import com.github.mikephil.charting.animation.Easing;
1616
import com.github.mikephil.charting.components.Legend.LegendPosition;
17+
import com.github.mikephil.charting.components.XAxis;
1718
import com.github.mikephil.charting.data.ChartData;
1819
import com.github.mikephil.charting.data.DataSet;
1920
import com.github.mikephil.charting.data.Entry;
@@ -192,6 +193,14 @@ protected void calculateOffsets() {
192193

193194
float min = Utils.convertDpToPixel(10f);
194195

196+
if (this instanceof RadarChart) {
197+
XAxis x = ((RadarChart) this).getXAxis();
198+
199+
if (x.isEnabled()) {
200+
min = Math.max(Utils.convertDpToPixel(10f), x.mLabelWidth);
201+
}
202+
}
203+
195204
float offsetLeft = Math.max(min, legendLeft);
196205
float offsetTop = Math.max(min, legendTop);
197206
float offsetRight = Math.max(min, legendRight);
@@ -309,9 +318,10 @@ public void setRotationAngle(float angle) {
309318
}
310319

311320
/**
312-
* gets the raw version of the current rotation angle of the pie chart
313-
* the returned value could be any value, negative or positive, outside of the 360 degrees.
314-
* this is used when working with rotation direction, mainly by gestures and animations.
321+
* gets the raw version of the current rotation angle of the pie chart the
322+
* returned value could be any value, negative or positive, outside of the
323+
* 360 degrees. this is used when working with rotation direction, mainly by
324+
* gestures and animations.
315325
*
316326
* @return
317327
*/

‎MPChartLib/src/com/github/mikephil/charting/charts/RadarChart.java‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,6 @@ protected void onDraw(Canvas canvas) {
174174
drawDescription(canvas);
175175

176176
drawMarkers(canvas);
177-
178-
// canvas.drawBitmap(mDrawBitmap, 0, 0, mDrawPaint);
179177
}
180178

181179
/**
@@ -326,7 +324,7 @@ protected float getRequiredBottomOffset() {
326324

327325
@Override
328326
protected float getRequiredBaseOffset() {
329-
return mXAxis.mLabelWidth;
327+
return mXAxis.isEnabled() ? mXAxis.mLabelWidth : Utils.convertDpToPixel(10f);
330328
}
331329

332330
@Override

0 commit comments

Comments
 (0)