javascript - D3.JS 读取 CSV 并选择行
问题描述
伙计们,
我尝试加载“cars2017.csv”并读取目标数据,例如行 [1] 列 [发动机气缸]。结果应显示“6”。但似乎我成功加载了 csv 文件,但无法访问选定的数据。那里发生了什么?
<html>
<script src='https://d3js.org/d3.v5.min.js'></script>
<style> circle {fill: lightblue; stroke: black;} </style>
<body >
<svg width=300 height=300>
</svg>
<script>
const csv = d3.csv("https://flunky.github.io/cars2017.csv", function(data,i){
console.log(csv); //looks good!
console.log(data[i]); //shows "undefined"
console.log(data[i].AverageHighwayMPG); //shows "errors"
});
</script>
</body>
</html>
解决方案
推荐阅读
- gettext - 为什么人们使用翻译占位符而不是简单的英语?
- machine-learning - 无法从 jupyter notebook 安装 lightgbm
- java - Java:告诉 JVM 将所有字段/方法视为公共的
- javascript - 节点错误:找不到模块 './clone.js'
- python - TypeError:linprog 的输入无效:A_ub 必须是数字二维数组,每行代表一个上限不等式约束
- css - 附加 CSS、JS、Bootstrap CDN 版本后,只有一个文件未正确呈现
- mongodb - 如何将数据从 JSR223 采样器传递到 JMeter 中的 Http Request 采样器
- php - SQL 查询中的条件
- php - 我面临执行 foreach 循环的问题
- python - 独立可执行文件中的 GIL