gadfly361 / rid3

Reagent Interface to D3
MIT License
142 stars 6 forks source link

Use rid3 pie example with cljs advanced code optimizations fails #9

Closed orolle closed 6 years ago

orolle commented 6 years ago

Hi, I try to run your pie example with cljs compiler with advanced optimizations turned on but the pie misses labels. When trying with figwheel in development mode, I do not have any problems.

It seems some functions are optimized away by cljs compiler when optimizations turned on. I tried to include cljsjs/d3 dependency and require cljsjs.d3 namespace but I could not get it to work with optimizations for the pie example.

I believe the problem is caused by (.centroid label d) in text-label function.

gadfly361 commented 6 years ago

@orolle I have found the externs on cljsjs for d3 are not comprehensive, which means (in some cases) you will need to add your own externs for advanced compilation.

I have an extern for .centeroid here: https://github.com/gadfly361/rid3/blob/master/externs.js#L38

I used lein-externs to generate the externs in that file. I should note, that tool will create more externs than you actually need though.

orolle commented 6 years ago

@gadfly361 Thanks a lot that fixed the problem!