码迷,mamicode.com
首页 > 其他好文 > 详细

Cannot read property 'scales' of undefined

时间:2020-02-01 21:28:44      阅读:223      评论:0      收藏:0      [点我收藏+]

标签:text   for   ott   查找   get   code   addgroup   func   set   

该报错在 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

标签:text   for   ott   查找   get   code   addgroup   func   set   

原文地址:https://www.cnblogs.com/guangzan/p/12247371.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!