import { useMemo, ReactNode } from "react" // @mui material components import Card from "@mui/material/Card" import Icon from "@mui/material/Icon" // ThreeD Garden components import MDBox from "~/components/mui/MDBox" import MDTypography from "~/components/mui/MDTypography" // PolarChart configurations import configs from "~/components/elements/Charts/PolarChart/configs" // react-chartjs-2 components import { PolarArea } from "react-chartjs-2" import { Chart as ChartJS, RadialLinearScale, ArcElement, // CategoryScale, // LinearScale, // PointElement, // LineElement, // BarElement, Title, Tooltip, Legend } from "chart.js" ChartJS.register( RadialLinearScale, ArcElement, // CategoryScale, // LinearScale, // PointElement, // LineElement, // BarElement, Title, Tooltip, Legend ) // Declaring props types for PolarChart interface Props { icon?: { color?: | "primary" | "secondary" | "info" | "success" | "warning" | "error" | "light" | "dark" component: ReactNode } title?: string description?: string | ReactNode chart: { labels: string[] datasets: { label: string backgroundColors: string[] data: number[] } } [key: string]: any } function PolarChart({ icon, title, description, chart }: Props): JSX.Element { const { data, options } = configs(chart.labels || [], chart.datasets || {}) const renderChart = ( {title || description ? ( {icon.component && ( {icon.component} )} {title && {title}} {description} ) : null} {useMemo( () => ( {/* options={options} */} ), [chart] )} ) return title || description ? {renderChart} : renderChart } // Declaring default props for PolarChart PolarChart.defaultProps = { icon: { color: "info", component: "" }, title: "", description: "", } export default PolarChart