Localize x axis labels. Closes #1913

This commit is contained in:
Mike Cao 2023-04-19 11:41:31 -07:00
parent 083a9ffc2c
commit cc20f898b1
3 changed files with 38 additions and 7 deletions

View file

@ -1,3 +1,4 @@
import { useEffect } from 'react';
import { StatusLight } from 'react-basics';
import { colord } from 'colord';
import classNames from 'classnames';
@ -9,7 +10,7 @@ export default function Legend({ chart }) {
const { locale } = useLocale();
const forceUpdate = useForceUpdate();
function handleClick(index) {
const handleClick = index => {
const meta = chart.getDatasetMeta(index);
meta.hidden = meta.hidden === null ? !chart.data.datasets[index].hidden : null;
@ -17,7 +18,11 @@ export default function Legend({ chart }) {
chart.update();
forceUpdate();
}
};
useEffect(() => {
forceUpdate();
}, [locale]);
if (!chart?.legend?.legendItems.find(({ text }) => text)) {
return null;