Brush event started does not initiate "points" variable
AntoineBergamaschi opened this issue · 1 comments
AntoineBergamaschi commented
I have several issue with the initialization of points
in the started
function from brush. First, the Event passed to the started
brush function is a MouseEvent that does not have an identifier
property. Second ( maybe related to the first ), points
remains empty after the Array.from function making the brush rect dimension NAN
.
I don't know the exact origin of this probleme, i did change the brush.js
points
initialization to (skipping touche event for now ):
var point = pointer(t, that)
t.point0 = t.slice();
var points = [point];
Browser/D3 version versions:
Chrome Version 115.0.5790.110.
D3 7.8.5 (brush module 3.0.0)
Exemple of code that does not work
const component = document.querySelector(`#chart`);
svg.attr(`viewBox`, [0, 0, width, height]);
// Defined Scale
// Add Axis
const svgDim = svg.node().viewBox.baseVal;
const brush = d3.brush().extent([[5, 5], [svgDim.x + svgDim.width, svgDim.y + svgDim.height]])
brush.on("brush", function(brushEvent) {
//Do something
});
svg.append('g').attr('class', 'brush').call(brush);
component.appendChild(svg.node());
brush.js (src)
function started(event) {
...
var that = this,
...
points = Array.from(event.touches || [event], t => {
const i = t.identifier;
t = pointer(t, that);
t.point0 = t.slice();
t.identifier = i;
return t;
});
}
package.json
{
...
"dependencies": {
...
"d3": "7.8.5",
...
}
}
Fil commented
Please share a minimal reproduction of the issue.