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" // DefaultDoughnutChart configurations import configs from "~/components/elements/Charts/DoughnutCharts/DefaultDoughnutChart/configs" // react-chartjs-2 components import { Doughnut } from "react-chartjs-2" import { Chart as ChartJS, ArcElement, // CategoryScale, // LinearScale, // PointElement, // LineElement, // BarElement, Title, Tooltip, Legend } from "chart.js" ChartJS.register( ArcElement, // CategoryScale, // LinearScale, // PointElement, // LineElement, // BarElement, Title, Tooltip, Legend ) // Declaring props types for DefaultDoughnutChart interface Props { icon?: { color?: | "primary" | "secondary" | "info" | "success" | "warning" | "error" | "light" | "dark" component: ReactNode } title?: string description?: string | ReactNode height?: string | number chart: { labels: string[] datasets: { label: string backgroundColors: string[] data: number[] } cutout?: number } [key: string]: any } function DefaultDoughnutChart({ icon, title, description, height, chart, }: Props): JSX.Element { const { data, options } = configs( chart.labels || [], chart.datasets || {}, chart.cutout ) const renderChart = ( {title || description ? ( {icon.component && ( {icon.component} )} {title && {title}} {description} ) : null} {useMemo( () => ( {/* options={options} */} ), [chart, height] )} ) return title || description ? {renderChart} : renderChart } // Declaring default props DefaultDoughnutChart DefaultDoughnutChart.defaultProps = { icon: { color: "info", component: "" }, title: "", description: "", height: "19.125rem", } export default DefaultDoughnutChart