Following the D3v6 documentation, i am unable to implement a simple dragging behaviour on a path SVG element drawn using the d3.symbol util. The typescript class is shown here as a context. The events trigger on the correct element but the callback functions do not seem to receive the (event, datum) parameters. Any help would be greatly appreciated.
import * as d3 from "d3";
export default class Sliders {
svg: SVGSVGElement;
constructor(svg: SVGSVGElement){
this.svg = svg;
}
draw(){
const g = d3.select(this.svg).append('g').attr('class', 'symbol');
const circle = g.append('circle').attr('r', 200);
const D = d3.drag() // `event` and `d` are always undefined in 3 lines below
.on("start", (event, d) => circle.attr("stroke", "lime"))
.on("drag", (event, d: any) => (d.x = event.x, d.y = event.y))
.on("end", (event, d) => circle.attr("stroke", "black")) as any; // Could not fathom the proper type
circle.call(D);
}
}
question from:https://stackoverflow.com/questions/65830586/d3v6-drag-event-callback-function-fire-with-undefined-parameters