0
joocを使用してd3-forceのサブセットをラップするのに問題があります。ライブラリはオブジェクトのプロパティを使用せず、代わりに融合されたgetter-setter関数を実装します。融合getter-setter関数をラップする
simulation.force("x", d3.forceX()) // setter
simulation.force("x") // getter
OCamlで同じ種類の多型をエミュレートする方法を知りたいと思います。ここで私は現在、
module Force = struct
class type force = object
(* not important *)
end
let x(): force Js.t = Js.Unsafe.meth_call __d3 "forceX" [||]
class type simulation = object
method force : string -> #force Js.t -> unit Js.meth
end
let simulation nodes: simulation Js.t =
Js.Unsafe.(meth_call __d3 "forceSimulation" [|inject nodes|])
end
を持っているものだと、ここで私は何の文字列はocamlのものと互換性がありませんJavaScriptの
let s = Force.simulation nodes in begin
s##force "x" (Force.x())
s##force "x" (* wishful thinking *)
end
ありがとう、本当にありがとう! –