-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdemo.html
84 lines (76 loc) · 1.9 KB
/
demo.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
<!doctype html>
<html lang="en">
<head>
<title>chartist zoom</title>
<link rel="stylesheet" href="node_modules/chartist/dist/chartist.min.css">
<style>
.ct-zoom-rect {
fill: rgba(200, 100, 100, 0.3);
stroke: red;
}
body {
min-height: 2000px;
}
.fixed {
position:fixed;
}
.ct-point {
stroke-width: 20px;
stroke-linecap: round;
}
</style>
</head>
<body>
<h1>Chartist Zoom Plugin</h1>
<p>Use left mouse button to drag a zoom box. Reset zoom with right mouse button.</p>
<p><a id="reset" href="#" style="display:none" onclick='return reset()'>Reset</a></p>
<div id="c1" class="ct-chart ct-golden-section" style="max-width:800px"></div>
<div id="c2" class="fixed ct-chart ct-golden-section" style="max-width:600px"></div>
<script src="node_modules/chartist/dist/chartist.js"></script>
<script src="dist/chartist-plugin-zoom.js"></script>
<script>
var data = {
series: [[
{x: 1, y: 100},
{x: 2, y: 50},
{x: 3, y: 25},
{x: 4, y: 66},
{x: 5, y: 44},
{x: 6, y: 22},
]]
};
var options = {
chartPadding: {
top: 50,
right: 30,
left: 40,
bottom: 50
},
axisX: {
type: Chartist.AutoScaleAxis
},
axisY: {
type: Chartist.AutoScaleAxis
},
plugins : [
Chartist.plugins.zoom({
onZoom: onZoom,
pointClipOffset: 10,
})
]
};
var chart1 = Chartist.Line('#c1', data, options);
var chart2 = Chartist.Line('#c2', data, options);
var resetFnc;
function onZoom(chart, reset) {
document.getElementById('reset').style.display = 'inline';
resetFnc = reset;
}
function reset() {
resetFnc && resetFnc();
resetFnc = null;
document.getElementById('reset').style.display = 'none';
}
</script>
</body>
</html>