You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The d3 API isn't quite as type-safe as I might have expected. Here's an example of a simple bit of code that doesn't behave the way I would expect. In particular, the function passed to datum is not applied to the data before its handed to the closure passed to data. I'm presumably fundamentally confused about what datum is supposed to be doing in D3, but the types don't help, and it's pretty disturbing to have typesafe code fail with null pointer errors....
open D3
open Printf
let logf k = ksprintf (fun s -> Firebug.console##log (Js.string s)) k
let view =
select ".foo"
|. selectAll "rect"
|. datum (fun l _ ->
logf "[datum] len:%d" (List.length l);
List.map (fun x -> (x,x)) l
)
|. data (fun x _ ->
logf "[data] len:%d" (List.length x);
x)
|. enter
|. append "rect"
|. attr "width" (fun _ (_,i) _ -> sprintf "%d" i)
let () =
run ~node:(Dom_html.document##body) view [1;2;3;4]
The text was updated successfully, but these errors were encountered:
The d3 API isn't quite as type-safe as I might have expected. Here's an example of a simple bit of code that doesn't behave the way I would expect. In particular, the function passed to datum is not applied to the data before its handed to the closure passed to data. I'm presumably fundamentally confused about what datum is supposed to be doing in D3, but the types don't help, and it's pretty disturbing to have typesafe code fail with null pointer errors....
The text was updated successfully, but these errors were encountered: