d3.js - d3从绑定数据中一一添加svg元素的速度
问题描述
我在 WASM C++ 代码中有一些需要显示的数据。显示是静态的,所以绑定不是很重要。我很好奇两种方法的运行时间(以及人们认为值得考虑的任何其他因素)。两个选项是:让 C++ 代码将数据放入 JavaScript 数组(调用它theData
),然后调用类似
svg.selectAll("bars")
.data(theData)
.enter()
.append("rect")
.attr("x", ...)
.attr("y", ...)
.attr("width", ...)
.attr("height", ...)
或者WASM 代码是否应该调用一个 JS 函数来生成每个元素:
function newRect(x, y, width, height) {
svg.append("rect")
.attr("x", x)
.attr("y", y)
.attr("width", width)
.attr("height", height)
}
解决方案
推荐阅读
- openstreetmap - 如何在 Overpass QL 中查找路径内的节点?
- apache-kafka - Kafka Streams - 在 KTable 上高效计算最小值/最大值
- r - 带有地址的地理编码中的R googleway错误
- azure - Office365:在收件箱 powershell 中关注
- scala - 如何使用播放框架 2.6 WsClient 上传多个文件?
- git - 拉到第二个远程存储库:仅推送
- javascript - RxJS:跳过条件mergeMap
- automation - API 自动化测试:有没有办法通过内容验证来自动化下载场景?
- javascript - Express - 根据发布请求推送到测试阵列
- unit-testing - 单元测试时使用 ServiceStack 将 Entity Framework Core Context 注入存储库