尝试创建堆积的条形图,并且尝试以与其他模块相同的方式导入d3.stack()。
import {
select,
axisBottom,
scaleLinear,
axisLeft,
format,
scaleBand,
layout,
stack,
nest,
max,
schemeCategory10
} from 'd3';
当我尝试使用以下代码来调用stack()时,浏览器中的错误通知我:
Uncaught TypeError: stack is not a function
尝试创建stack()
const stack = stack()
.y(function (d) { return d[key] })
.values(function (d) { return d.values })
我尝试使用d3.stack(),layout.stack(),我使用的是5.16。
谢谢。
答案 0 :(得分:0)
已解决:如果无论如何按键都不正确,这就是生成的错误。它与错误提示所提示的模块导入不正确无关。 感谢所有人的帮助。