Commit cde125d6 authored by isstuev's avatar isstuev

fix

parent cf2e70dc
...@@ -10,3 +10,5 @@ export const MINUTE = 60 * SECOND; ...@@ -10,3 +10,5 @@ export const MINUTE = 60 * SECOND;
export const HOUR = 60 * MINUTE; export const HOUR = 60 * MINUTE;
export const DAY = 24 * HOUR; export const DAY = 24 * HOUR;
export const WEEK = 7 * DAY; export const WEEK = 7 * DAY;
export const MONTH = 30 * DAY;
export const YEAR = 365 * DAY;
...@@ -3,6 +3,7 @@ import { useMemo } from 'react'; ...@@ -3,6 +3,7 @@ import { useMemo } from 'react';
import type { TimeChartData } from 'ui/shared/chart/types'; import type { TimeChartData } from 'ui/shared/chart/types';
import { WEEK, MONTH, YEAR } from 'lib/consts';
import formatNumberToMetricPrefix from 'lib/formatNumberToMetricPrefix'; import formatNumberToMetricPrefix from 'lib/formatNumberToMetricPrefix';
interface Props { interface Props {
...@@ -59,11 +60,11 @@ export default function useTimeChartController({ data, width, height }: Props) { ...@@ -59,11 +60,11 @@ export default function useTimeChartController({ data, width, height }: Props) {
const span = Number(extent[1]) - Number(extent[0]); const span = Number(extent[1]) - Number(extent[0]);
if (span > 365 * 24 * 60 * 60 * 1000) { if (span > YEAR) {
format = d3.timeFormat('%Y'); format = d3.timeFormat('%Y');
} else if (span > 30 * 24 * 60 * 60 * 1000) { } else if (span > 2 * MONTH) {
format = d3.timeFormat('%b'); format = d3.timeFormat('%b');
} else if (span > 7 * 24 * 60 * 60 * 1000) { } else if (span > WEEK) {
format = d3.timeFormat('%b %d'); format = d3.timeFormat('%b %d');
} else { } else {
format = d3.timeFormat('%a %d'); format = d3.timeFormat('%a %d');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment