【发布时间】:2013-09-28 06:08:45
【问题描述】:
我试图掌握d3.js 以获取可视化数据表示,并且在其中提供的教程之一中,我尝试运行其中一个将 .csv 文件作为输入的代码,然后使用所需的 svg 方法和在网页上显示它的 java 脚本。
好吧,当我尝试运行以下代码时,它没有成功。我的系统中安装了 xampp。我将 j3s.html 保存在 httpdocs 文件夹中,并将 .csv 文件保存在同一个文件夹中,但是一些它是如何不工作的。
我对 web 和 java 脚本完全陌生,但是这段代码很容易理解。下面是代码。
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
<div id="viz"></div>
<script type="text/javascript">
d3.text("auto_mpg_tmp.csv", function(datasetText) {
var parsedCSV = d3.csv.parseRows(datasetText);
var sampleHTML = d3.select("#viz")
.append("table")
.style("border-collapse", "collapse")
.style("border", "2px black solid")
.selectAll("tr")
.data(parsedCSV)
.enter().append("tr")
.selectAll("td")
.data(function(d){return d;})
.enter().append("td")
.style("border", "1px black solid")
.style("padding", "5px")
.on("mouseover", function(){d3.select(this).style("background-color", "aliceblue")})
.on("mouseout", function(){d3.select(this).style("background-color", "white")})
.text(function(d){return d;})
.style("font-size", "12px");
});
</script>
</body>
</html>
好吧,我的 XAMPP 也有很多问题,我尝试使用 this link 解决这些问题。 这是xampp服务器的错误日志。
4:17:41 PM [Apache] Error: Apache shutdown unexpectedly.
4:17:41 PM [Apache] This may be due to a blocked port, missing dependencies,
4:17:41 PM [Apache] improper privileges, a crash, or a shutdown by another method.
4:17:41 PM [Apache] Press the Logs button to view error logs and check
4:17:41 PM [Apache] the Windows Event Viewer for more clues
4:17:41 PM [Apache] If you need more help, copy and post this
4:17:41 PM [Apache] entire log window on the forums
【问题讨论】:
标签: javascript google-chrome d3.js xampp