Moved render functions into lib/charts.

This commit is contained in:
Mike Cao 2023-05-25 10:26:00 -07:00
parent 5a5127c921
commit 3ccdd95f49
6 changed files with 101 additions and 101 deletions

View file

@ -4,16 +4,12 @@ import classNames from 'classnames';
import Chart from 'chart.js/auto';
import HoverTooltip from 'components/common/HoverTooltip';
import Legend from 'components/metrics/Legend';
import { formatLongNumber } from 'lib/format';
import useLocale from 'hooks/useLocale';
import useTheme from 'hooks/useTheme';
import { DEFAULT_ANIMATION_DURATION } from 'lib/constants';
import { renderNumberLabels } from 'lib/charts';
import styles from './BarChart.module.css';
function defaultRenderYLabel(label) {
return +label > 1000 ? formatLongNumber(label) : label;
}
export function BarChart({
datasets,
unit,
@ -90,7 +86,7 @@ export function BarChart({
},
ticks: {
color: colors.text,
callback: renderYLabel || defaultRenderYLabel,
callback: renderYLabel || renderNumberLabels,
},
},
},