javascript - Uncaught SyntaxError: Unexpected identifier - 尝试理解 D3 js
问题描述
我尝试使此代码有效(D3.js)。基本上,此代码呈现存储在 json 文件中的图形。
但是有一些我不明白的东西可能很明显,但我无法理解。
我有这部分代码
color = {
const scale = d3.scaleOrdinal(d3.schemeCategory10);
return d => scale(d.group);
}
这会引发以下错误:
':' expected.
{
"resource": "",
"owner": "typescript",
"code": "1005",
"severity": 8,
"message": "':' expected.",
"source": "ts",
"startLineNumber": 5,
"startColumn": 11,
"endLineNumber": 5,
"endColumn": 16
}
此颜色用于这部分代码:
const node = svg.append("g")
.attr("stroke", "#fff")
.attr("stroke-width", 1.5)
.selectAll("circle")
.data(nodes)
.join("circle")
.attr("r", 5)
.attr("fill", color)
.call(drag(simulation));
我敢肯定,这与Javascript有关。你有什么线索可以让我理解吗?
谢谢
解决方案
推荐阅读
- java - 是否可以在 Vaadin 14 和 RouterLink 中添加 uri 的#fragment 部分?
- c++ - 需要帮助了解 Stockfish 中使用的 uci.h 文件
- ios - 邮递员 GET 请求的 Alamofire 等效项
- php - 为什么我的前端 Wordpress 登录表单卡在重定向循环中?
- c++ - 分配 C++ 后指针的行为不符合预期
- android - Android谷歌地图,点击创建标记并立即开始拖动它
- regex - 如何使用带有正则表达式/特殊字符的 lstlisting 包?
- python - PyTorch - 调整图像大小的原因是什么以及如何确定最佳尺寸?
- amazon-web-services - 如何启用 (https) SSL 证书 AWS EC2 托管站点
- python - Discord.py - 如何在事件中调用命令?