Fix up start date logic for graphs excluding data
This commit is contained in:
parent
5460241f4c
commit
4d053ae126
|
@ -1,6 +1,6 @@
|
||||||
import { useMemo } from 'react'
|
import { useMemo } from 'react'
|
||||||
import { scaleTime, scaleLinear } from 'd3-scale'
|
import { scaleTime, scaleLinear } from 'd3-scale'
|
||||||
import { max } from 'lodash'
|
import { min, max } from 'lodash'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
|
|
||||||
import { formatPercent } from 'common/util/format'
|
import { formatPercent } from 'common/util/format'
|
||||||
|
@ -52,6 +52,8 @@ export function DailyChart(props: {
|
||||||
[startDate, dailyValues, excludeFirstDays]
|
[startDate, dailyValues, excludeFirstDays]
|
||||||
)
|
)
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
|
const minDate = min(data.map((d) => d.x))!
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
const maxDate = max(data.map((d) => d.x))!
|
const maxDate = max(data.map((d) => d.x))!
|
||||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||||
const maxValue = max(data.map((d) => d.y))!
|
const maxValue = max(data.map((d) => d.y))!
|
||||||
|
@ -61,7 +63,7 @@ export function DailyChart(props: {
|
||||||
<SingleValueHistoryChart
|
<SingleValueHistoryChart
|
||||||
w={width}
|
w={width}
|
||||||
h={height}
|
h={height}
|
||||||
xScale={scaleTime([startDate, maxDate], [0, width - MARGIN_X])}
|
xScale={scaleTime([minDate, maxDate], [0, width - MARGIN_X])}
|
||||||
yScale={scaleLinear([0, maxValue], [height - MARGIN_Y, 0])}
|
yScale={scaleLinear([0, maxValue], [height - MARGIN_Y, 0])}
|
||||||
data={data}
|
data={data}
|
||||||
Tooltip={pct ? DailyPercentTooltip : DailyCountTooltip}
|
Tooltip={pct ? DailyPercentTooltip : DailyCountTooltip}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user