Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReactChart2 - Line is not a registered Element

I can't seem to fix this error which is only happening after I've deployed and it's driving me crazy. I've tried everything from all other stack overflow suggestions with no luck. I get no errors on local, however when I deploy to Heroku I get the error "Error: "line" is not a registered controller." Any ideas?

import React, { useState } from 'react';
import {
    Chart as ChartJS,
    CategoryScale,
    LinearScale,
    BarElement,
    Title,
    Tooltip,
    Legend,
    PointElement,
    LineElement,
} from 'chart.js';
ChartJS.register(
    CategoryScale,
    LinearScale,
    BarElement,
    PointElement,
    LineElement,
    Title,
    Tooltip,
    Legend,
);
import { Chart } from 'react-chartjs-2';
const staticData = [
        {
            type: 'line',
            label: 'Macleay Island Avg',
            backgroundColor: '#38A169',
            borderColor: '#38A169',
            order: 1
        },
        {
            type: 'bar',
            label: 'Macleay Island Total',
            backgroundColor: '#C6F6D5',
            order: 3

        },
        {
            type: 'line',
            label: 'Russell Island Avg',
            backgroundColor: '#F56565',
            borderColor: '#F56565',
            order: 2
        },
        {
            type: 'bar',
            label: 'Russell Island Total',
            backgroundColor: '#FED7D7',
            borderColor: 'rgb(14, 142, 205)',
            order: 4
        }
    ]
return (
        <>
            <Chart type='bar' data={graphData} />
        </>
    )
like image 828
unicorn_surprise Avatar asked Oct 14 '25 19:10

unicorn_surprise


1 Answers

You need to import and register the LineController

like image 78
LeeLenalee Avatar answered Oct 17 '25 08:10

LeeLenalee



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!