我正在尝试使用d3plus.js将图表添加到我的网站。我收到以下错误消息:
Uncaught TypeError: Cannot read property 'buttons' of null
at SVGGElement.<anonymous> (d3plus.js:23745)
at SVGGElement.__onmousemove (d3.js:1120)
我尝试将脚本放置在页面的开头和页脚之后。
**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>
鼠标悬停时,标签应显示在图表上,但出现错误消息:
Uncaught TypeError: Cannot read property 'buttons' of null
at SVGGElement.<anonymous> (d3plus.js:23745)
at SVGGElement.__onmousemove (d3.js:1120)