Pre loader

Column Chart color according to Candle chart

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums

0
0

Hi,

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?

Version
2.0.0.1884
  • You must to post comments
1
0

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>(FastColumnRenderableSeries::class.java), IStrokePaletteProvider, IFillPaletteProvider {
    private val colors = IntegerValues()

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

            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,
Yura

  • 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