Down stroke color for Android candlestick charts

Thread is closed for posting
2 posts, 0 answers
  1. Thean Hoo
    Thean Hoo avatar
    8 posts
    Member since:
    Jun 2015

    Posted 25 Jun 2015 Link to this post

    Is there a way to set a different (down stroke) color for Android candlestick charts, similar to OHLC charts?
  2. Victor
    Victor avatar
    1358 posts

    Posted 29 Jun 2015 Link to this post

    Hello Thean,

    Thanks for writing.
    You can currently specify a down stroke by overriding the candle stick renderer. For example:
    public class CandlestickPointRenderer extends OhlcPointRendererBase {
        private Paint bodyPaint = new Paint();
         * Creates a new instance of the {@link CandlestickPointRenderer} class.
         * @param series owner series.
        public CandlestickPointRenderer(CandlestickSeries series) {
         * Gets the current body paint.
         * @return the current body paint.
        public Paint getBodyPaint() {
            return this.bodyPaint;
         * Sets the current body paint.
         * @param paint the new body paint.
        public void setBodyPaint(Paint paint) {
            if (paint == null)
                throw new NullPointerException("paint");
            this.bodyPaint = paint;
        protected void renderPointCore(Canvas canvas, DataPoint point) {
            OhlcDataPoint ohlcPoint = (OhlcDataPoint) point;
            NumericalAxisOhlcPlotInfo plotInfo = ohlcPoint.getNumericalPlot();
            RectF pointSlot = Util.convertToRectF(point.getLayoutSlot());
            Paint strokePaint;
            Paint bodyPaint;
            if (getSeries().isPaletteApplied() && this.pointColors().containsKey(ohlcPoint)) {
                PaletteEntry entry = this.pointColors().get(ohlcPoint);
                int color = entry.getStroke();
                float strokeWidth = entry.getStrokeWidth();
                bodyPaint = new Paint();
                strokePaint = new Paint();
            } else {
                strokePaint = this.upStrokePaint;
                bodyPaint = this.bodyPaint;
            if (ohlcPoint.isFalling()) {
            } else {
            float stickUpperMiddle = (float) (Math.min(plotInfo.physicalOpen, plotInfo.physicalClose));
            float stickLowerMiddle = (float) (Math.max(plotInfo.physicalOpen, plotInfo.physicalClose));
            canvas.drawLine(pointSlot.centerX(),, pointSlot.centerX(), stickUpperMiddle, strokePaint);
            canvas.drawLine(pointSlot.centerX(), stickLowerMiddle, pointSlot.centerX(), pointSlot.bottom, strokePaint);
            canvas.drawRect(pointSlot.left, stickUpperMiddle, pointSlot.right, stickLowerMiddle, bodyPaint);

    This is the base implementation you can simply rename the class to CustomCandlestickRenderer for example and tell your series to use it like this:
    candleStickSeries.setDataPointRenderer(new CandlestickCustomRenderer(candleStickSeries));

    Please write again if you need further assistance.

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top