UNPKG

react-garden

Version:

React + TypeScript + ThreeJS app using Material UI on NextJS, Apollo Client, GraphQL + WordPress REST APIs, for ThreeD web development.. a part of the threed.ai code family.

100 lines (91 loc) 3.11 kB
// ** MUI Imports import Box from '@mui/material/Box' import Card from '@mui/material/Card' import CardHeader from '@mui/material/CardHeader' import Typography from '@mui/material/Typography' import CardContent from '@mui/material/CardContent' // ** Third Party Imports import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts' // ** Icons Imports import ArrowUp from 'mdi-material-ui/ArrowUp' // ** Custom Components Imports import CustomChip from '~/@core/components/mui/chip' const data = [ { pv: 280, name: '7/12' }, { pv: 200, name: '8/12' }, { pv: 220, name: '9/12' }, { pv: 180, name: '10/12' }, { pv: 270, name: '11/12' }, { pv: 250, name: '12/12' }, { pv: 70, name: '13/12' }, { pv: 90, name: '14/12' }, { pv: 200, name: '15/12' }, { pv: 150, name: '16/12' }, { pv: 160, name: '17/12' }, { pv: 100, name: '18/12' }, { pv: 150, name: '19/12' }, { pv: 100, name: '20/12' }, { pv: 50, name: '21/12' } ] const CustomTooltip = props => { // ** Props const { active, payload } = props if (active && payload) { return ( <div className='recharts-custom-tooltip'> <span>{`${payload[0].value}%`}</span> </div> ) } return null } const RechartsLineChart = ({ direction }) => { return ( <Card> <CardHeader title='Balance' titleTypographyProps={{ variant: 'h6' }} subheader='Commercial networks & enterprises' subheaderTypographyProps={{ variant: 'caption', sx: { color: 'text.disabled' } }} sx={{ flexDirection: ['column', 'row'], alignItems: ['flex-start', 'center'], '& .MuiCardHeader-action': { mb: 0 }, '& .MuiCardHeader-content': { mb: [2, 0] } }} action={ <Box sx={{ display: 'flex', alignItems: 'center' }}> <Typography variant='h6' sx={{ mr: 5 }}> $221,267 </Typography> <CustomChip skin='light' color='success' sx={{ fontWeight: 500, borderRadius: 1, fontSize: '0.875rem' }} label={ <Box sx={{ display: 'flex', alignItems: 'center' }}> <ArrowUp sx={{ fontSize: '1rem', mr: 1 }} /> <span>22%</span> </Box> } /> </Box> } /> <CardContent> <Box sx={{ height: 350 }}> <ResponsiveContainer> <LineChart height={350} data={data} style={{ direction }} margin={{ left: -20 }}> <CartesianGrid /> <XAxis dataKey='name' reversed={direction === 'rtl'} /> <YAxis orientation={direction === 'rtl' ? 'right' : 'left'} /> <Tooltip content={CustomTooltip} /> <Line dataKey='pv' stroke='#ff9f43' strokeWidth={3} /> </LineChart> </ResponsiveContainer> </Box> </CardContent> </Card> ) } export default RechartsLineChart