Cannot read property 'scales' of undefined
Posted guangzan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cannot read property 'scales' of undefined相关的知识,希望对你有一定的参考价值。
该报错在 antv f2 绘制柱状图文本是产生
原因: 在图表渲染之前绘制
解决:在 chart.render();
之后绘制
// ....
chart.render();
// 绘制柱状图文本
const offset = -5;
const canvas = chart.get("canvas");
const group = canvas.addGroup();
const shapes = {};
data.forEach(function(obj) {
const point = chart.getPosition(obj);
const text = group.addShape("text", {
attrs: {
x: point.x,
y: point.y + offset,
text: obj.confirmedCount,
textAlign: "center",
textBaseline: "bottom",
fill: "#808080"
}
});
shapes[obj.year] = text; // 缓存该 shape, 便于后续查找
});
以上是关于Cannot read property 'scales' of undefined的主要内容,如果未能解决你的问题,请参考以下文章
Uncaught TypeError: Cannot read property 'addEventListener'
Uncaught TypeError: Cannot read properties of undefined (reading 'getUserMedia')
axios报错: Cannot read property 'protocol' of undefined ....
解决报错Cannot read property 'forceUpdate' of undefined