【问题标题】:Safe Stack with d3.js使用 d3.js 的安全堆栈
【发布时间】:2018-08-25 01:09:49
【问题描述】:

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

作为概念证明,我正在尝试整合这个条形图: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" ] ] ]
......

但我做了一些尝试,但无法编译。

有人知道怎么做吗?

谢谢

【问题讨论】:

    标签: f# fable-f#


    【解决方案1】:

    事实证明这其实很简单。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-10-21
      • 1970-01-01
      • 1970-01-01
      • 2020-12-04
      • 2013-08-19
      • 2011-05-08
      • 1970-01-01
      相关资源
      最近更新 更多