Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API to get color of the bar/candlestick item #518

Closed
nakcyber opened this issue Jul 8, 2020 · 5 comments
Closed

API to get color of the bar/candlestick item #518

nakcyber opened this issue Jul 8, 2020 · 5 comments
Labels
needs investigation Needs further investigation.

Comments

@nakcyber
Copy link

nakcyber commented Jul 8, 2020

Hi, lightweight-charts team
Is it possible to get barStyle() via an index in the series chart in lightweight-charts v3.1.2 ?
I used to barStyle() for get color in lightweight-charts v2.0.0

var candleSeries = chart.addCandlestickSeries();
var color = candleSeries.series().barColorer().barStyle(index);

example Information obtained from the barStyle()
{
barBorderColor: "rgb(229, 68, 95)"
barColor: "rgb(229, 68, 95)"
barWickColor: "rgb(229, 68, 95)"
}

Now it doesn't work. Can I have another method to use instead?

I want to get barStyle() method because my app chart has a legend feature a color the same as the bar color.

image
image
image

Lightweight Charts Version: 3.1.2

@timocov
Copy link
Contributor

timocov commented Jul 9, 2020

The issue we need to pay attention here is custom colors per bar item (available for histogram atm, but could be implemented in other series soon in #195). If you don't use custom colors - you can do it easily by getting color from options (for bars logic of choosing a color is pretty simple).

@timocov timocov added the needs investigation Needs further investigation. label Jul 9, 2020
@timocov timocov changed the title Support to get color barStyle API to get color of the bar/candlestick item Dec 9, 2020
@emrahtunc14
Copy link

How can I get the candle color on mouseover from charts that are like candle type?

@emrahtunc14
Copy link

any body here?

@SlicedSilver
Copy link
Contributor

At the moment, you can't get the colour directly from the API but you can work around this to get it working.

The colour of the candlestick is either based on whether the it is higher or lower than the previous value, or set by the data itself.

The crosshair event (https://tradingview.github.io/lightweight-charts/docs/api/interfaces/IChartApi#subscribecrosshairmove) contains a time property which you could use to either check the colour you've set in the data, or find the previous value and compare it's value to determine the expect colour.

@GanatraJay2000
Copy link

Hi! Has there been any new updates for this or do we still need to use the work-around??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs investigation Needs further investigation.
Projects
None yet
Development

No branches or pull requests

5 participants