Skip to content

Commit 38fef05

Browse files
committed
Stats & charts: horizontal axis improvements
1 parent 3a400a1 commit 38fef05

5 files changed

+7
-9
lines changed
Loading
Loading
Loading

ui/shared/chart/ChartWidgetGraph.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ const ChartWidgetGraph = ({
6363
const axesConfig = React.useMemo(() => {
6464
return {
6565
x: {
66-
ticks: isEnlarged ? 8 : 4,
66+
ticks: isEnlarged && !isMobile ? 8 : 4,
6767
},
6868
y: {
6969
ticks: isEnlarged ? 6 : 3,
7070
nice: true,
7171
},
7272
};
73-
}, [ isEnlarged ]);
73+
}, [ isEnlarged, isMobile ]);
7474

7575
const {
7676
ref,

ui/shared/chart/utils/timeChartAxis.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import _unique from 'lodash/uniq';
44

55
import type { AxesConfig, AxisConfig, TimeChartData } from '../types';
66

7-
import { WEEK, MONTH, YEAR } from 'lib/consts';
7+
import { MONTH, YEAR } from 'lib/consts';
88

99
export const DEFAULT_MAXIMUM_SIGNIFICANT_DIGITS = 2;
1010
export const DEFAULT_MAXIMUM_FRACTION_DIGITS = 3;
@@ -48,14 +48,12 @@ const tickFormatterX = (axis: d3.Axis<d3.NumberValue>) => (d: d3.AxisDomain) =>
4848

4949
const span = Number(extent[1]) - Number(extent[0]);
5050

51-
if (span > YEAR) {
51+
if (span > 2 * YEAR) {
5252
format = d3.timeFormat('%Y');
53-
} else if (span > 2 * MONTH) {
54-
format = d3.timeFormat('%b');
55-
} else if (span > WEEK) {
56-
format = d3.timeFormat('%b %d');
53+
} else if (span > 4 * MONTH) {
54+
format = d3.timeFormat('%b \'%y');
5755
} else {
58-
format = d3.timeFormat('%a %d');
56+
format = d3.timeFormat('%d %b');
5957
}
6058

6159
return format(d as Date);

0 commit comments

Comments
 (0)