Skip to content

Commit

Permalink
The registering of the Chart.js elements can't be part of the useEffe…
Browse files Browse the repository at this point in the history
…ct handle after all.
  • Loading branch information
Alex-NRCan committed Oct 18, 2023
1 parent 6ef59ed commit 36f4daf
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions src/chart.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -52,6 +41,9 @@ const sxClasses = {
* @returns {JSX.Element} the created Chart element
*/
export function Chart(props: TypeChartChartProps<GeoChartType>): JSX.Element {
// Prep ChartJS
ChartJS.register(...registerables);

// Fetch cgpv
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const w = window as any;
Expand Down Expand Up @@ -273,11 +265,10 @@ export function Chart(props: TypeChartChartProps<GeoChartType>): JSX.Element {
return <div />;
};

// 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();
}
Expand Down

0 comments on commit 36f4daf

Please sign in to comment.