Separate neutralColor in candlestick chart
This commit is contained in:
parent
83ebea7fd2
commit
45a8960251
6 changed files with 62 additions and 9 deletions
|
@ -204,6 +204,7 @@ public class CandleStickChartActivity extends DemoBase implements OnSeekBarChang
|
|||
set1.setDecreasingPaintStyle(Paint.Style.FILL);
|
||||
set1.setIncreasingColor(Color.rgb(122, 242, 84));
|
||||
set1.setIncreasingPaintStyle(Paint.Style.STROKE);
|
||||
set1.setNeutralColor(Color.BLUE);
|
||||
//set1.setHighlightLineWidth(1f);
|
||||
|
||||
CandleData data = new CandleData(xVals, set1);
|
||||
|
|
|
@ -61,6 +61,7 @@ public class RealmDatabaseActivityCandle extends RealmBaseActivity {
|
|||
set.setDecreasingPaintStyle(Paint.Style.FILL);
|
||||
set.setIncreasingColor(Color.rgb(122, 242, 84));
|
||||
set.setIncreasingPaintStyle(Paint.Style.STROKE);
|
||||
set.setNeutralColor(Color.BLUE);
|
||||
|
||||
ArrayList<ICandleDataSet> dataSets = new ArrayList<ICandleDataSet>();
|
||||
dataSets.add(set); // add the dataset
|
||||
|
|
|
@ -45,7 +45,12 @@ public class CandleDataSet extends LineScatterCandleRadarDataSet<CandleEntry> im
|
|||
protected Paint.Style mDecreasingPaintStyle = Paint.Style.FILL;
|
||||
|
||||
/**
|
||||
* color for open <= close
|
||||
* color for open == close
|
||||
*/
|
||||
protected int mNeutralColor = ColorTemplate.COLOR_NONE;
|
||||
|
||||
/**
|
||||
* color for open < close
|
||||
*/
|
||||
protected int mIncreasingColor = ColorTemplate.COLOR_NONE;
|
||||
|
||||
|
@ -164,6 +169,21 @@ public class CandleDataSet extends LineScatterCandleRadarDataSet<CandleEntry> im
|
|||
|
||||
/** BELOW THIS COLOR HANDLING */
|
||||
|
||||
/**
|
||||
* Sets the one and ONLY color that should be used for this DataSet when
|
||||
* open == close.
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setNeutralColor(int color) {
|
||||
mNeutralColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNeutralColor() {
|
||||
return mNeutralColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the one and ONLY color that should be used for this DataSet when
|
||||
* open > close.
|
||||
|
|
|
@ -50,7 +50,12 @@ public class RealmCandleDataSet<T extends RealmObject> extends RealmLineScatterC
|
|||
protected Paint.Style mDecreasingPaintStyle = Paint.Style.FILL;
|
||||
|
||||
/**
|
||||
* color for open <= close
|
||||
* color for open == close
|
||||
*/
|
||||
protected int mNeutralColor = ColorTemplate.COLOR_NONE;
|
||||
|
||||
/**
|
||||
* color for open < close
|
||||
*/
|
||||
protected int mIncreasingColor = ColorTemplate.COLOR_NONE;
|
||||
|
||||
|
@ -200,6 +205,21 @@ public class RealmCandleDataSet<T extends RealmObject> extends RealmLineScatterC
|
|||
|
||||
/** BELOW THIS COLOR HANDLING */
|
||||
|
||||
/**
|
||||
* Sets the one and ONLY color that should be used for this DataSet when
|
||||
* open == close.
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
public void setNeutralColor(int color) {
|
||||
mNeutralColor = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNeutralColor() {
|
||||
return mNeutralColor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the one and ONLY color that should be used for this DataSet when
|
||||
* open > close.
|
||||
|
@ -217,7 +237,7 @@ public class RealmCandleDataSet<T extends RealmObject> extends RealmLineScatterC
|
|||
|
||||
/**
|
||||
* Sets the one and ONLY color that should be used for this DataSet when
|
||||
* open <= close.
|
||||
* open < close.
|
||||
*
|
||||
* @param color
|
||||
*/
|
||||
|
|
|
@ -29,17 +29,24 @@ public interface ICandleDataSet extends ILineScatterCandleRadarDataSet<CandleEnt
|
|||
*
|
||||
* @return
|
||||
*/
|
||||
public int getShadowColor();
|
||||
int getShadowColor();
|
||||
|
||||
/**
|
||||
* Returns the decreasing color.
|
||||
* Returns the neutral color (for open == close)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getNeutralColor();
|
||||
|
||||
/**
|
||||
* Returns the decreasing color (for open > close).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int getDecreasingColor();
|
||||
|
||||
/**
|
||||
* Returns the increasing color.
|
||||
* Returns the increasing color (for open < close).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -129,9 +129,9 @@ public class CandleStickChartRenderer extends LineScatterCandleRadarRenderer {
|
|||
|
||||
else
|
||||
mRenderPaint.setColor(
|
||||
dataSet.getShadowColor() == ColorTemplate.COLOR_NONE ?
|
||||
dataSet.getNeutralColor() == ColorTemplate.COLOR_NONE ?
|
||||
dataSet.getColor(j) :
|
||||
dataSet.getShadowColor()
|
||||
dataSet.getNeutralColor()
|
||||
);
|
||||
|
||||
} else {
|
||||
|
@ -187,7 +187,11 @@ public class CandleStickChartRenderer extends LineScatterCandleRadarRenderer {
|
|||
mRenderPaint);
|
||||
} else { // equal values
|
||||
|
||||
mRenderPaint.setColor(dataSet.getShadowColor());
|
||||
if (dataSet.getNeutralColor() == ColorTemplate.COLOR_NONE) {
|
||||
mRenderPaint.setColor(dataSet.getColor(j / 4 + minx));
|
||||
} else {
|
||||
mRenderPaint.setColor(dataSet.getNeutralColor());
|
||||
}
|
||||
|
||||
c.drawLine(
|
||||
mBodyBuffers[0], mBodyBuffers[1],
|
||||
|
|
Loading…
Add table
Reference in a new issue