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

[Feature] setVisibleRange #441

Closed
oneart-dev opened this issue May 30, 2023 · 3 comments
Closed

[Feature] setVisibleRange #441

oneart-dev opened this issue May 30, 2023 · 3 comments
Labels
duplicate This issue or pull request already exists

Comments

@oneart-dev
Copy link
Contributor

Feature Description

It would be super helpful to add function setVisibleRange(start, end).

I'm showing entry and exits on the chart and i would like to be able to focus exact range(trade) so user don't have to scroll every time.

To Do

  1. add setVisibleRange function
@oneart-dev
Copy link
Contributor Author

oneart-dev commented Jun 14, 2023

Found the solution for now:

    const { from, to } = range(); // timestamp values
    const bars = (to - from) / interval.IntervalMs;  
    const chartWidth = this.getChartWidth(); // use clientWidth to get chart width if responsive or fixed value
    const barSpace = chartWidth / bars;
    this.i.setBarSpace(Math.max(Math.min(barSpace, 50), 1)); // respect constraints
    this.i.scrollToTimestamp(to);

If you using markers timestamp it is good idea to add padding on both sides so it looks nice.
Code simplified and do not check if from and to exists in data list. You should check it if necessary.

@rascaler
Copy link

that's great, I will have a try

@liihuu liihuu added the duplicate This issue or pull request already exists label Nov 15, 2023
@liihuu
Copy link
Member

liihuu commented Nov 15, 2023

#430

@liihuu liihuu closed this as completed Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants