Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The registering of the Chart.js elements can't be part of the useEffect #14

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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