toolkit/javascript/d3/examples/hello-world/hello-transition-undefined.html
changeset 47 c0b4a8b5a012
equal deleted inserted replaced
46:efd9c589177a 47:c0b4a8b5a012
       
     1 <!DOCTYPE html>
       
     2 <html>
       
     3   <head>
       
     4     <title>Hello, transition undefined!</title>
       
     5     <script type="text/javascript" src="../../d3.js"></script>
       
     6     <style type="text/css">
       
     7 
       
     8 body {
       
     9   font: 14px Helvetica Neue;
       
    10   text-rendering: optimizeLegibility;
       
    11   margin: 1em;
       
    12 }
       
    13 
       
    14 div {
       
    15   font-size: 42px;
       
    16   margin-top: .5em;
       
    17   text-align: right;
       
    18 }
       
    19 
       
    20     </style>
       
    21   </head>
       
    22   <body>
       
    23     Your lucky number is:<br>
       
    24     <div>hello</div>
       
    25     <script type="text/javascript">
       
    26 
       
    27 transform();
       
    28 
       
    29 function transform() {
       
    30   d3.select("div")
       
    31       .style("width", "0%")
       
    32     .transition()
       
    33       .ease("bounce")
       
    34       .duration(2000)
       
    35       .style("width", "100%")
       
    36       .style("background-color", function() { return d3.hsl(180, Math.random(), .5); });
       
    37 }
       
    38 
       
    39 window.addEventListener("keypress", transform, false);
       
    40 
       
    41     </script>
       
    42   </body>
       
    43 </html>