Update chart tooltip.

This commit is contained in:
Mike Cao 2020-09-13 20:09:18 -07:00
parent 0d4a2e2a0e
commit 38ec91c48e
2 changed files with 13 additions and 4 deletions

View file

@ -44,9 +44,9 @@ export default function BarChart({
return dateFormat(d, 'EEE M/d', locale);
case 'month':
if (w <= 660) {
return dateFormat(d, 'MMM', locale);
return index % 2 === 0 ? dateFormat(d, 'MMM', locale) : '';
}
return dateFormat(d, 'MMMM', locale);
return dateFormat(d, 'MMM', locale);
default:
return label;
}
@ -65,7 +65,7 @@ export default function BarChart({
const [label, value] = body[0].lines[0].split(':');
setTooltip({
title: dateFormat(new Date(+title[0]), 'EEE MMMM d yyyy', locale),
title: dateFormat(new Date(+title[0]), getTooltipFormat(unit), locale),
value,
label,
labelColor: labelColors[0].backgroundColor,
@ -73,6 +73,15 @@ export default function BarChart({
}
}
function getTooltipFormat(unit) {
switch (unit) {
case 'hour':
return 'EEE ha — MMM d yyyy';
default:
return 'EEE MMMM d yyyy';
}
}
function createChart() {
const options = {
animation: {