From 89c3ea559c166669b618fbd4e5ba8bde7250e479 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Wed, 28 Sep 2022 01:18:11 -0700 Subject: [PATCH] Clamp time range in history chart scales (#952) --- web/components/charts/contract/binary.tsx | 2 +- web/components/charts/contract/choice.tsx | 2 +- web/components/charts/contract/pseudo-numeric.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/web/components/charts/contract/binary.tsx b/web/components/charts/contract/binary.tsx index 372577c4..6d906998 100644 --- a/web/components/charts/contract/binary.tsx +++ b/web/components/charts/contract/binary.tsx @@ -56,7 +56,7 @@ export const BinaryContractChart = (props: { const containerRef = useRef(null) const width = useElementWidth(containerRef) ?? 0 const height = props.height ?? (isMobile ? 250 : 350) - const xScale = scaleTime(visibleRange, [0, width - MARGIN_X]) + const xScale = scaleTime(visibleRange, [0, width - MARGIN_X]).clamp(true) const yScale = scaleLinear([0, 1], [height - MARGIN_Y, 0]) return (
diff --git a/web/components/charts/contract/choice.tsx b/web/components/charts/contract/choice.tsx index 5786b7bb..7cf3e5ed 100644 --- a/web/components/charts/contract/choice.tsx +++ b/web/components/charts/contract/choice.tsx @@ -159,7 +159,7 @@ export const ChoiceContractChart = (props: { const containerRef = useRef(null) const width = useElementWidth(containerRef) ?? 0 const height = props.height ?? (isMobile ? 150 : 250) - const xScale = scaleTime(visibleRange, [0, width - MARGIN_X]) + const xScale = scaleTime(visibleRange, [0, width - MARGIN_X]).clamp(true) const yScale = scaleLinear([0, 1], [height - MARGIN_Y, 0]) return (
diff --git a/web/components/charts/contract/pseudo-numeric.tsx b/web/components/charts/contract/pseudo-numeric.tsx index 987a7fea..0e2aaad0 100644 --- a/web/components/charts/contract/pseudo-numeric.tsx +++ b/web/components/charts/contract/pseudo-numeric.tsx @@ -71,7 +71,7 @@ export const PseudoNumericContractChart = (props: { const containerRef = useRef(null) const width = useElementWidth(containerRef) ?? 0 const height = props.height ?? (isMobile ? 150 : 250) - const xScale = scaleTime(visibleRange, [0, width - MARGIN_X]) + const xScale = scaleTime(visibleRange, [0, width - MARGIN_X]).clamp(true) const yScale = contract.isLogScale ? scaleLog( [Math.max(contract.min, 1), contract.max],