This theme is |

guangzan

园龄:6年5个月粉丝:676关注:333

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, 便于后续查找
      });

本文作者:guangzan

本文链接:https://www.cnblogs.com/guangzan/p/12247371.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   guangzan  阅读(1944)  评论(0编辑  收藏  举报
评论
收藏
关注
推荐
深色
回顶
收起
点击右上角即可分享
微信分享提示