Clamp time range in history chart scales (#952)

This commit is contained in:
Marshall Polaris 2022-09-28 01:18:11 -07:00 committed by GitHub
parent 9238b20242
commit 89c3ea559c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -56,7 +56,7 @@ export const BinaryContractChart = (props: {
const containerRef = useRef<HTMLDivElement>(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 (
<div ref={containerRef}>

View File

@ -159,7 +159,7 @@ export const ChoiceContractChart = (props: {
const containerRef = useRef<HTMLDivElement>(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 (
<div ref={containerRef}>

View File

@ -71,7 +71,7 @@ export const PseudoNumericContractChart = (props: {
const containerRef = useRef<HTMLDivElement>(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],