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?
- Marcos Miguez asked 6 years ago
- You must login 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>(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
- Yura Khariton answered 6 years ago
- last edited 6 years ago
- 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.
- 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 login to post comments
Please login first to submit.