scala-js-d3
scala-js-d3 copied to clipboard
Should 'd3.scala' be a trait rather than object?
I had need recently to extend your library to use an additional D3 library however I couldn't 'Monkey Patch' your facade (as per https://www.scala-js.org/doc/interoperability/facade-types.html) as 'd3.scala' is an object and therefore not extendable.
Jquery (the example used in the ScalaJS documentaion) uses a trait which means it can be extended nicely.
Is there a reason d3 is an object?
PS; thanks for the awesome lib :)
thanks for your hint. because this part is over a year old. i tried to use annotations instead of doing some js.Dynamic magic. but your use case is very valid. I implemented the jquery approach. Have look at branch issue_28_trait_d3 https://github.com/spaced/scala-js-d3/tree/issue_28_trait_d3
does it helps?
thanks for your reply and your patch. Unfortunately in my environment I need to rely on the built repo version of 0.3.2 (because of my scala & sbt versions). I think you patch will help others though :)
I managed to get it working in my situation however; I used some implicit conversion magic: https://github.com/twrichards/emishviz/blob/master/client/src/main/scala/facades/d3/ImplicitAddons.scala - this allows me to call d3.slider() which will use my underlying implementation all other methods called on d3 object will use your impls. Neat right?