From 5d84b0055af13a999d61e3f92122870ab0682f72 Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Sun, 12 Apr 2015 16:50:00 +0300 Subject: [PATCH 1/2] Bugfix: Consider viewport for second point in cubic line --- .../github/mikephil/charting/renderer/LineChartRenderer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MPChartLib/src/com/github/mikephil/charting/renderer/LineChartRenderer.java b/MPChartLib/src/com/github/mikephil/charting/renderer/LineChartRenderer.java index cd57f01397..87ffc0f23a 100644 --- a/MPChartLib/src/com/github/mikephil/charting/renderer/LineChartRenderer.java +++ b/MPChartLib/src/com/github/mikephil/charting/renderer/LineChartRenderer.java @@ -168,8 +168,8 @@ protected void drawCubic(Canvas c, LineDataSet dataSet, List entries) { prevDx = (next.getXIndex() - cur.getXIndex()) * intensity; prevDy = (next.getVal() - cur.getVal()) * intensity; - cur = entries.get(1); - next = entries.get((entries.size() > 2) ? 2 : 1); + cur = entries.get(minx + 1); + next = entries.get(minx + (size - minx > 2 ? 2 : 1)); curDx = (next.getXIndex() - prev.getXIndex()) * intensity; curDy = (next.getVal() - prev.getVal()) * intensity; From 791a487456801a64c5bb50cc8c3a958da3e3a81c Mon Sep 17 00:00:00 2001 From: Daniel Cohen Gindi Date: Sun, 12 Apr 2015 16:54:25 +0300 Subject: [PATCH 2/2] Bugfix: Last label were sometimes invisible due to rounding errors --- .../src/com/github/mikephil/charting/utils/ViewPortHandler.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MPChartLib/src/com/github/mikephil/charting/utils/ViewPortHandler.java b/MPChartLib/src/com/github/mikephil/charting/utils/ViewPortHandler.java index ad1b26d577..d95468f0a3 100644 --- a/MPChartLib/src/com/github/mikephil/charting/utils/ViewPortHandler.java +++ b/MPChartLib/src/com/github/mikephil/charting/utils/ViewPortHandler.java @@ -379,6 +379,7 @@ public boolean isInBoundsLeft(float x) { } public boolean isInBoundsRight(float x) { + x = (float)((int)(x * 100.f)) / 100.f; return mContentRect.right >= x ? true : false; } @@ -387,6 +388,7 @@ public boolean isInBoundsTop(float y) { } public boolean isInBoundsBottom(float y) { + y = (float)((int)(y * 100.f)) / 100.f; return mContentRect.bottom >= y ? true : false; }