source: Dev/trunk/d3/examples/hello-world/hello-webkit-transition.html @ 76

Last change on this file since 76 was 76, checked in by fpvanagthoven, 14 years ago

d3

File size: 1.4 KB
Line 
1<!DOCTYPE html>
2<html>
3  <head>
4    <title>Hello, data!</title>
5    <script type="text/javascript" src="../../d3.js"></script>
6    <style type="text/css">
7
8body {
9  font: 14px Helvetica Neue;
10  text-rendering: optimizeLegibility;
11  margin: 1em;
12}
13
14#cells {
15  position: relative;
16  margin-top: .5em;
17  height: 300px;
18  overflow: hidden;
19}
20
21.cell {
22  position: absolute;
23  background: steelblue;
24  color: white;
25  width: 28px;
26  text-align: center;
27  padding-top: 6px;
28  top: 300px;
29  bottom: 0;
30  background: -webkit-gradient(linear, left top, left bottom, from(transparent), to(steelblue));
31  -webkit-transition-property: top, background-color;
32  -webkit-transition-duration: 500ms;
33  -webkit-transition-timing-function: ease, linear;
34}
35
36    </style>
37  </head>
38  <body>
39    Your lucky numbers are:<br>
40    <div id="cells"></div>
41    <script type="text/javascript">
42
43var n = 10;
44
45d3.select("#cells")
46  .selectAll("div")
47    .data(d3.range(n))
48  .enter().append("div")
49    .attr("class", "cell")
50    .style("left", function(i) { return i * 30; });
51
52function transform() {
53  d3.selectAll(".cell")
54      .data(d3.range(n).map(Math.random))
55      .style("top", function(d) { return (1 - d) * 300; })
56      .style("background-color", function(d) { return "rgb(" + ~~(d * 255) + ",50,100)"; })
57      .text(function(d) { return ~~(d * 100); });
58}
59
60window.addEventListener("keypress", transform, false);
61
62    </script>
63  </body>
64</html>
Note: See TracBrowser for help on using the repository browser.