package plotly
Binding for Plotly Open Source Graphing Library
Install
Dune Dependency
Authors
Maintainers
Sources
v1.0.0.tar.gz
md5=a3817f0fa4fb58615bfd7cb8e64f5856
sha512=40b0d2b4a3a33ae0d9eecdd39d233bfb072ac01cbfdaaad1fe10e0057a2ed9fadb685a9aed3b47cb7296757b78665b23630dc5a0a9bc3ec5f5a3f330c7c1c69d
doc/src/plotly.jsoo/jsoo.ml.html
Source file jsoo.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
(* https://plotly.com/javascript/plotlyjs-function-reference/ *) open Plotly open Js_of_ocaml module Html = Dom_html let rec conv_value v = let open Value in match v with | Value (Float, f) -> Js.Unsafe.inject f | Value (String, s) -> Js.Unsafe.inject @@ Js.string s | Value (Array ty, vs) -> let vs = Array.map (fun v -> conv_value (Value (ty, v))) vs in Js.Unsafe.inject @@ Js.array vs let obj_of_attributes (xs : Attribute.t list) : _ Js.t = Js.Unsafe.obj @@ Array.of_list @@ List.fold_left (fun acc (n, v) -> if List.mem_assoc n acc then assert false; (* warning? *) (n, conv_value v) :: acc) [] xs let obj_of_graph_object Graph.{type_; data} = obj_of_attributes @@ Attributes.string "type" type_ @ (data :> Attribute.t list) let obj_of_layout (layout : Plotly.Layout.t) = obj_of_attributes (layout :> Attribute.t list) type data type layout type config (* Plotly.newPlot(graphDiv, data, layout, config) *) type plotly = < newPlot : Html.divElement Js.t -> data Js.t Js.js_array Js.t -> layout Js.t -> config Js.t -> unit Js.meth; react : Html.divElement Js.t -> data Js.t Js.js_array Js.t -> layout Js.t -> config Js.t -> unit Js.meth; > let plotly : plotly Js.t = Js.Unsafe.pure_js_expr "Plotly" let create div fig = plotly##newPlot div (Js.array @@ Array.of_list @@ List.map obj_of_graph_object fig.Figure.graphs) (obj_of_layout fig.layout) (Js.Unsafe.obj [||])
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>