我正在尝试使用 Chart-js 和 React-chartjs-2 但显示以下错误:
编译失败。
./node_modules/react-chartjs-2/dist/index.modern.js
Module not found: Can't resolve 'chart.js/auto' in 'C:\Users\An\chart-react\project-folder\client\node_modules\react-chartjs-2\dist'
Run Code Online (Sandbox Code Playgroud)
我的代码:
import React from "react";
import { Bar } from "react-chartjs-2";
function ChartData() {
const data = {
labels: ["1", "2", "3", "4", "5", "6"],
datasets: [
{
label: "# of Votes",
data: [12, 19, 3, 5, 2, 3],
fill: false,
backgroundColor: "rgb(255, 99, 132)",
borderColor: "rgba(255, 99, 132, 0.2)",
},
],
};
const options = {
scales: {
yAxes: [
{
ticks: {
beginAtZero: …Run Code Online (Sandbox Code Playgroud)