Currently, I am making a code that automatically draws input values into a chart when input is received through react. I'm trying to add a saved chart using usestate for testing, but I can't proceed with the error <"Line" is not a registered controller.>.
Any way to fix this error?
Here's the code:
import {CreatChart} from './WidgetCRUD'
import Chart from 'chart.js/auto'
import {Radar,Line,Pie,Doughnut,PolarArea, Bar} from 'react-chartjs-2'
const options =
{
responsive: true,
scales:
{
yAxes:
[
{
ticks:
{
beginAtZero: true,
},
},
],
},
}
const data =
{
labels: ['1', '2', '3', '4', '5', '6', '7' , '8', '9','10'],
datasets: [
{
type: 'line',
label: 'Dataset 1',
borderColor: 'rgb(54, 162, 235)',
borderWidth: 2,
data: [30, 9, 24, 50,-20,20, 17, 45, 49],
}
],
}
const main = () =>
{
const [createChart, setCreateChart] = useState([])
setCreateChart(<Line data = {data} options={options} style={{ position: "relative"}}/>)
return (
<div>{createChart}</div>
)
}