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

Add pan capability to charts #4186

Merged
merged 15 commits into from
Mar 5, 2024
Merged

Add pan capability to charts #4186

merged 15 commits into from
Mar 5, 2024

Conversation

djbarnwal
Copy link
Member

@djbarnwal djbarnwal commented Feb 27, 2024

Checklist

  • Manual verification
  • Unit test coverage
  • E2E test coverage
  • Needs manual QA?

Closes #4131

Details

Adds Pan interaction to chart using icon button and left-right key press

Steps to Verify

  1. On a dashboard hover over a chart and click the arrow icons
  2. The arrow icons should only allow to pan within all time range of the data.

Copy link
Contributor

@briangregoryholmes briangregoryholmes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to function well. I do have a question about the implementation, though.

Could you not replace the isRangeValid and canPanLeft/canPanRight with something like this:

$: startRange = $timeControlsStore?.allTimeRange?.start;
$: endRange = $timeControlsStore?.allTimeRange?.end;
$: selectedStart = $timeControlsStore.selectedTimeRange?.start;
$: selectedEnd = $timeControlsStore.selectedTimeRange?.end;

$: canPan = {
  left:
    (selectedStart?.getTime() || Infinity) >=
    (startRange?.getTime() || -Infinity),
  right:
    (selectedEnd?.getTime() || -Infinity) <=
    (endRange?.getTime() || Infinity),
};

That seems to be giving me the same results.

It would be great to hoist this out of the component, too. It only needs to be calculated once, but it's actually being recalculated every time you hover over the chart (though this is mostly because of the hovering check on line 60/61).

Also, we should put the select-none class on the MeasureChart div wrapper.

@djbarnwal djbarnwal changed the title Add pan capability to charts using arrow icons Add pan capability to charts Mar 4, 2024
@briangregoryholmes
Copy link
Contributor

@djbarnwal Looks good! Approved, but I'll let you merge in case you're still finishing up the testing tasks.

@djbarnwal
Copy link
Member Author

There's some more changes coming in for Chart interactions. I would merge this now and make the changes in the a later PR.

@djbarnwal djbarnwal merged commit 4a3a480 into main Mar 5, 2024
4 checks passed
@djbarnwal djbarnwal deleted the feat/pan-charts branch March 5, 2024 10:08
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

Successfully merging this pull request may close these issues.

Ability to cycle between defined time intervals across periods in the UI
2 participants