gpt4 book ai didi

angular - "export ' 鼠标 ' (imported as ' d3 ') was not found in ' d3'

转载 作者:行者123 更新时间:2023-12-04 01:12:52 26 4
gpt4 key购买 nike

我正在尝试在 angular 中使用 d3.mouse() 函数,但它引发了该错误。
我也尝试使用 d3.pointer,但它说该函数甚至不存在。
我已经使用 npm 在我的项目中安装了 d3:

npm install d3 && npm install @types/d3 --save-dev
提前谢谢。
typescript 代码:
 // Draw the X-axis on the DOM
this.svg.append("g")
.attr("transform", "translate(0," + this.height + ")")
.call(d3.axisBottom(x))
.selectAll("text")
.attr("transform", "translate(-10,0)rotate(-45)")
.style("text-anchor", "end")
.on('mousemove', function(d){

// recover coordinate we need
var mouse = d3.mouse(this);

var x0 = x.invert(mouse[0]); // invert transforma a cordenada no valor correspondente à ela no eixo X
var y0 = y.invert(mouse[1]);

// move o cursor pontilhado ao longo do svg conforme movimento do mouse
d3.select("[name=cursor]")
.attr("d", function() {
var d = "M" + mouse[0] + "," + svgHeight;
d += " " + mouse[0] + "," + 0;
return d;
});
});

最佳答案

您已经安装了 d3 版本 6。从 release notes :

Remove d3.mouse, d3.touch, d3.touches, d3.clientPoint; add d3.pointer and d3.pointers.


要么降级到 d3 版本 5,要么改用 d3.pointer

关于angular - "export ' 鼠标 ' (imported as ' d3 ') was not found in ' d3',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64270094/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com