Fixed issue concerning all equal values (issue #409).
This commit is contained in:
parent
64f6ab0a41
commit
66d80a07bf
5 changed files with 22 additions and 11 deletions
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.xxmassdeveloper.mpchartexample"
|
||||
android:versionCode="37"
|
||||
android:versionCode="38"
|
||||
android:versionName="2.0.8" >
|
||||
|
||||
<uses-sdk
|
||||
|
|
|
@ -6,7 +6,7 @@ android {
|
|||
defaultConfig {
|
||||
minSdkVersion 16
|
||||
targetSdkVersion 21
|
||||
versionCode 37
|
||||
versionCode 38
|
||||
versionName '2.0.8'
|
||||
|
||||
sourceSets {
|
||||
|
|
|
@ -99,12 +99,14 @@ public class BarChartActivity extends DemoBase implements OnSeekBarChangeListene
|
|||
leftAxis.setLabelCount(8);
|
||||
leftAxis.setValueFormatter(custom);
|
||||
leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
|
||||
leftAxis.setSpaceTop(15f);
|
||||
|
||||
YAxis rightAxis = mChart.getAxisRight();
|
||||
rightAxis.setDrawGridLines(false);
|
||||
rightAxis.setTypeface(mTf);
|
||||
rightAxis.setLabelCount(8);
|
||||
rightAxis.setValueFormatter(custom);
|
||||
rightAxis.setSpaceTop(15f);
|
||||
|
||||
Legend l = mChart.getLegend();
|
||||
l.setPosition(LegendPosition.BELOW_CHART_LEFT);
|
||||
|
|
|
@ -311,6 +311,13 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleData<? exte
|
|||
|
||||
float leftRange = Math.abs(maxLeft - (mAxisLeft.isStartAtZeroEnabled() ? 0 : minLeft));
|
||||
float rightRange = Math.abs(maxRight - (mAxisRight.isStartAtZeroEnabled() ? 0 : minRight));
|
||||
|
||||
// in case all values are equal
|
||||
if (leftRange == 0f)
|
||||
maxLeft = maxLeft + 1f;
|
||||
|
||||
if (rightRange == 0f)
|
||||
maxRight = maxRight + 1f;
|
||||
|
||||
float topSpaceLeft = leftRange / 100f * mAxisLeft.getSpaceTop();
|
||||
float topSpaceRight = rightRange / 100f * mAxisRight.getSpaceTop();
|
||||
|
@ -356,7 +363,7 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleData<? exte
|
|||
offsetRight += mLegend.mTextWidthMax + mLegend.getXOffset() * 2f;
|
||||
|
||||
} else if (mLegend.getPosition() == LegendPosition.LEFT_OF_CHART
|
||||
|| mLegend.getPosition() == LegendPosition.LEFT_OF_CHART_CENTER) {
|
||||
|| mLegend.getPosition() == LegendPosition.LEFT_OF_CHART_CENTER) {
|
||||
|
||||
offsetLeft += mLegend.mTextWidthMax + mLegend.getXOffset() * 2f;
|
||||
|
||||
|
@ -370,11 +377,13 @@ public abstract class BarLineChartBase<T extends BarLineScatterCandleData<? exte
|
|||
|
||||
// offsets for y-labels
|
||||
if (mAxisLeft.needsOffset()) {
|
||||
offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft.getPaintAxisLabels());
|
||||
offsetLeft += mAxisLeft.getRequiredWidthSpace(mAxisRendererLeft
|
||||
.getPaintAxisLabels());
|
||||
}
|
||||
|
||||
if (mAxisRight.needsOffset()) {
|
||||
offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight.getPaintAxisLabels());
|
||||
offsetRight += mAxisRight.getRequiredWidthSpace(mAxisRendererRight
|
||||
.getPaintAxisLabels());
|
||||
}
|
||||
|
||||
float xlabelheight = mXAxis.mLabelHeight * 2f;
|
||||
|
|
|
@ -60,9 +60,9 @@ public class YAxisRenderer extends AxisRenderer {
|
|||
yMax = (float) p1.y;
|
||||
} else {
|
||||
|
||||
if (!mYAxis.isStartAtZeroEnabled())
|
||||
if (!mYAxis.isStartAtZeroEnabled()) {
|
||||
yMin = (float) Math.min(p1.y, p2.y);
|
||||
else
|
||||
} else
|
||||
yMin = 0;
|
||||
yMax = (float) Math.max(p1.y, p2.y);
|
||||
}
|
||||
|
@ -275,11 +275,11 @@ public class YAxisRenderer extends AxisRenderer {
|
|||
|
||||
float[] pts = new float[4];
|
||||
Path limitLinePath = new Path();
|
||||
|
||||
|
||||
for (int i = 0; i < limitLines.size(); i++) {
|
||||
|
||||
LimitLine l = limitLines.get(i);
|
||||
|
||||
|
||||
pts[1] = l.getLimit();
|
||||
pts[3] = l.getLimit();
|
||||
|
||||
|
@ -287,7 +287,7 @@ public class YAxisRenderer extends AxisRenderer {
|
|||
|
||||
pts[0] = mViewPortHandler.contentLeft();
|
||||
pts[2] = mViewPortHandler.contentRight();
|
||||
|
||||
|
||||
limitLinePath.moveTo(pts[0], pts[1]);
|
||||
limitLinePath.lineTo(pts[2], pts[3]);
|
||||
|
||||
|
@ -297,7 +297,7 @@ public class YAxisRenderer extends AxisRenderer {
|
|||
|
||||
c.drawPath(limitLinePath, mLimitLinePaint);
|
||||
limitLinePath.reset();
|
||||
// c.drawLines(pts, mLimitLinePaint);
|
||||
// c.drawLines(pts, mLimitLinePaint);
|
||||
|
||||
String label = l.getLabel();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue