Skip to content

Commit

Permalink
Merge pull request #14 from Alex-NRCan/update-babel
Browse files Browse the repository at this point in the history
The registering of the Chart.js elements can't be part of the useEffect
  • Loading branch information
Alex-NRCan authored Oct 18, 2023
2 parents c639530 + 36f4daf commit b0d37ee
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 b0d37ee

Please sign in to comment.