From ad4cb719b6e275e4772a7eec9d32ec8e2d18f3b3 Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Wed, 28 Sep 2022 23:24:20 -0700 Subject: [PATCH] Fix tick formatting glitch --- web/components/charts/generic-charts.tsx | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/web/components/charts/generic-charts.tsx b/web/components/charts/generic-charts.tsx index 8bbfc659..161721f1 100644 --- a/web/components/charts/generic-charts.tsx +++ b/web/components/charts/generic-charts.tsx @@ -21,21 +21,9 @@ import { } from './helpers' import { useEvent } from 'web/hooks/use-event' -export type MultiPoint = { - x: Date - y: number[] - datum?: T -} -export type HistoryPoint = { - x: Date - y: number - datum?: T -} -export type DistributionPoint = { - x: number - y: number - datum?: T -} +export type MultiPoint = { x: Date; y: number[]; datum?: T } +export type HistoryPoint = { x: Date; y: number; datum?: T } +export type DistributionPoint = { x: number; y: number; datum?: T } const getTickValues = (min: number, max: number, n: number) => { const step = (max - min) / (n - 1) @@ -143,7 +131,9 @@ export const MultiValueHistoryChart = (props: { const pctTickValues = getTickValues(min, max, h < 200 ? 3 : 5) const xAxis = axisBottom(xScale).ticks(w / 100) const yAxis = pct - ? axisLeft(yScale).tickValues(pctTickValues).tickFormat(formatPct) + ? axisLeft(yScale) + .tickValues(pctTickValues) + .tickFormat((n) => formatPct(n)) : axisLeft(yScale) return { xAxis, yAxis } }, [w, h, pct, xScale, yScale]) @@ -233,7 +223,9 @@ export const SingleValueHistoryChart = (props: { const pctTickValues = getTickValues(min, max, h < 200 ? 3 : 5) const xAxis = axisBottom(xScale).ticks(w / 100) const yAxis = pct - ? axisLeft(yScale).tickValues(pctTickValues).tickFormat(formatPct) + ? axisLeft(yScale) + .tickValues(pctTickValues) + .tickFormat((n) => formatPct(n)) : axisLeft(yScale) return { xAxis, yAxis } }, [w, h, pct, xScale, yScale])