import * as React from 'react';
import PropTypes from 'prop-types';
import { PieChart } from '@mui/x-charts/PieChart';
import { useDrawingArea } from '@mui/x-charts/hooks';
import { styled } from '@mui/material/styles';
import Typography from '@mui/material/Typography';
import Card from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import Box from '@mui/material/Box';
import Stack from '@mui/material/Stack';
import LinearProgress, { linearProgressClasses } from '@mui/material/LinearProgress';
import {
IndiaFlag,
UsaFlag,
BrazilFlag,
GlobeFlag,
} from '../internals/components/CustomIcons';
const data = [
{ label: 'India', value: 50000 },
{ label: 'USA', value: 35000 },
{ label: 'Brazil', value: 10000 },
{ label: 'Other', value: 5000 },
];
const countries = [
{
name: 'India',
value: 50,
flag: ,
color: 'hsl(220, 25%, 65%)',
},
{
name: 'USA',
value: 35,
flag: ,
color: 'hsl(220, 25%, 45%)',
},
{
name: 'Brazil',
value: 10,
flag: ,
color: 'hsl(220, 25%, 30%)',
},
{
name: 'Other',
value: 5,
flag: ,
color: 'hsl(220, 25%, 20%)',
},
];
const StyledText = styled('text', {
shouldForwardProp: (prop) => prop !== 'variant',
})(({ theme }) => ({
textAnchor: 'middle',
dominantBaseline: 'central',
fill: (theme.vars || theme).palette.text.secondary,
variants: [
{
props: {
variant: 'primary',
},
style: {
fontSize: theme.typography.h5.fontSize,
},
},
{
props: ({ variant }) => variant !== 'primary',
style: {
fontSize: theme.typography.body2.fontSize,
},
},
{
props: {
variant: 'primary',
},
style: {
fontWeight: theme.typography.h5.fontWeight,
},
},
{
props: ({ variant }) => variant !== 'primary',
style: {
fontWeight: theme.typography.body2.fontWeight,
},
},
],
}));
function PieCenterLabel({ primaryText, secondaryText }) {
const { width, height, left, top } = useDrawingArea();
const primaryY = top + height / 2 - 10;
const secondaryY = primaryY + 24;
return (
{primaryText}
{secondaryText}
);
}
PieCenterLabel.propTypes = {
primaryText: PropTypes.string.isRequired,
secondaryText: PropTypes.string.isRequired,
};
const colors = [
'hsl(220, 20%, 65%)',
'hsl(220, 20%, 42%)',
'hsl(220, 20%, 35%)',
'hsl(220, 20%, 25%)',
];
export default function ChartUserByCountry() {
return (
Users by country
{countries.map((country, index) => (
{country.flag}
{country.name}
{country.value}%
))}
);
}