translate javascript to typescript

39 views
Skip to first unread message

Mallegriss

unread,
Mar 16, 2016, 5:42:51 AM3/16/16
to Polymer
Hi guys,

I'd like to know how to translate below piece code into typescript:

this.nodes = svg.selectAll(".node")
                        .data(this.forceLayout.nodes()) //<-- get all nodes in data
                        .enter().append("path")
                        .attr("class", "node")
                        .attr("d", function (d) { return d3.svg.symbol()
                                                 .size(d.size); })


I tried this:
.attr("d", (d) => { d3.svg.symbol()
                    .size(d.size)})

it turned out to be below, which doesn't work.
                    .attr("d", function (d) {
                                d3.svg.symbol()
                                    .size(d.size);})


Thanks,
M

Mallegriss

unread,
Mar 17, 2016, 5:52:18 AM3/17/16
to Polymer, vins...@gmail.com
sorted out.

 
.attr("d", d3.svg.symbol()
                    .size(d => d.size))

Justin Fagnani

unread,
Mar 17, 2016, 8:44:27 PM3/17/16
to Mallegriss, Polymer
Just wanted to point out that this isn't TypeScript specific, arrow functions are part of ES2015.

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/8c129908-c89a-4dfd-8bc1-cbd503a96845%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages