Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular &引用;出口';鼠标&x27;在';中找不到(导入为';d3';);d3和x27;_Angular_Typescript_D3.js - Fatal编程技术网

Angular &引用;出口';鼠标&x27;在';中找不到(导入为';d3';);d3和x27;

Angular &引用;出口';鼠标&x27;在';中找不到(导入为';d3';);d3和x27;,angular,typescript,d3.js,Angular,Typescript,D3.js,我试图在angular中使用d3.mouse()函数,但这会导致错误 我也尝试过使用d3.pointer,但它说这个函数根本不存在 我已经使用npm在我的项目中安装了d3: npm install d3 && npm install @types/d3 --save-dev Thx提前 打字脚本代码: // Draw the X-axis on the DOM this.svg.append("g") .attr("transfo

我试图在angular中使用d3.mouse()函数,但这会导致错误

我也尝试过使用d3.pointer,但它说这个函数根本不存在

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

npm install d3 && npm install @types/d3 --save-dev
Thx提前

打字脚本代码:

 // 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。从:

移除d3.mouse,d3.touch,d3.touch,d3.clientPoint;添加d3.pointer和d3.pointer


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

我尝试使用d3.pointer,但无法使用,因为我的项目目标是@types/d3,没有鼠标或指针。我删除了它并开始使用d3库,然后我就可以使用d3.pointer()。asnwear的Thx在d3.nest中得到了帮助。它在v6中被删除,现在改用d3.group。这个答案为我指明了正确的方向。