source: Dev/trunk/d3/examples/superformula/superformula.html @ 76

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

d3

File size: 1.5 KB
Line 
1<!DOCTYPE html>
2  <html>
3  <head>
4    <title>Superformula</title>
5    <script type="text/javascript" src="../../d3.js"></script>
6    <script type="text/javascript" src="superformula.js"></script>
7    <style type="text/css">
8
9path {
10  stroke-width: 1.5px;
11}
12
13path.small {
14  fill: steelblue;
15}
16
17path.big {
18  stroke: #666;
19  fill: #ddd;
20}
21
22path.small:hover {
23  stroke: steelblue;
24  fill: lightsteelblue;
25}
26
27    </style>
28  </head>
29  <body>
30    <script type="text/javascript">
31
32var size = 1000;
33
34var x = d3.scale.ordinal()
35    .domain(superformulaTypes)
36    .rangePoints([0, 960], 1);
37
38var svg = d3.select("body").append("svg:svg")
39    .attr("width", 960)
40    .attr("height", 500);
41
42var small = superformula()
43    .type(String)
44    .size(size);
45
46var big = superformula()
47    .type("square")
48    .size(size * 50)
49    .segments(360);
50
51svg.selectAll("a")
52    .data(superformulaTypes)
53  .enter().append("svg:a")
54    .attr("xlink:title", String)
55    .attr("transform", function(d, i) { return "translate("+ x(d) + ",40)"; })
56  .append("svg:path")
57    .attr("class", "small")
58    .attr("d", small)
59    .on("mousedown", function() { d3.select(this).style("fill", "aliceblue"); })
60    .on("mouseup", function() { d3.select(this).style("fill", null); })
61    .on("click", function(d) { d3.select(".big").transition().duration(500).attr("d", big.type(d)); });
62
63svg.append("svg:path")
64    .attr("class", "big")
65    .attr("transform", "translate(450,250)")
66    .attr("d", big);
67
68    </script>
69  </body>
70</html>
Note: See TracBrowser for help on using the repository browser.