From 36f4dafd05c4bbfecdb0a3000b0cc00eb7e7ba3e Mon Sep 17 00:00:00 2001 From: Alex Date: Wed, 18 Oct 2023 15:07:51 -0400 Subject: [PATCH] The registering of the Chart.js elements can't be part of the useEffect handle after all. --- src/chart.tsx | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src/chart.tsx b/src/chart.tsx index 6a074ab..c1acf2f 100644 --- a/src/chart.tsx +++ b/src/chart.tsx @@ -1,18 +1,7 @@ /* eslint-disable no-console */ // TODO: Remove the disable above import { Box } from '@mui/material'; -import { - Chart as ChartJS, - ChartDataset, - CategoryScale, - LinearScale, - PointElement, - LineElement, - BarElement, - Title, - Tooltip, - ArcElement, -} from 'chart.js'; +import { Chart as ChartJS, ChartDataset, registerables } from 'chart.js'; import { Chart as ChartReact } from 'react-chartjs-2'; import { GeoChartOptions, GeoChartType, GeoChartData, GeoChartAction, GeoChartDefaultColors } from './chart-types'; import { ChartValidator, ValidatorResult } from './chart-validator'; @@ -52,6 +41,9 @@ const sxClasses = { * @returns {JSX.Element} the created Chart element */ export function Chart(props: TypeChartChartProps): JSX.Element { + // Prep ChartJS + ChartJS.register(...registerables); + // Fetch cgpv // eslint-disable-next-line @typescript-eslint/no-explicit-any const w = window as any; @@ -273,11 +265,10 @@ export function Chart(props: TypeChartChartProps): JSX.Element { return
; }; - // Effect hook to add and remove event listeners - useEffect(() => { - // Prep ChartJS - ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, BarElement, Title, Tooltip, ArcElement); - }, []); + // // Effect hook to add and remove event listeners + // useEffect(() => { + + // }, []); return renderChartContainer(); }