Hi,

I suppose that will depend on the way we setup the drag handler. two cases; 
first one  is setted up like this :

 this.g = this.svg.selectAll(".dimension")
        .data(dimensions)
        .enter().append("g")
        .attr("id","toto")
        .attr("class", "dimension")
        .attr("transform", function(d) { return "translate(0," + _this.y(d.
id) + ")"; })
        .call(d3.drag()

          .on("start",(d, i) => this.dragstarted(d,i))
          .on("drag",(d, i) => this.dragstarted(d,i))
          .on("end", (d, i) => this.dragended(d, i)));


In this case, the dragstarted func will receive d as the dimension data 
associated to the g element.(not a dom event ...) 
and this keyword is pointing the whole component class. 

following the next example, I can receive the dom event target :-), but am 
unable to access the component class :-( , so unable to access some useful 
methods in the clas component:
 this.g = this.svg.selectAll(".dimension")
        .data(dimensions)
        .enter().append("g")
        .attr("id","toto")
        .attr("class", "dimension")
        .attr("transform", function(d) { return "translate(0," + _this.y(d.
id) + ")"; })
        .call(d3.drag()
          .on("start",this.dragstarted)
          .on("drag", this.dragged)
          .on("end", this.dragended));


Le vendredi 1 février 2019 16:29:49 UTC+1, Stéphane Ancelot a écrit :
>
> Hi,
> I have got to implement drag and drop in a svg d3js component.
>
> the svg elements are created dynamically . 
>
> I want to retrieve the transform attribute of the dragged element in the 
> drag handler.
>
> This would mean, I would need ElementRef of these dynamically allocated 
> element.
>
> I suppose , the solution needs ViewChildren ,  but I don't know how to 
> implement it.
>
> The elements are created using the following code :
>  this.g = this.svg.selectAll(".dimension")
>         .data(dimensions)
>         .enter().append("g")
>         .attr("class", "dimension")
>
>         .attr("transform", function(d) { return "translate(0," + _this.y(d
> .id) + ")"; })
>
> Regards
>

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to