【发布时间】:2014-08-13 10:28:18
【问题描述】:
我想将来自 grails 控制器的映射作为 JSON 传递给 d3,并使用 d3.json() 方法对其进行解析
我的控制器看起来像这样
def graph() {
def map = [[source: "NodeOne", "target": "NodeTwo", "type": "type"],
["source": "NodeOne", "target": "NodeThree", "type": "type"]]
render map as JSON
}
gsp 脚本端如下所示:(d3 示例 http://bl.ocks.org/mbostock/4062045)。 d3.json() 在 URL 处渲染一个 json
d3.json( URL , function(error, graph) {...[more code here]...}
为了让我的地图在 d3 中呈现,我需要为 URL 输入什么?当我创建到控制器的链接时,不是加载视图,而是将 JSON 打印为文本。
【问题讨论】:
标签: javascript json grails d3.js