如何使用 d3.js 创建双层分区?

How to create Bilevel Partition using d3.js?

我是 d3 世界的新手。我正在尝试从 http://d3js.org/ 学习它。 我正在尝试创建一个双层分区。

我无法让它显示任何结果。这是我的

JSfiddle

这里的这一行有问题:

d3.json("/mbostock/raw/4063550/flare.json", function(error, root) {

这是在路径“/mbostock/raw/4063550/flare.json”中加载文件的调用。这不是 JSFiddle 上的有效路径。在原来的 code, the path refers to a file hosted on that domain. Note that changing the domain on the Fiddle to the full path ("http://bl.ocks.org/mbostock/raw/4063550/flare.json") 中不起作用,因为 JSFiddle 可以防止跨站点脚本攻击。

请注意,您可以使用浏览器上的调试控制台来调试此类错误。