在安装前请确保已安装最新版本的 Node.js 和 npm。确保您的项目中已安装了正确的依赖项,例如 React 和 React-dom。如果问题仍然存在,请尝试手动安装 Apex Charts,使用以下命令:
npm install apexcharts --save
在您的代码中,确保您已正确导入 Apex Charts:
import React from 'react';
import ReactApexChart from 'react-apexcharts';
class Chart extends React.Component {
constructor(props) {
super(props);
this.state = {
series: [{
data: [30, 40, 35, 50, 49]
}],
options: {
chart: {
height: 350,
type: 'bar',
},
plotOptions: {
bar: {
horizontal: false,
columnWidth: '55%',
endingShape: 'rounded'
},
},
dataLabels: {
enabled: false
},
stroke: {
show: true,
width: 2,
colors: ['transparent']
},
xaxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
},
yaxis: {
title: {
text: '$ (thousands)'
}
},
fill: {
opacity: 1
},
tooltip: {
y: {
formatter: function (val) {
return "$ " + val + " thousands"
}
}
}
},
};
}
render() {
return (
);
}
}
export default Chart;