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

lockVisibleTimeRangeOnResize does not work with fixLeftEdge #991

Closed
edew opened this issue Jan 27, 2022 · 0 comments · Fixed by #1026
Closed

lockVisibleTimeRangeOnResize does not work with fixLeftEdge #991

edew opened this issue Jan 27, 2022 · 0 comments · Fixed by #1026
Assignees
Labels
bug Unexpected problem or unintended behavior.
Milestone

Comments

@edew
Copy link
Contributor

edew commented Jan 27, 2022

Lightweight Charts Version: 3.7.0
Steps/code to reproduce:

lockVisibleTimeRangeOnResize does not work as expected when

  1. it is enabled and fixLeftEdge is enabled and fixRightEdge is enabled.
  2. it is enabled and fixLeftEdge is enabled

See https://codesandbox.io/s/bold-wave-xcpb7?file=/index.html for code.

Create chart with these time scale options:

        timeScale: {
          fixLeftEdge: true,
          fixRightEdge: true,
          lockVisibleTimeRangeOnResize: true
        }

Listen for resize events:

      const resizeListener = () => {
        const { width, height } = container.getBoundingClientRect();
        chart.resize(width, height);
      };

      window.addEventListener("resize", resizeListener);

Resize the window.

Actual behavior:

The visible range is changed after resizing the chart.

Expected behavior:

The visible range should not be changed after resizing the chart.

Screenshots:

output

CodeSandbox/JSFiddle/etc link:

https://codesandbox.io/s/bold-wave-xcpb7?file=/index.html

@edew edew added the bug Unexpected problem or unintended behavior. label Jan 27, 2022
@timocov timocov added this to the 4.0 milestone Jan 27, 2022
timocov added a commit that referenced this issue Feb 21, 2022
Fixes #991

1. We couldn't rely on the state while updating the state without a proper verifying that the state is correct.
  Thus if we change width/barSpacing/rightOffset we have to mark visible
  range as invalidated to make sure that it will be updated on getting current logical/visible range.
2. To fix left edge to could rely on logical range rather than strict range.
  Visible range is a range of edges of a bar, not the middle.
@timocov timocov self-assigned this Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected problem or unintended behavior.
Projects
None yet
2 participants