Skip to content

Commit 5b6ab3c

Browse files
committed
Fixed issue that caused candle-body not to be drawn.
1 parent 80d3217 commit 5b6ab3c

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

MPChartLib/src/com/github/mikephil/charting/data/CandleEntry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ public class CandleEntry extends Entry {
2626
* @param xIndex The index on the x-axis.
2727
* @param shadowH The (shadow) high value.
2828
* @param shadowL The (shadow) low value.
29-
* @param open
30-
* @param close
29+
* @param open The open value.
30+
* @param close The close value.
3131
*/
3232
public CandleEntry(int xIndex, float shadowH, float shadowL, float open, float close) {
3333
super((shadowH + shadowL) / 2f, xIndex);

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

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

44
import android.graphics.Canvas;
5+
import android.graphics.Color;
56
import android.graphics.Paint;
67

78
import com.github.mikephil.charting.animation.ChartAnimator;
@@ -137,7 +138,7 @@ protected void drawDataSet(Canvas c, CandleDataSet dataSet) {
137138
// draw the body
138139
c.drawRect(leftBody, close, rightBody, open, mRenderPaint);
139140

140-
} else {
141+
} else if(open < close) {
141142

142143
if (dataSet.getIncreasingColor() == ColorTemplate.COLOR_NONE) {
143144
mRenderPaint.setColor(dataSet.getColor(j / 4 + minx));
@@ -148,6 +149,11 @@ protected void drawDataSet(Canvas c, CandleDataSet dataSet) {
148149
mRenderPaint.setStyle(dataSet.getIncreasingPaintStyle());
149150
// draw the body
150151
c.drawRect(leftBody, open, rightBody, close, mRenderPaint);
152+
} else { // equal values
153+
154+
mRenderPaint.setColor(Color.BLACK);
155+
mRenderPaint.setStyle(Paint.Style.STROKE);
156+
c.drawLine(leftBody, open, rightBody, close, mRenderPaint);
151157
}
152158
}
153159
}

0 commit comments

Comments
 (0)