Clamp time range in history chart scales

This commit is contained in:
Marshall Polaris 2022-09-28 01:15:11 -07:00
parent 9238b20242
commit 81e52fe9df
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],