Histogram (volume) does not honor color setting (sometimes)
See original GitHub issueLightweight Charts Version: “lightweight-charts”: “1.1.0”
Steps/code to reproduce: I can’t reproduce it easily, please bear with me until I can find a way to consistently reproduce this.
Context: typical volume histogram at the bottom of chart. There is a button in the UI that allows to switch timeframe. On click of a button, the volume serie (and candles) are changed.
The code is as follow:
// this is how the data is formatted for the chart
// snapshot is an OHLC array from an exchange
formatDataForChart (snapshot) {
return snapshot.reduce((acc, _candle) => {
const candle = Object.assign({}, _candle)
candle.time = candle.time / 1000
acc.candles.push(candle)
acc.volume.push({
time: candle.time,
value: candle.volumeQuote,
color: candle.open > candle.close ? volumeChartCfg.downColor : volumeChartCfg.upColor
})
return acc
}, {volume: [], candles: []})
}
// method called when user click to change timeframe
changeInterval (interval) {
this.chartInterval = interval
const snapshot = await ...
const chartData = this.formatDataForChart(snapshot)
this.candlestickSeries.setData(chartData.candles)
this.volumeSeries.setData(chartData.volume)
this.resetChartTimeScale(chartData)
}
Actual behavior: This works perfectly most of the time but sometimes, the chart does not use the color provided for the volume. (candles are fine). All bars are colored with one of the two colors provided. It is weird because it works most of the time and the bug(?) seems random.
Expected behavior: Bars should use the color provided.
Screenshots
Chart vs data provided.
You can see that the volume colors (array on the right) would match the candles color (which are automatically colored by the chart) but the chart draws them all with the same color.
Issue Analytics
- State:
- Created 4 years ago
- Comments:16 (9 by maintainers)
@AoDev I just created #242 with fixes. There you can find simplest repro for this bugs (see new files in
tests/e2e/graphics/test-cases/series
folder) 🙂@AoDev I’ve reproduced that issues. They are definitely bugs 😂 We’ll fix them. Thank you for your the time to investigate and reproduce that interesting issues. I’ll post updates about my investigates here soon.