SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy

We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!

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.