Localize chart tooltip.
parent
4ae7ad35ff
commit
a66d3155d0
|
@ -64,8 +64,14 @@ export default function BarChart({
|
||||||
} else {
|
} else {
|
||||||
const [label, value] = body[0].lines[0].split(':');
|
const [label, value] = body[0].lines[0].split(':');
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
+title[0],
|
||||||
|
new Date(+title[0]),
|
||||||
|
dateFormat(new Date(+title[0]), 'EEE MMMM d yyyy', locale),
|
||||||
|
);
|
||||||
|
|
||||||
setTooltip({
|
setTooltip({
|
||||||
title: title[0],
|
title: dateFormat(new Date(+title[0]), 'EEE MMMM d yyyy', locale),
|
||||||
value,
|
value,
|
||||||
label,
|
label,
|
||||||
labelColor: labelColors[0].backgroundColor,
|
labelColor: labelColors[0].backgroundColor,
|
||||||
|
@ -95,7 +101,7 @@ export default function BarChart({
|
||||||
distribution: 'series',
|
distribution: 'series',
|
||||||
time: {
|
time: {
|
||||||
unit,
|
unit,
|
||||||
tooltipFormat: 'ddd MMMM DD YYYY',
|
tooltipFormat: 'x',
|
||||||
},
|
},
|
||||||
ticks: {
|
ticks: {
|
||||||
callback: renderXLabel,
|
callback: renderXLabel,
|
||||||
|
@ -138,6 +144,7 @@ export default function BarChart({
|
||||||
options.scales.xAxes[0].time.unit = unit;
|
options.scales.xAxes[0].time.unit = unit;
|
||||||
options.scales.xAxes[0].ticks.callback = renderXLabel;
|
options.scales.xAxes[0].ticks.callback = renderXLabel;
|
||||||
options.animation.duration = animationDuration;
|
options.animation.duration = animationDuration;
|
||||||
|
options.tooltips.custom = renderTooltip;
|
||||||
|
|
||||||
onUpdate(chart.current);
|
onUpdate(chart.current);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
min-width: 140px;
|
min-width: 120px;
|
||||||
|
margin-right: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.value {
|
.value {
|
||||||
|
@ -15,5 +16,4 @@
|
||||||
|
|
||||||
.label {
|
.label {
|
||||||
font-size: var(--font-size-normal);
|
font-size: var(--font-size-normal);
|
||||||
padding-right: 20px;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue