小编Fel*_*omé的帖子

“在'd3'中找不到导出'鼠标'(导入为'd3')

我正在尝试在 angular 中使用 d3.mouse() 函数,但它引发了该错误。

我也尝试使用 d3.pointer,但它说该函数甚至不存在。

我已经使用 npm 在我的项目中安装了 d3:

npm install d3 && npm install @types/d3 --save-dev
Run Code Online (Sandbox Code Playgroud)

提前谢谢。

打字稿代码:

 // 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 …
Run Code Online (Sandbox Code Playgroud)

d3.js typescript angular

3
推荐指数
1
解决办法
3159
查看次数

标签 统计

angular ×1

d3.js ×1

typescript ×1