[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: using d3 bindings for js_of_ocaml
I fixed it, I was using d3.v2.js, but with d3.js it works.
Thanks,
Dimitar
On Jun 26 2012, Anil Madhavapeddy wrote:
That's definitely flawed output, since the contents of the tag should
never leak javascript.
What happens if you just run:
let svg = select(Selector.tag "body")
>>append "svg"
>> attr "width" (fun _ _-> Some(w))
?
-anil
On 26 Jun 2012, at 13:18, Dimitar Popov wrote:
I am trying to use the bindings, but have some problems doing so. This
code:
let svg = select(Selector.tag "body")
>>append "svg"
>> attr "width" (fun _ _-> Some(w))
>> attr "height" (fun _ _-> Some (h)) in
svg>>subnodes "rect"
>> data dataset enter append "rect" >> attr "x" (fun d i ->
>> Some(i * (w / Array.length dataset)) ) attr "y" (fun d _
>> ->Some(h - (d * 4)))
>> attr "width" (fun _ _ -> Some(w /
>> Array.length dataset - barPadding))
>> attr "height" (fun d _ -> Some( d * 4))
>> attr "fill" (fun d _ ->Some( "rgb(0, 0, "
>> ^ string_of_int (d * 10) ^ ")")); ...
Produces weird results when I inspect the page : <svg width="function
(x) { return caml_call_gen(f, args.concat([x]));}" ...
all the parameters of the svg and the rect's are strings of functions.
What am I doing wrong?
Many thanks in advance!
Best wishes,
Dimitar
|