Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectAll type #16

Open
clayrat opened this issue Nov 4, 2015 · 1 comment
Open

selectAll type #16

clayrat opened this issue Nov 4, 2015 · 1 comment

Comments

@clayrat
Copy link

clayrat commented Nov 4, 2015

Hello, I'm a Purescript newbie, trying to rewrite some D3 snippets. I'm currently working on Arc and Pie chart examples, so I've added some wrappers for them in my fork. However, while transcribing http://bl.ocks.org/mbostock/3888852, I've ran into trouble with this part:

    svg.selectAll(".arc")
        .data(function(d) { return pie(d.ages); })
      .enter().append("path")
        .attr("class", "arc")
        .attr("d", arc)
        .style("fill", function(d) { return color(d.data.name); });

If I understand correctly, here we need something like bindData' :: forall oldData newData. (oldData -> newData) -> Selection oldData -> D3Eff (Update newData). However, selectAll always gives us Selection Void, not allowing to modify previously bound data. Can this type signature be made more elaborate?

@clayrat clayrat changed the title selectAll behaviour selectAll type Nov 6, 2015
@nwolverson
Copy link
Contributor

I have been using a couple of definitions locally that I intended to contribute at some point which I think are along the same lines:

bind' :: forall oldData newData. (oldData -> Array newData) -> Selection oldData -> D3Eff (Update newData)
bind' = ffi ["fn", "selection", ""] "selection.data(fn)"

selectAll' :: forall d. String -> Selection d -> D3Eff (Selection d)
selectAll' = ffi ["selector", "selection", ""] "selection.selectAll(selector)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants