-
Notifications
You must be signed in to change notification settings - Fork 17
/
example.html
38 lines (33 loc) · 932 Bytes
/
example.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<html>
<head>
<script src="http://d3js.org/d3.v4.min.js"></script>
<script src="build/d3-transform.js"></script>
</head>
<body>
<svg class="example1"></svg>
<script>
var transform = d3.transform()
.translate(function(d) { return [20, d.size * 10] })
.rotate(40)
.scale(function(d) { return d.size + 2 });
console.log(transform({'size':5}));
var svg = d3.select('svg.example1').selectAll('g')
.data([{ size: 5 }, { size: 10 }])
.enter()
.append('g')
.attr('transform', transform);
console.log(svg.length);
</script>
<svg class="example2"></svg>
<script>
var transform1 = d3.transform()
.translate(10,20);
var transform2 = d3.transform(transform1)
.scale(function(d) { return [d.size];})
d3.select('svg.example2').selectAll('g')
.data([{ 'size' : 5 }, { 'size' : 10 }])
.enter().append('g')
.attr('transform', transform2);
</script>
</body>
</html>