ReactChart2 - 线条不是注册元素

uni*_*ise 4 javascript reactjs chart.js

我似乎无法修复此错误,该错误仅在我部署后才发生,这让我发疯。我已经尝试了所有其他堆栈溢出建议中的所有内容,但没有成功。我在本地没有收到任何错误,但是当我部署到 Heroku 时,我收到错误“错误:“line”不是已注册的控制器。” 有任何想法吗?

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} />
        </>
    )
Run Code Online (Sandbox Code Playgroud)

Lee*_*lee 6

您需要导入并注册LineController