-
Notifications
You must be signed in to change notification settings - Fork 0
/
直方图和刻度表.html
65 lines (52 loc) · 1.23 KB
/
直方图和刻度表.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>d3</title>
<style type="text/css">
svg,
g {
pointer-events: all;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
</style>
</head>
<body>
<script src="http://cdn.bootcss.com/d3/4.1.1/d3.js"></script>
<script>
var data_1 = [23, 54, 67, 12, 4];
var data_2 = [1, 2, 3, 4, 5];
var width = 800;
var height = 800;
var mapScale = d3.scaleLinear()
.domain([-70, +70])
.range([0, width - 40]);
var axisBot = d3.axisBottom(mapScale);
var axisLft = d3.axisLeft(data_1);
var canvas = d3.select('body')
.append('svg')
.attr('width', width)
.attr('height', height);
var xsCont = canvas.append('g')
.call(axisBot);
if (false) {
var lines = canvas.selectAll('rect')
.data(data_1)
.enter()
.append('rect')
.attr('width', function(d) {
return mapScale(d);
})
.attr('height', 20)
.attr('y', function(d, i) {
return i * 100
});
}
</script>
</body>
</html>