-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathcal.html
47 lines (40 loc) · 952 Bytes
/
cal.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
39
40
41
42
43
44
45
46
47
<!doctype html>
<html>
<head>
<title>Test</title>
<style>
line {stroke-width:1px;
stroke:#999;}
</style>
<script src="../src/d3.min.js"></script>
</head>
<body>
<script>
var svg = d3.select('body').append('svg');
function draw(w, h, d, x1, y1){
x1 = x1 || 0;
y1 = y1 || 0;
var x = d3.scale.linear().domain([0, w/d]);
svg.attr('width', w)
.attr('height', h);
var nodes = svg.selectAll('line.xline')
.data(x.ticks(w/d));
nodes
.attr('x1', function(i){return i*d+0.5+x1;})
.attr('y1', y1)
.attr('x2', function(i){return i*d+0.5+x1;})
.attr('y2', h+y1);
//draw y line
nodes.enter()
.append('line')
.attr('class', 'xline')
.attr('x1', function(i){return i*d+0.5+x1;})
.attr('y1', y1)
.attr('x2', function(i){return i*d+0.5+x1;})
.attr('y2', h+y1);
nodes.exit().remove();
}
draw(200, 200, 24);
</script>
</body>
</html>