Rev | Line | |
---|
[76] | 1 | <!DOCTYPE html> |
---|
| 2 | <html> |
---|
| 3 | <head> |
---|
| 4 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> |
---|
| 5 | <title>Partition - Icicle</title> |
---|
| 6 | <script type="text/javascript" src="../../d3.js"></script> |
---|
| 7 | <script type="text/javascript" src="../../d3.layout.js"></script> |
---|
| 8 | <style type="text/css"> |
---|
| 9 | |
---|
| 10 | rect { |
---|
| 11 | stroke: #fff; |
---|
| 12 | } |
---|
| 13 | |
---|
| 14 | </style> |
---|
| 15 | </head> |
---|
| 16 | <body> |
---|
| 17 | <div id="chart"></div> |
---|
| 18 | <script type="text/javascript"> |
---|
| 19 | |
---|
| 20 | var w = 960, |
---|
| 21 | h = 250, |
---|
| 22 | color = d3.scale.category20c(); |
---|
| 23 | |
---|
| 24 | var vis = d3.select("#chart").append("svg:svg") |
---|
| 25 | .attr("width", w) |
---|
| 26 | .attr("height", h); |
---|
| 27 | |
---|
| 28 | var partition = d3.layout.partition() |
---|
| 29 | .size([w, h]) |
---|
| 30 | .value(function(d) { return d.size; }); |
---|
| 31 | |
---|
| 32 | d3.json("../data/flare.json", function(json) { |
---|
| 33 | vis.data([json]).selectAll("rect") |
---|
| 34 | .data(partition.nodes) |
---|
| 35 | .enter().append("svg:rect") |
---|
| 36 | .attr("x", function(d) { return d.x; }) |
---|
| 37 | .attr("y", function(d) { return d.y; }) |
---|
| 38 | .attr("width", function(d) { return d.dx; }) |
---|
| 39 | .attr("height", function(d) { return d.dy; }) |
---|
| 40 | .style("fill", function(d) { return color((d.children ? d : d.parent).name); }); |
---|
| 41 | }); |
---|
| 42 | |
---|
| 43 | </script> |
---|
| 44 | </body> |
---|
| 45 | </html> |
---|
Note: See
TracBrowser
for help on using the repository browser.