Pre loader

Column Chart color according to Candle chart



I’m trying to colorize my Column Chart according to my Candle Chart (red / green).
I’ve tried to create a Palette provider, but I don’t know how to get the corresponding item from my Candle Data.

How can I do this?

  • You must to post comments

Hi Marcos,

If assume that column and candle series have same x data and they are drawn with same xAxis and same resampling mode then you can just use current render pass data from candle series inside palette provider for column series:

class VolumePaletteProvider(private val stockSeries: FastCandlestickRenderableSeries, private val upColor: Int, private val downColor: Int) : PaletteProviderBase<FastColumnRenderableSeries>(, IStrokePaletteProvider, IFillPaletteProvider {
    private val colors = IntegerValues()

    override fun update() {
        val stockRenderPassData = stockSeries.currentRenderPassData
        if(stockRenderPassData is OhlcRenderPassData) {
            val size = stockRenderPassData.pointsCount()

            val openValues = stockRenderPassData.openValues.itemsArray
            val closeValues = stockRenderPassData.closeValues.itemsArray

            val itemsArray = colors.itemsArray
            for (i in 0..size-1) {
                itemsArray[i] = if (closeValues[i] >= openValues[i]) upColor else downColor

    override fun getFillColors(): IntegerValues = colors

    override fun getStrokeColors(): IntegerValues = colors

Is this suitable for you?

Best regards,

  • Marcos Miguez
    Thank you very much! It worked perfectly, but if I drag the chart very slowly I can see that some times the colors is different by 1 position. x data, xAxis and resampling mode are the same in both charts.
  • Yura Khariton
    That’s strange. Can you put a breakpoint into update() call and check if content of stockSeries.currentRenderPassData.indices (indices of points to draw for candle series) is the same as content of renderableSeries.currentRenderPassData.indices (indices of points to draw for column series )? I’m asking because for correct work of code above indices in currentRenderPassData should be the same
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies