Skip to content

Commit 45cdfca

Browse files
committed
Fixed issue concerning PieChart legend offsets (issue PhilJay#137).
1 parent 2719cef commit 45cdfca

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed
137 Bytes
Binary file not shown.

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ protected void calculateOffsets() {
179179
// setup offsets for legend
180180
if (mDrawLegend) {
181181

182-
float legendRight = 0f, legendBottom = 0f;
182+
float legendRight = 0f, legendBottom = 0f, legendTop = 0f;
183183

184184
if (mLegend == null)
185185
return;
@@ -193,6 +193,7 @@ protected void calculateOffsets() {
193193
+ mLegend.getFormSize() + mLegend.getFormToTextSpace() + spacing;
194194

195195
mLegendLabelPaint.setTextAlign(Align.LEFT);
196+
legendTop = mLegend.getFullHeight(mLegendLabelPaint);
196197

197198
} else if (mLegend.getPosition() == LegendPosition.BELOW_CHART_LEFT
198199
|| mLegend.getPosition() == LegendPosition.BELOW_CHART_RIGHT
@@ -208,8 +209,9 @@ protected void calculateOffsets() {
208209

209210
mLegend.setOffsetTop(min);
210211
mLegend.setOffsetLeft(min);
211-
212-
mOffsetTop = Math.max(mLegend.getFullHeight(mLegendLabelPaint), min);
212+
213+
mOffsetTop = Math.max(min, legendTop);
214+
mOffsetBottom = Math.max(min, legendBottom);
213215

214216
applyCalculatedOffsets();
215217
}

0 commit comments

Comments
 (0)