-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path单条折线图.html
69 lines (69 loc) · 1.38 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
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,height=device-height">
<title>基础折线图</title>
<style>::-webkit-scrollbar{display:none;}html,body{overflow:hidden;height:100%;}</style>
</head>
<body>
<div id="mountNode"></div>
<script>/*Fixing iframe window.innerHeight 0 issue in Safari*/document.body.clientHeight;</script>
<script src="https://gw.alipayobjects.com/os/antv/assets/g2/3.1.0/g2.min.js"></script>
<script src="https://gw.alipayobjects.com/os/antv/assets/data-set/0.8.7/data-set.min.js"></script>
<script>
var data = [{
year: '1991',
value: 3
}, {
year: '1992',
value: 4
}, {
year: '1993',
value: 3.5
}, {
year: '1994',
value: 5
}, {
year: '1995',
value: 4.9
}, {
year: '1996',
value: 6
}, {
year: '1997',
value: 7
}, {
year: '1998',
value: 9
}, {
year: '1999',
value: 13
}];
var chart = new G2.Chart({
container: 'mountNode',
forceFit: true,
height: window.innerHeight,
padding:[5,20,35,24]
});
chart.source(data);
chart.scale('value', {
min: 0
});
chart.scale('year', {
range: [0, 1]
});
chart.tooltip({
crosshairs: {
type: 'line'
}
});
chart.line().position('year*value').color('#9facb9');
chart.point().position('year*value').color('#9facb9').size(4).shape('circle').style({
stroke: '#fff',
lineWidth: 1
});
chart.render();
</script>
</body>
</html>