Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brush event started does not initiate "points" variable #102

Open
AntoineBergamaschi opened this issue Jul 31, 2023 · 1 comment
Open

Brush event started does not initiate "points" variable #102

AntoineBergamaschi opened this issue Jul 31, 2023 · 1 comment

Comments

@AntoineBergamaschi
Copy link

AntoineBergamaschi commented Jul 31, 2023

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
Copy link
Member

Fil commented Aug 1, 2023

Please share a minimal reproduction of the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants