Commit baeb0c84 authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Stats & charts: horizontal axis improvements (#2478)

parent a49e6e10
...@@ -63,14 +63,14 @@ const ChartWidgetGraph = ({ ...@@ -63,14 +63,14 @@ const ChartWidgetGraph = ({
const axesConfig = React.useMemo(() => { const axesConfig = React.useMemo(() => {
return { return {
x: { x: {
ticks: isEnlarged ? 8 : 4, ticks: isEnlarged && !isMobile ? 8 : 4,
}, },
y: { y: {
ticks: isEnlarged ? 6 : 3, ticks: isEnlarged ? 6 : 3,
nice: true, nice: true,
}, },
}; };
}, [ isEnlarged ]); }, [ isEnlarged, isMobile ]);
const { const {
ref, ref,
......
...@@ -4,7 +4,7 @@ import _unique from 'lodash/uniq'; ...@@ -4,7 +4,7 @@ import _unique from 'lodash/uniq';
import type { AxesConfig, AxisConfig, TimeChartData } from '../types'; import type { AxesConfig, AxisConfig, TimeChartData } from '../types';
import { WEEK, MONTH, YEAR } from 'lib/consts'; import { MONTH, YEAR } from 'lib/consts';
export const DEFAULT_MAXIMUM_SIGNIFICANT_DIGITS = 2; export const DEFAULT_MAXIMUM_SIGNIFICANT_DIGITS = 2;
export const DEFAULT_MAXIMUM_FRACTION_DIGITS = 3; export const DEFAULT_MAXIMUM_FRACTION_DIGITS = 3;
...@@ -48,14 +48,12 @@ const tickFormatterX = (axis: d3.Axis<d3.NumberValue>) => (d: d3.AxisDomain) => ...@@ -48,14 +48,12 @@ const tickFormatterX = (axis: d3.Axis<d3.NumberValue>) => (d: d3.AxisDomain) =>
const span = Number(extent[1]) - Number(extent[0]); const span = Number(extent[1]) - Number(extent[0]);
if (span > YEAR) { if (span > 2 * YEAR) {
format = d3.timeFormat('%Y'); format = d3.timeFormat('%Y');
} else if (span > 2 * MONTH) { } else if (span > 4 * MONTH) {
format = d3.timeFormat('%b'); format = d3.timeFormat('%b \'%y');
} else if (span > WEEK) {
format = d3.timeFormat('%b %d');
} else { } else {
format = d3.timeFormat('%a %d'); format = d3.timeFormat('%d %b');
} }
return format(d as Date); return format(d as Date);
......
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