【发布时间】:2021-08-12 21:45:56
【问题描述】:
错误文本:“TypeError: Cannot read property 'extend' of undefined (匿名函数) ./node_modules/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.js:587"
print of the error i'm getting
这就是我要导入包的组件。
import { Divider } from "@material-ui/core";
import { Bar } from "react-chartjs-2";
import "chartjs-plugin-datalabels";
const FieldsData = (props) => {
const getFirstChart = () => {
const labels = props.fails
? props.fails.failsByOcurrence.map((fail) => {
return fail.label;
})
: [];
const colors = ["#e8e15f", "#e8e15f", "#e64f3e", "#e64f3e", "#e64f3e"];
const data = {
labels,
datasets: [
{
label: "Intensidade de falhas por intervalo de comprimento",
barPercentage: 0.6,
data: props.fails
? props.fails.failsByLengthClass.map((x) => {
return x.value;
})
: [],
backgroundColor: colors,
},
],
};
const chartConfig = {
data: data,
options: {
responsive: false,
plugins: {},
},
};
return (
<div style={{ width: "90%", margin: "0 auto" }}>
<Bar data={data} options={chartConfig} />
</div>
);
};
return (
<div>
<Divider style={{ margin: "0.5rem 0" }} />
{getFirstChart()}
</div>
);
};
export default FieldsData;
我尝试使用
【问题讨论】:
-
请添加代码框或其他内容,并附上上下文和部分代码来帮助您。
-
我现在已经编辑了这个问题。抱歉缺少代码和细节。
-
请将错误以文本形式发布。代码/错误的图片并非毫无用处,因为它们不可搜索,并且给视力有限的用户增加了挫败感。
-
我已添加错误文本。感谢您的提示,这是我第二次在这里提出问题。谢谢