-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
98 lines (94 loc) · 2.16 KB
/
index.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>d3.js实现自定义多y轴折线图</title>
<link rel="stylesheet" href="./multiYChart.css">
<script src="./d3.min.js"></script>
<script src="./multiYChart.js"></script>
<style>
.chart {
margin: 0 auto;
width: 690px;
height: 650px;
}
.reset {
display: block;
margin: 50px auto 10px;
}
</style>
</head>
<body>
<div class="chartWrap">
<button class="reset" id="reset">RESET</button>
<div class="chart" id="chart">
</div>
</div>
<script>
var dataSource = [{
desc: '体温',
code: 'temperature',
unit: '℃',
min: 34,
max: 42,
data: [{
datetime: new Date(2018, 0, 1, 12),
value: 36.5
}, {
datetime: new Date(2018, 0, 2, 12),
value: 37
}, {
datetime: new Date(2018, 0, 3, 12),
value: 38
}, {
datetime: new Date(2018, 0, 4, 12),
value: 38.3
}, {
datetime: new Date(2018, 0, 5, 12),
value: 37
}, {
datetime: new Date(2018, 0, 6, 12),
value: 36.5
}]
},
{
desc: '脉搏',
code: 'pulseRate',
unit: '次/分',
min: 20,
max: 180,
data: [{
datetime: new Date(2018, 0, 1, 12),
value: 80
}, {
datetime: new Date(2018, 0, 2, 12),
value: 70
}, {
datetime: new Date(2018, 0, 3, 12),
value: 90
}, {
datetime: new Date(2018, 0, 4, 12),
value: 89
}, {
datetime: new Date(2018, 0, 5, 12),
value: 85
}, {
datetime: new Date(2018, 0, 6, 12),
value: 100
}]
}
];
var options = {
id: 'chart',
width: 690,
height: 650,
beginTime: new Date(2018, 0, 1),
zooming: true,
dataSource
};
var multiYChart = new multiYChart(options)
</script>
</body>
</html>