【发布时间】:2020-07-26 04:58:38
【问题描述】:
我有一个口袋妖怪数据集,我想按类型对它们进行分组。所以会有一组类型为火、水、草等的口袋妖怪......并且d3.js有一个名为d3.group的函数。
在文档中它声明 Groups 将指定的值迭代到 Map 从键到值数组。我尝试关注此observable tutorial,但我不断收到错误Uncaught (in promise) TypeError: d3.group is not a function
我不知道我做错了什么。这是我的代码。 bar_chart.js
drawBarChart = async() => {
// 1. Access the data
const dataset = await d3.csv('./pokemon.csv');
console.log(dataset);
pokemon = d3.group(dataset, d => d.type1)
const metricAccesor = d => d.type1;
// 2. create the dimensions
const width = 600;
}
drawBarChart()
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div id="wrapper"></div>
<script src="http://d3js.org/d3.v5.min.js"></script>
<script src="./bar_chart.js"></script>
</body>
</html>
这是我在github上的代码
【问题讨论】:
标签: javascript d3.js