Skip to content
This repository has been archived by the owner on Apr 17, 2022. It is now read-only.

axis as function #5

Closed
daenenk opened this issue Nov 20, 2015 · 2 comments
Closed

axis as function #5

daenenk opened this issue Nov 20, 2015 · 2 comments

Comments

@daenenk
Copy link

daenenk commented Nov 20, 2015

In javascript axis as-is can be used as a function.
In scala this is supported by the apply functions.

trait Axis extends js.Any { 
 def apply(selection: Selection[js.Any]): Unit = js.native
 def apply(selection: Transition[js.Any]): Unit = js.native

However this makes it hard to pass an axis as argument to the selection.call() function,
as in e.g. from Simple d3.js Graph

svg
   .append("g")
   .attr("class", "x axis")
   .call(xAxis)

I suggest the following:

trait Axis extends js.Function1[ Selection[js.Any] | Transition[js.Any], Unit] 
@spaced spaced closed this as completed in ee4a091 Nov 21, 2015
@spaced
Copy link
Owner

spaced commented Nov 21, 2015

Tnx for feedback, Several other traits are functions too. Need to check it too.

@daenenk
Copy link
Author

daenenk commented Nov 27, 2015

Works fine now! thx

@spaced spaced mentioned this issue Dec 16, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants