d3.js 的安全堆栈

Safe Stack with d3.js

我正在尝试将使用 d3 创建的数据可视化集成到 SAFE 堆栈默认模板中。

作为概念展示,我正在尝试整合此条形图:http://fable.io/fable-graphics/samples/d3/barchart/index.html

我已经能够将条形图的代码插入 client.fs:

let svg = Fable.Import.D3.Globals.select("#display")
                                 .append("svg")
                                 .attr("width", U3.Case1 width)
                                 .attr("height", U3.Case1 height)

一切都编译并运行良好,但我不知道如何使图像在生成的页面上可见。

我猜它必须被插入到视图中:

let view (model : Model) (dispatch : Msg -> unit) =
    div []
        [ Navbar.navbar [ Navbar.Color IsPrimary ]
            [ Navbar.Item.div [ ]
                [ Heading.h2 [ ]
                    [ str "SAFE Template" ] ] ]
......

但我已经尝试了几次,但无法编译。

有人知道怎么做吗?

谢谢

原来这其实很简单。

所需要的只是将选择器从“#display”更改为像 "body" 这样保证存在的东西

let svg = Fable.Import.D3.Globals.select("body")