f# - 使用 d3.js 的安全堆栈
问题描述
我正在尝试在 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" ] ] ]
......
但我做了一些尝试,无法编译。
有谁知道如何做到这一点?
谢谢
解决方案
事实证明这实际上很容易。
所需要的只是将选择器从“#display”更改为像“body”这样保证存在的东西
let svg = Fable.Import.D3.Globals.select("body")
推荐阅读
- javascript - 如何在 mongodb 中获取 ObjectId 属性以在 ejs 中显示
- java - 我无法连接到 H2 数据库
- trigonometry - 如何在 Maxima CAS 中求解三角方程组?
- flutter - Row() 中的容器在 Flutter 中不起作用
- json - Wordpress API 获取所有帖子
- http-post - 对盈透证券客户端 Web API 的任何 POST 请求的 403 响应代码
- regex - Flex 正则表达式用于包含空格的文本,例如“-.-.--.- -.-.--.-”
- python - 尝试使用 SMTP 和 Python 发送电子邮件时出现 SMTPNotSupportedError
- c# - 打印给出路径的文件和目录的数量
- php - 初学者 1 周:我的动态 php 代码有问题