Skip to content

Commit

Permalink
Merge branch 'main' into feature-996-consolidate-networks
Browse files Browse the repository at this point in the history
  • Loading branch information
asizemore committed May 8, 2024
2 parents 7b9a57e + 886aab8 commit ef1f2ad
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,17 @@ function TimeSlider(props: TimeSliderProps) {
debounce((domain: Bounds | null) => {
if (!domain) return;
const { x0, x1 } = domain;

// computing the offset of 2 pixel (SAFE_PIXEL) in domain (milliseconds)
// https://github.com/airbnb/visx/blob/86a851cb3bf622b013b186f02f955bcd6548a87f/packages/visx-brush/src/Brush.tsx#L14
const brushOffset =
xBrushScale.invert(2).getTime() - xBrushScale.invert(0).getTime();

// compensating the offset
// x0 and x1 are millisecond value
const startDate = millisecondTodate(x0);
const endDate = millisecondTodate(x1);
const startDate = millisecondTodate(x0 + brushOffset);
const endDate = millisecondTodate(x1 - brushOffset);

setSelectedRange({
// don't let range go outside the xAxisRange, if provided
start: xAxisRange
Expand Down

0 comments on commit ef1f2ad

Please sign in to comment.