[英]Why doesn't my script load while adding d3plus.js chart?
I am trying to add a chart to my website using d3plus.js. 我正在尝试使用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)
The problem was caused by not using the right version of the d3.js and the d3plus.js. 该问题是由于未使用正确版本的d3.js和d3plus.js引起的。 I have downloaded the latest versions of the scripts and now I am able to add charts to my website:)
我已经下载了最新版本的脚本,现在可以在我的网站上添加图表了:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.