代码之家  ›  专栏  ›  技术社区  ›  John Palmer

带d3.js的安全堆栈

  •  0
  • John Palmer  · 技术社区  · 6 年前

    我正在尝试将用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" ] ] ]
    ......
    

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

    谢谢

    1 回复  |  直到 6 年前
        1
  •  1
  •   John Palmer    6 年前

    事实证明这很简单。

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

    let svg = Fable.Import.D3.Globals.select("body")
    
    推荐文章