How to set the color of candlestick for WPF

Posted by: oms on 4 February 2020, 9:20 pm EST

    • Post Options:
    • Link

    Posted 4 February 2020, 9:20 pm EST

    Hi! Can i change color of candlestick? For example, “green” color for bullish candlesticks and “red” color for bearish candlesticks, w/o border line.

  • Posted 5 February 2020, 4:46 pm EST - Updated 3 October 2022, 10:56 pm EST

    Hi,

    In order change color of candles(data points) based on saome condition(e.g. for bullish Close>Open) you can make use of Series.SymbolRendering event. In the event handler, you can set Fill/Stroke brushes for chart rendering engine as follows:

    private void Series_SymbolRendering(object sender, C1.WPF.Chart.RenderSymbolEventArgs e)
    {
     var dataItem = e.Item as DataItem;
     Brush brush = dataItem.Close > dataItem.Open ? Brushes.Green : Brushes.Red;
     e.Engine.SetFill(brush);
     e.Engine.SetStroke(brush);
    }
    
    

    Please verify the same with the attached sample.

    Regards,

    Basant

    prj_BullBearCandles.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels