douju2014 2019-04-20 12:32
浏览 102

添加d3plus.js图表​​时为什么我的脚本没有加载?

I am trying to add a chart to my website using d3plus.js. I get the following error message:

Uncaught TypeError: Cannot read property 'buttons' of null
    at SVGGElement.<anonymous> (d3plus.js:23745)
    at SVGGElement.__onmousemove (d3.js:1120)

I have tried placing the script to the beginning of the page and to after the footer too.

**head.php**
    <script src="../wp-content/themes/sage/bower_components/d3/d3.js"> </script>
    <script src="../wp-content/themes/sage/bower_components/d3plus/d3plus.js"></script>

**page.php**
    <div id="viz" width="1356" height="579"></div>

    <script>
    var data = [
      {"year": 1991, "name":"alpha", "value": 15},
      {"year": 1991, "name":"beta", "value": 10},
      {"year": 1991, "name":"gamma", "value": 5},
      {"year": 1991, "name":"delta", "value": 50},
      {"year": 1992, "name":"alpha", "value": 20},
      {"year": 1992, "name":"beta", "value": 10},
      {"year": 1992, "name":"gamma", "value": 10},
      {"year": 1992, "name":"delta", "value": 43},
      {"year": 1993, "name":"alpha", "value": 30},
      {"year": 1993, "name":"beta", "value": 40},
      {"year": 1993, "name":"gamma", "value": 20},
      {"year": 1993, "name":"delta", "value": 17},
      {"year": 1994, "name":"alpha", "value": 60},
      {"year": 1994, "name":"beta", "value": 60},
      {"year": 1994, "name":"gamma", "value": 25},
      {"year": 1994, "name":"delta", "value": 32}
    ]
    var visualization = d3plus.viz()
      .container("#viz")
      .data(data)
      .type("bar")
      .id("name")
      .height(300)
      .width(1100)
      .x("year")
      .y("value")
      .draw()
    </script>

On mouseover, the label should appear on the chart, but I get the error message:

Uncaught TypeError: Cannot read property 'buttons' of null
    at SVGGElement.<anonymous> (d3plus.js:23745)
    at SVGGElement.__onmousemove (d3.js:1120)
  • 写回答

1条回答 默认 最新

  • doubu5154 2019-04-20 22:49
    关注

    The problem was caused by not using the right version of the d3.js and the d3plus.js. I have downloaded the latest versions of the scripts and now I am able to add charts to my website:)

    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看