Skip to content

Commit 4484809

Browse files
committed
More bugfixes.
1 parent 191ec27 commit 4484809

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

MPChartExample/src/com/xxmassdeveloper/mpchartexample/LineChartActivity1.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ private void setData(int count, float range) {
342342
ll2.setTextSize(10f);
343343

344344
YAxis leftAxis = mChart.getAxisLeft();
345+
leftAxis.removeAllLimitLines(); // reset all limit lines to avoid overlapping lines
345346
leftAxis.addLimitLine(ll1);
346347
leftAxis.addLimitLine(ll2);
347348
leftAxis.setAxisMaxValue(220f);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ protected void onDraw(Canvas canvas) {
223223

224224
// canvas.drawBitmap(mDrawBitmap, 0, 0, mDrawPaint);
225225

226-
if (true) {
226+
if (mLogEnabled) {
227227
long drawtime = (System.currentTimeMillis() - starttime);
228228
totalTime += drawtime;
229229
drawCycles += 1;

MPChartLib/src/com/github/mikephil/charting/components/YAxis.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
package com.github.mikephil.charting.components;
33

44
import android.graphics.Paint;
5+
import android.util.Log;
56

67
import com.github.mikephil.charting.utils.DefaultValueFormatter;
78
import com.github.mikephil.charting.utils.Utils;
@@ -95,6 +96,12 @@ public enum AxisDependency {
9596
LEFT, RIGHT
9697
}
9798

99+
public YAxis() {
100+
super();
101+
this.mAxisDependency = AxisDependency.LEFT;
102+
this.mLimitLines = new ArrayList<LimitLine>();
103+
}
104+
98105
public YAxis(AxisDependency position) {
99106
super();
100107
this.mAxisDependency = position;
@@ -230,6 +237,11 @@ public boolean isStartAtZeroEnabled() {
230237
*/
231238
public void addLimitLine(LimitLine l) {
232239
mLimitLines.add(l);
240+
241+
if (mLimitLines.size() > 6) {
242+
Log.e("MPAndroiChart",
243+
"Warning! You have more than 6 LimitLines on your axis, do you really want that?");
244+
}
233245
}
234246

235247
/**
@@ -245,7 +257,7 @@ public void removeLimitLine(LimitLine l) {
245257
* Removes all LimitLines from the axis.
246258
*/
247259
public void removeAllLimitLines() {
248-
mLimitLines = new ArrayList<LimitLine>();
260+
mLimitLines.clear();
249261
}
250262

251263
/**

MPChartLib/src/com/github/mikephil/charting/renderer/YAxisRenderer.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import android.graphics.Color;
66
import android.graphics.Paint;
77
import android.graphics.Paint.Align;
8+
import android.graphics.Path;
89

910
import com.github.mikephil.charting.components.LimitLine;
1011
import com.github.mikephil.charting.components.LimitLine.LimitLabelPosition;
@@ -272,24 +273,30 @@ public void renderLimitLines(Canvas c) {
272273
return;
273274

274275
float[] pts = new float[4];
275-
276+
Path limitLinePath = new Path();
277+
276278
for (int i = 0; i < limitLines.size(); i++) {
277279

278280
LimitLine l = limitLines.get(i);
279-
281+
280282
pts[1] = l.getLimit();
281283
pts[3] = l.getLimit();
282284

283285
mTrans.pointValuesToPixel(pts);
284286

285287
pts[0] = mViewPortHandler.contentLeft();
286288
pts[2] = mViewPortHandler.contentRight();
289+
290+
limitLinePath.moveTo(pts[0], pts[1]);
291+
limitLinePath.lineTo(pts[2], pts[3]);
287292

288293
mLimitLinePaint.setColor(l.getLineColor());
289294
mLimitLinePaint.setPathEffect(l.getDashPathEffect());
290295
mLimitLinePaint.setStrokeWidth(l.getLineWidth());
291296

292-
c.drawLines(pts, mLimitLinePaint);
297+
c.drawPath(limitLinePath, mLimitLinePaint);
298+
limitLinePath.reset();
299+
// c.drawLines(pts, mLimitLinePaint);
293300

294301
String label = l.getLabel();
295302

0 commit comments

Comments
 (0)