mardi 12 juillet 2016

Using Ember data with D3.js nodes (Force Layout)

I want to link x and y attributes of nodes with my Ember.js Model.

var nodes = this.get('store').findAll('node');
var node = svg.selectAll(".node")
                .data(nodes)
                .enter().append("circle")
                .attr("class", "node")
                .attr("cx", function (d) {
                    return d.x;
                })
                .attr("cy", function (d) {
                    return d.y;
                })
                .attr("r", 7)
                .style("fill", function (d) {
                    return fill(1);
                })
                .style("stroke", function (d, i) {
                    return d3.rgb(fill(i)).darker(2);
                });

But I'm getting Uncaught TypeError: Cannot read property 'x' of undefined error in the console. I have x and y value defined in the model. Maybe I'm doing it completely wrong.

Basically all I want to do is use the x and y values from the model in the d3 plot.




Aucun commentaire:

Enregistrer un commentaire