Skip to content

Commit c522fac

Browse files
committed
Optional logging
1 parent e9b2a62 commit c522fac

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ public void calculateOffsets() {
517517

518518
float minOffset = UtilsKtKt.convertDpToPixel(mMinOffset);
519519

520-
getViewPortHandler().restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom));
520+
getViewPortHandler().restrainViewPort(Math.max(minOffset, offsetLeft), Math.max(minOffset, offsetTop), Math.max(minOffset, offsetRight), Math.max(minOffset, offsetBottom), false);
521521

522522
if (isLogEnabled()) {
523523
Timber.i("offsetLeft: " + offsetLeft + ", offsetTop: " + offsetTop + ", offsetRight: " + offsetRight + ", offsetBottom: " + offsetBottom);
@@ -911,7 +911,7 @@ public void setViewPortOffsets(final float left, final float top, final float ri
911911
@Override
912912
public void run() {
913913

914-
getViewPortHandler().restrainViewPort(left, top, right, bottom);
914+
getViewPortHandler().restrainViewPort(left, top, right, bottom, false);
915915
prepareOffsetMatrix();
916916
prepareValuePxMatrix();
917917
}

MPChartLib/src/main/java/com/github/mikephil/charting/charts/HorizontalBarChart.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,12 +177,16 @@ open class HorizontalBarChart : BarChart {
177177

178178
val minOffset = mMinOffset.convertDpToPixel()
179179

180+
if (isLogEnabled)
181+
Timber.i(viewPortHandler.toString())
180182
viewPortHandler.restrainViewPort(
181183
max(minOffset, offsetLeft),
182184
max(minOffset, offsetTop),
183185
max(minOffset, offsetRight),
184186
max(minOffset, offsetBottom)
185187
)
188+
if (isLogEnabled)
189+
Timber.i(viewPortHandler.toString())
186190

187191
if (isLogEnabled) {
188192
Timber.i("offsetLeft: $offsetLeft, offsetTop: $offsetTop, offsetRight: $offsetRight, offsetBottom: $offsetBottom")

MPChartLib/src/main/java/com/github/mikephil/charting/utils/ViewPortHandler.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.github.mikephil.charting.utils
33
import android.graphics.Matrix
44
import android.graphics.RectF
55
import android.view.View
6+
import timber.log.Timber
67
import kotlin.math.max
78
import kotlin.math.min
89

@@ -103,8 +104,10 @@ open class ViewPortHandler {
103104

104105
fun hasChartDimens(): Boolean = chartHeight > 0 && chartWidth > 0
105106

106-
fun restrainViewPort(offsetLeft: Float, offsetTop: Float, offsetRight: Float, offsetBottom: Float) {
107+
fun restrainViewPort(offsetLeft: Float, offsetTop: Float, offsetRight: Float, offsetBottom: Float, logging: Boolean = false) {
107108
contentRect[offsetLeft, offsetTop, chartWidth - offsetRight] = (chartHeight - offsetBottom)
109+
if (logging)
110+
Timber.i(contentRect.toString())
108111
}
109112

110113
fun offsetLeft(): Float = contentRect.left

0 commit comments

Comments
 (0)