我看到我的投票率下降了,请告诉我有关此问题的任何建议,或者您是否对此处提到的任何内容感到不高兴。谢谢您的歉意。
我正在尝试显示基于工作日的HTML表中已有的不同.csv文档之一的数据。
到目前为止,由于D3.js,我的代码允许显示.csv上的数据,尽管如此,我仍然可以看到下一个问题:
-由于某些原因,表格出现在页面底部...?
-我不知道如何只显示当天的一张桌子
这是我的HTML div:
<div id="T">Loading table...</div>
<!-- The table should appear here -->
这是我的脚本:
<script charset="utf-8">
function daySelection() {
var d = new Date();
var weekday = new Array(7);
weekday[0] = "<div id="Sun">Looking for Sunday data</div>";
weekday[1] = "<div id="Mon">Looking for Monday data</div>";
weekday[2] = "<div id="Tue">Looking for Tuesday data</div>";
weekday[3] = "<div id="Wed">Looking for Wednesday data</div>";
weekday[4] = "<div id="Thu">Looking for Thursday data</div>";
weekday[5] = "<div id="Fri">Looking for Friday data</div>";
weekday[6] = "<div id="Sat">Looking for Saturday data</div>";
var e = weekday[d.getDay()];
// We get the corresponding content for each day
document.getElementById("T").innerHTML = e;
// Print the content on the <div id="T">
}
window.onload = daySelection;
// Run everytime the page gets loaded
</script>
<script src="http://d3js.org/d3.v3.min.js">
// I get the D3.js
</script>
<script type="text/javascript" charset="utf-8">
d3.text("tmp3/Sun.csv", function(data) {
var parsedCSV = d3.csv.parseRows(data);
var container = d3.select("body")
.append("table")
.selectAll("tr")
.data(parsedCSV).enter()
.append("tr")
.selectAll("td")
.data(function(d) { return d; }).enter()
.append("td")
.text(function(d) { return d; });
// So far the .csv was converted to a HTML table
});
// I should now modify this script to make the table appear on the <div id="Sun"> and not at the end of the page, and apply these modifications for all the following scripts so that only 1 table appears, and the one that appears is the one on that day.
</script>
<!-- There are more scripts down here, one for every .csv document or day of the week -->
...
</body>
感谢您的帮助!祝你有愉快的一天! :D
—阿格斯