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

Re: using d3 bindings for js_of_ocaml



Can you detail your setup a little more.

What is your file structure?
How did you build your example? (Your make rules, or your compilation
command line.)
In particular, are you generating html? If so, why? From what
template/file/whatever?

I am not sure how to reproduce such results without these few explanations.

You can have a look at how the examples (in the tests/ directory of
the d3 bindings repository) are organised. The html is static and a
<script> tag at the beginning points to the appropriate javascript
file. The tests are silly because the html files have empty bodies
that are populated by the script, but the same structure should work.


On Tue, Jun 26, 2012 at 2:18 PM, Dimitar Popov <dpp23@xxxxxxxxx> 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
>
>
>



-- 
_______
Raphael



 


Rackspace

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