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.
120 lines (113 loc) • 3.06 kB
JavaScript
// ** MUI Imports
import Card from '@mui/material/Card'
import CardHeader from '@mui/material/CardHeader'
import CardContent from '@mui/material/CardContent'
// ** Third Party Imports
import { Line } from 'react-chartjs-2'
const ChartjsLineChart = props => {
// ** Props
const { white, primary, success, warning, labelColor, borderColor, gridLineColor } = props
const options = {
responsive: true,
backgroundColor: false,
maintainAspectRatio: false,
scales: {
x: {
ticks: { color: labelColor },
grid: {
borderColor,
color: gridLineColor
}
},
y: {
min: 0,
max: 400,
scaleLabel: { display: true },
ticks: {
stepSize: 100,
color: labelColor
},
grid: {
borderColor,
color: gridLineColor
}
}
},
plugins: {
legend: {
align: 'end',
position: 'top',
labels: {
padding: 25,
boxWidth: 10,
color: labelColor,
usePointStyle: true
}
}
}
}
const data = {
labels: [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140],
datasets: [
{
fill: false,
tension: 0.5,
pointRadius: 1,
label: 'Europe',
pointHoverRadius: 5,
pointStyle: 'circle',
borderColor: primary,
backgroundColor: primary,
pointHoverBorderWidth: 5,
pointHoverBorderColor: white,
pointBorderColor: 'transparent',
pointHoverBackgroundColor: primary,
data: [80, 150, 180, 270, 210, 160, 160, 202, 265, 210, 270, 255, 290, 360, 375]
},
{
fill: false,
tension: 0.5,
label: 'Asia',
pointRadius: 1,
pointHoverRadius: 5,
pointStyle: 'circle',
borderColor: warning,
backgroundColor: warning,
pointHoverBorderWidth: 5,
pointHoverBorderColor: white,
pointBorderColor: 'transparent',
pointHoverBackgroundColor: warning,
data: [80, 125, 105, 130, 215, 195, 140, 160, 230, 300, 220, 170, 210, 200, 280]
},
{
fill: false,
tension: 0.5,
pointRadius: 1,
label: 'Africa',
pointHoverRadius: 5,
pointStyle: 'circle',
borderColor: success,
backgroundColor: success,
pointHoverBorderWidth: 5,
pointHoverBorderColor: white,
pointBorderColor: 'transparent',
pointHoverBackgroundColor: success,
data: [80, 99, 82, 90, 115, 115, 74, 75, 130, 155, 125, 90, 140, 130, 180]
}
]
}
return (
<Card>
<CardHeader
title='New Technologies Data'
titleTypographyProps={{ variant: 'h6' }}
subheader='Commercial networks & enterprises'
subheaderTypographyProps={{ variant: 'caption' }}
/>
<CardContent>
<Line data={data} options={options} height={400} />
</CardContent>
</Card>
)
}
export default ChartjsLineChart