Fix issue in LegendRenderer

This commit is contained in:
Philipp Jahoda 2016-06-10 16:03:19 +02:00
parent 4826f3be24
commit 694eb49162
2 changed files with 18 additions and 11 deletions

View file

@ -55,23 +55,23 @@ public class CandleDataSet extends LineScatterCandleRadarDataSet<CandleEntry> im
/**
* color for open == close
*/
protected int mNeutralColor = ColorTemplate.COLOR_NONE;
protected int mNeutralColor = ColorTemplate.COLOR_SKIP;
/**
* color for open < close
*/
protected int mIncreasingColor = ColorTemplate.COLOR_NONE;
protected int mIncreasingColor = ColorTemplate.COLOR_SKIP;
/**
* color for open > close
*/
protected int mDecreasingColor = ColorTemplate.COLOR_NONE;
protected int mDecreasingColor = ColorTemplate.COLOR_SKIP;
/**
* shadow line color, set -1 for backward compatibility and uses default
* color
*/
protected int mShadowColor = ColorTemplate.COLOR_NONE;
protected int mShadowColor = ColorTemplate.COLOR_SKIP;
public CandleDataSet(List<CandleEntry> yVals, String label) {
super(yVals, label);

View file

@ -2,6 +2,7 @@
package com.github.mikephil.charting.renderer;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Typeface;
@ -124,10 +125,15 @@ public class LegendRenderer extends Renderer {
labels.add(pds.getLabel());
}
} else if(dataSet instanceof ICandleDataSet && ((ICandleDataSet) dataSet).getDecreasingColor() != ColorTemplate.COLOR_NONE) {
} else if (dataSet instanceof ICandleDataSet && ((ICandleDataSet) dataSet).getDecreasingColor() !=
ColorTemplate.COLOR_NONE) {
int decreasingColor = ((ICandleDataSet) dataSet).getDecreasingColor();
colors.add(decreasingColor);
int increasingColor = ((ICandleDataSet) dataSet).getIncreasingColor();
colors.add(increasingColor);
colors.add(((ICandleDataSet) dataSet).getDecreasingColor());
colors.add(((ICandleDataSet) dataSet).getIncreasingColor());
labels.add(null);
labels.add(dataSet.getLabel());
@ -252,7 +258,7 @@ public class LegendRenderer extends Renderer {
: mLegend.mNeededWidth / 2.0 - xoffset);
}
break;
break;
}
switch (orientation) {
@ -288,8 +294,8 @@ public class LegendRenderer extends Renderer {
}
if (posX == originPosX &&
horizontalAlignment == Legend.LegendHorizontalAlignment.CENTER &&
lineIndex < calculatedLineSizes.length) {
horizontalAlignment == Legend.LegendHorizontalAlignment.CENTER &&
lineIndex < calculatedLineSizes.length) {
posX += (direction == Legend.LegendDirection.RIGHT_TO_LEFT
? calculatedLineSizes[lineIndex].width
: -calculatedLineSizes[lineIndex].width) / 2.f;
@ -311,7 +317,8 @@ public class LegendRenderer extends Renderer {
if (!isStacked) {
if (drawingForm)
posX += direction == Legend.LegendDirection.RIGHT_TO_LEFT ? -formToTextSpace : formToTextSpace;
posX += direction == Legend.LegendDirection.RIGHT_TO_LEFT ? -formToTextSpace :
formToTextSpace;
if (direction == Legend.LegendDirection.RIGHT_TO_LEFT)
posX -= calculatedLabelSizes[i].width;