我正在尝试使用d3plus查询一个MySQL数据库并创建一个可视化。我的后端是Express.JS,模板是EJS
下面是我的错误:
ReferenceError: C:\cit\views\results.ejs:10
8|
9| <script>
>> 10| <% var data = [
11| {"year": 2011, "name":"jobs", "value": "2011"}
12| ]
13| var visualization = d3plus.viz()
d3plus is not defined
at eval (eval at compile (C:\cit\node_modules\ejs\lib\ejs.js:618:12), <anonymous>:31:24)
at returnedFn (C:\cit\node_modules\ejs\lib\ejs.js:653:17)
at tryHandleCache (C:\cit\node_modules\ejs\lib\ejs.js:251:36)
at View.exports.renderFile [as engine] (C:\cit\node_modules\ejs\lib\ejs.js:482:10)
at View.render (C:\cit\node_modules\express\lib\view.js:135:8)
at tryRender (C:\cit\node_modules\express\lib\application.js:640:10)
at Function.render (C:\cit\node_modules\express\lib\application.js:592:3)
at ServerResponse.render (C:\cit\node_modules\express\lib\response.js:1008:7)
at Query.con.query (C:\cit\app.js:24:13)
at Query.<anonymous> (C:\cit\node_modules\mysql\lib\Connection.js:502:10)我的results.ejs代码:
<% include partials/header.ejs %>
<h1>= <%= naics %></h1>
<h1>= <%= industry %></h1>
<div id="viz"></div>
<script>
<% var data = [
{"year": 2011, "name":"jobs", "value": "2011"}
]
var visualization = d3plus.viz()
.container("#viz")
.data(data)
.type("bar")
.id("name")
.x("year")
.y("value")
.draw() %>
</script>
<% include partials/footer.ejs %>以及我的包含d3plus脚本源代码的header.ejs代码:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="http://d3plus.org/js/d3.js"></script>
<script src="http://d3plus.org/js/d3plus.js"></script>
<title>The HTML5 Herald</title>
<meta name="description" content="The HTML5 Herald">
<meta name="author" content="SitePoint">
</head>
<body>现在我正在做一个可视化的硬拷贝,我仍然得到一个问题。问题会是什么呢?
附言:我也在我的脚注中添加了我的脚本源代码。以防万一这就是问题所在。不是这样的。
发布于 2018-12-16 22:55:37
我认为您正在使用d3plus v1。相反,您必须使用d3plus v2。
`new d3plus.BarChart() .select("#viz") .data(data) .x("year") .y("value") .groupBy("name") .render();`https://stackoverflow.com/questions/53748359
复制相似问题