[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using d3 bindings for js_of_ocaml



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
> 
> 
> 




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.