Skip to content

Commit

Permalink
fix update on range shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
GrandSchtroumpf committed Jan 28, 2025
1 parent 6c52d54 commit 4c84cf8
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/components/strategies/common/d3Chart/D3PriceHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,22 @@ export const D3PriceHistory: FC<Props> = (props) => {
},
];

const zoomFromTo = async ({ start, end }: { start?: Date; end?: Date }) => {
if (!start || !end) return;
const zoomFromTo = async (range: { start?: Date; end?: Date }) => {
if (!range.start || !range.end) return;
setListenOnZoom(false);
const from = toUnixUTC(startOfDay(start));
const to = toUnixUTC(startOfDay(end));
await zoomRange(from, differenceInDays(end, start) + 1);
onRangeUpdates({ start: from, end: to });
const start = toUnixUTC(startOfDay(range.start));
const end = toUnixUTC(startOfDay(range.end));
await zoomRange(start, differenceInDays(range.end, range.start) + 1);
onRangeUpdates({ start, end });
setListenOnZoom(true);
};

const zoomIn = async (days: number) => {
setListenOnZoom(false);
await zoomRange(data.at(days * -1)!.date.toString(), days);
const start = data.at(days * -1)!.date.toString();
const end = data.at(-1)!.date.toString();
await zoomRange(start, days);
onRangeUpdates({ start, end });
setListenOnZoom(true);
};

Expand Down

0 comments on commit 4c84cf8

Please sign in to comment.