seliopou / ocaml-d3

OCaml bindings for D3.js
Other
74 stars 6 forks source link

Tyxml combinators #12

Open Drup opened 9 years ago

Drup commented 9 years ago

First two commits are from #10

It seems that this iteration of the interface doesn't explode too easily, so there we go!

It handles both usual selection and enter selection (with a hack). It allows both to put tyxml in d3 and d3 in tyxml (although you can break typing that way, see later).

The way to use this is the following: you create a function producing tyxml elements depending on data. Both the elements and the layout can change depending on the data. Deep hierarchy works fine.

let f data i = ....

Then you turn it into a d3 element: d3 f

At the moment, since tyxml element don't carry the type of data with them, it's possible to break typing by doing : d3 (inject ...). I'm not sure how I feel about that ...

Drup commented 9 years ago

Note that there is a bug I don't understand in https://github.com/Drup/ocaml-d3/commit/439b301ccdd5f9b50384407a15aa561c14eeef99 It only colors one rectangle, not all of them.

seliopou commented 9 years ago

I'm gonna take a look at this later tonight or tomorrow.

seliopou commented 9 years ago

Might be "getting" tyxml a bit more after browsing this. More soon.

Drup commented 9 years ago

Note that the example is quite contrived on purpose (in order to test both inject and d3).

Drup commented 9 years ago

Rebased.

Drup commented 9 years ago

In fact, the enter stuff doesn't really work and I can't manage to fix it properly. I tried to use append but without success. Do you have any propositions ?