Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 139982

D3 Typescript error when using d3.mouse: 'this' implicitly has type 'any' because it does not have a type annotation

$
0
0

I am using d3 in my react application, where I write code using Typescript. I have the following code:

function mousemove() {
        // recover coordinate we need
        var x0 = xScale.invert(d3.mouse(this)[0]);
        var i = bisect(data, x0, 1);
        var selectedData = data[i]
        focus
            .attr("cx", xScale(selectedData.dateCreated))
            .attr("cy", yScale(selectedData[value]))
        focusText
            .html("x:" + selectedData.x + "  -  " + "y:" + selectedData.y)
            .attr("x", xScale(selectedData.dateCreated) + 15)
            .attr("y", yScale(selectedData[value]))
}

d3.mouse(this)[0] throws the following error:

'this' implicitly has type 'any' because it does not have a type annotation.

Any suggestions to resolve it? This error is common typescript but I do not how to resolve it with d3.mouse function.


Viewing all articles
Browse latest Browse all 139982

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>