question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Histogram (volume) does not honor color setting (sometimes)

See original GitHub issue

Lightweight 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.

volume_problem

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:closed
  • Created 4 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
timocovcommented, Nov 1, 2019

@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) 🙂

1reaction
timocovcommented, Nov 1, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Histogram Colors Not True - MATLAB Answers - MathWorks
I have a histogram, and I am trying to change its color using: set(get(gca,'child'),'FaceColor','k'). However, when I do this, the color ...
Read more >
Histogram - Wikipedia
... in digital image processing, see Image histogram and Color histogram. A histogram is an approximate representation of the distribution of numerical data....
Read more >
Pine script error when applying colors to volume bars
You did not have a color assigned for the case where pct>200 is false. na is used now but you can replace it...
Read more >
(PDF) Color histogram specification by histogram warping
method can be applied to color histogram equalization as well as color transfer from an example image or a color palette. ... most...
Read more >
Waindrops [Makit0] - TradingView
It can plot balanced or unbalanced waindrops, and volume profiles up to 24H ... Bullish Histogram color: histogram color when right vwap is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found