Can someone advise me with the issue. I need to get html element on which mouse pointer is located in the end of d3.xhr
request processing. And this d3.xhr
should calls within queue: async.queue
define([
"d3",
"lodash",
"async",
], function (d3, _, async) {
var html = d3.select("html");
async.queue(function (cell, callback) {
d3.xhr("/myurl", function (error, data) {
var data = _.merge(JSON.parse(data.response), cellDetails);
//processing data
console.log(d3.mouse(html)); //this line fails
}
}
The error that appears in console
Uncaught TypeError: Cannot read property 'sourceEvent' of null
k @ d3.v3.min.js:1
aa.mouse @ d3.v3.min.js:3
(anonymous function) @ myJSfile.js:77
(anonymous function) @ d3.v3.min.js:1
t @ d3.v3.min.js:1
u @ d3.v3.min.js:1
Generally task is hide tooltip properly, because now it doesn't disappear every time. In more details. We have a table:
<table>
<tr>
<td class="fav">Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td class="fav">Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
<tr>
<td class="fav">Data 1</td>
<td>Data 2</td>
<td>Data 3</td>
</tr>
</table>
<div class="tooltip" style="visibility:hidden"></div>
We should be able to navigate to the cell in the table, when mouseenter on cell then js sends request via d3.xhr within async queue. And as a result we have to show response in tooltip if mouse is still over the same cell. This verification needed because request/response takes some time and user may navigate to another cell or even go out of table borders. In that case we should hide tooltip.
I tried to add event like 'mouseenter', 'mouseleave' on the table, html and others element on page but it doesn't work ok for me. Easier to verify where mouse is on. Please help.