Skip to content

Commit 9ee3a74

Browse files
authored
Merge pull request PhilJay#4013 from RobertZagorski/bugfix/PhilJay#2369-legend-offset-is-not-calculated-twice-for-line-chart
Remove mLabelRotatedHeight counted twice, when calculating legend offset
2 parents 73054be + 8943622 commit 9ee3a74

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -427,18 +427,12 @@ protected void calculateLegendOffsets(RectF offsets) {
427427
offsets.top += Math.min(mLegend.mNeededHeight,
428428
mViewPortHandler.getChartHeight() * mLegend.getMaxSizePercent())
429429
+ mLegend.getYOffset();
430-
431-
if (getXAxis().isEnabled() && getXAxis().isDrawLabelsEnabled())
432-
offsets.top += getXAxis().mLabelRotatedHeight;
433430
break;
434431

435432
case BOTTOM:
436433
offsets.bottom += Math.min(mLegend.mNeededHeight,
437434
mViewPortHandler.getChartHeight() * mLegend.getMaxSizePercent())
438435
+ mLegend.getYOffset();
439-
440-
if (getXAxis().isEnabled() && getXAxis().isDrawLabelsEnabled())
441-
offsets.bottom += getXAxis().mLabelRotatedHeight;
442436
break;
443437

444438
default:
@@ -478,21 +472,21 @@ public void calculateOffsets() {
478472

479473
if (mXAxis.isEnabled() && mXAxis.isDrawLabelsEnabled()) {
480474

481-
float xlabelheight = mXAxis.mLabelRotatedHeight + mXAxis.getYOffset();
475+
float xLabelHeight = mXAxis.mLabelRotatedHeight + mXAxis.getYOffset();
482476

483477
// offsets for x-labels
484478
if (mXAxis.getPosition() == XAxisPosition.BOTTOM) {
485479

486-
offsetBottom += xlabelheight;
480+
offsetBottom += xLabelHeight;
487481

488482
} else if (mXAxis.getPosition() == XAxisPosition.TOP) {
489483

490-
offsetTop += xlabelheight;
484+
offsetTop += xLabelHeight;
491485

492486
} else if (mXAxis.getPosition() == XAxisPosition.BOTH_SIDED) {
493487

494-
offsetBottom += xlabelheight;
495-
offsetTop += xlabelheight;
488+
offsetBottom += xLabelHeight;
489+
offsetTop += xLabelHeight;
496490
}
497491
}
498492

@@ -1224,7 +1218,7 @@ public boolean isDrawBordersEnabled() {
12241218

12251219
/**
12261220
* When enabled, the values will be clipped to contentRect,
1227-
* otherwise they can bleed outside the content rect.
1221+
* otherwise they can bleed outside the content rect.
12281222
*
12291223
* @param enabled
12301224
*/
@@ -1234,7 +1228,7 @@ public void setClipValuesToContent(boolean enabled) {
12341228

12351229
/**
12361230
* When enabled, the values will be clipped to contentRect,
1237-
* otherwise they can bleed outside the content rect.
1231+
* otherwise they can bleed outside the content rect.
12381232
*
12391233
* @return
12401234
*/

0 commit comments

Comments
 (0)