source: Dev/branches/jQueryUI/client/d3/examples/partition/partition-icicle-zoom.html @ 249

Last change on this file since 249 was 249, checked in by hendrikvanantwerpen, 13 years ago

This one's for Subversion, because it's so close...

First widget (stripped down sequencer).
Seperated client and server code in two direcotry trees.

File size: 1.6 KB
Line 
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
10rect {
11  stroke: #fff;
12}
13
14    </style>
15  </head>
16  <body>
17    <div id="chart"></div>
18    <script type="text/javascript">
19
20var w = 960,
21    h = 250,
22    x = d3.scale.linear().range([0, w]),
23    y = d3.scale.linear().range([0, h]),
24    color = d3.scale.category20c();
25
26var vis = d3.select("#chart").append("svg:svg")
27    .attr("width", w)
28    .attr("height", h);
29
30var partition = d3.layout.partition()
31    .value(function(d) { return d.size; });
32
33d3.json("../data/flare.json", function(json) {
34  var rect = vis.data([json]).selectAll("rect")
35      .data(partition.nodes)
36    .enter().append("svg:rect")
37      .attr("x", function(d) { return x(d.x); })
38      .attr("y", function(d) { return y(d.y); })
39      .attr("width", function(d) { return x(d.dx); })
40      .attr("height", function(d) { return y(d.dy); })
41      .attr("fill", function(d) { return color((d.children ? d : d.parent).name); })
42      .on("click", click);
43
44  function click(d) {
45    x.domain([d.x, d.x + d.dx]);
46    y.domain([d.y, 1]).range([d.y ? 20 : 0, h]);
47
48    rect.transition()
49      .duration(750)
50      .attr("x", function(d) { return x(d.x); })
51      .attr("y", function(d) { return y(d.y); })
52      .attr("width", function(d) { return x(d.x + d.dx) - x(d.x); })
53      .attr("height", function(d) { return y(d.y + d.dy) - y(d.y); });
54  }
55});
56
57    </script>
58  </body>
59</html>
Note: See TracBrowser for help on using the repository browser.