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

Price Scale Tick Gap Not Working as Expected in Lightweight Charts #1772

Open
ZhangPeibin opened this issue Jan 13, 2025 · 1 comment
Open

Comments

@ZhangPeibin
Copy link

Lightweight Charts™ Version: 4.2.0

I want to dynamically set the price interval on the scale based on the price range. For example:

If the price is in the thousands, the gap between price labels should be 1000.
If the price is in the tens of thousands, the gap should be 10000.

Currently, I cannot find a way to implement this behavior effectively. Attempts to use tickMarkFormatter or priceFormat seem to be ignored, as the chart dynamically adjusts the scale regardless of my configuration.

@SlicedSilver
Copy link
Contributor

You are correct. The library doesn't have a way for you to specify exactly which tick marks you want visible. The library will decide by itself based on the vertical space available, the price range, and the priceFormat options how many tick marks it will want to display.

One option you could do (but is a bit of work) is to write a plugin to render the price scale exactly how you prefer. Plugins have the ability to render in the price scale canvas so it would be possible to cover up the existing price scale and draw your own on top of it. Or even skip having a price scale and draw one on the main pane of the chart, like this: https://tradingview.github.io/lightweight-charts/plugin-examples/plugins/overlay-price-scale/example/

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

No branches or pull requests

2 participants