-
Notifications
You must be signed in to change notification settings - Fork 17
/
example6.html
202 lines (175 loc) · 7.14 KB
/
example6.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example 6</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<style>
.graph-cont {
height: 300px;
width: 100%;
}
h4 {
margin-top: 1em;
}
footer {
margin-bottom: 20px;
}
.content img {
margin: 2em 0;
}
.range-btns-cont {
display: block;
float:right;
visibility: hidden;
margin: 6px 6px;
}
</style>
<body>
<a href="https://github.com/kaliatech/dygraphs-dynamiczooming-example"><img
style="position: absolute; top: 0; right: 0; border: 0;"
src="https://s3.amazonaws.com/github/ribbons/forkme_right_green_007200.png" alt="Fork me on GitHub"></a>
<div class="container">
<div class="row">
<div class="col-md-12">
<h3>Using Dygraphs to load down-sampled data while zooming
<small> - Example 6</small>
</h3>
<p>This example shows that the overall technique works with live continuous data loading as well, but it
requires some additional handling and complexity. The main difference when using live data and dynamic
zooming, is that it's necessary to prevent changing graph automatically <em>unless</em> the user
intends to be looking at the most recent live data continuously. This is highly dependent on user interface
design and expectations.</p>
<p>In this simple example, if the user has zoomed in to detail view with the detail
end time less than 10 seconds from current time, then code assumes user intends to look at the most recent
live data continuously and so it resets the detail window end time on each data load. If the user
pans/zooms away from the current time, then code does not automatically reset detail view even though new
data is still continuing to be loaded and will be visible in the range viewer.</p>
<p>Note that the original demos were not written with live data loading in mind. Some minor refactoring would make
for much cleaner implementation.</p>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div id="graph-cont-1" class="graph-cont">
</div>
<div>
<span id="range-btns-cont-1" class="btn-group range-btns-cont">
<button name="range-btn-5y" class="btn btn-default btn-mini">
5y
</button>
<button name="range-btn-1y" class="btn btn-default btn-mini">
1y
</button>
<button name="range-btn-ytd" class="btn btn-default btn-mini">
YTD
</button>
<button name="range-btn-6m" class="btn btn-default btn-mini">
6m
</button>
<button name="range-btn-1m" class="btn btn-default btn-mini">
1m
</button>
<button name="range-btn-1d" class="btn btn-default btn-mini">
1d
</button>
<button name="range-btn-15min" class="btn btn-default btn-mini">
15min
</button>
<button name="range-btn-5min" class="btn btn-default btn-mini">
5min
</button>
</span>
</div>
<div style="margin:1em 0">
<button type="button" class="btn btn-success liveupdate-btn">Enable Live Updates</button>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
</div>
</div>
<div class="row">
<div class="col-md-12">
<h3>Files</small></h3>
<dl>
<dt><a href="https://github.com/kaliatech/dygraphs-dynamiczooming-example/blob/master/example6.html">example6.html</a>
</dt>
<dd>This page. Contains the graph container's HTML, range selector buttons, and this documentation. No
javascript.
</dd>
</dl>
<dl>
<dt><a href="https://github.com/kaliatech/dygraphs-dynamiczooming-example/blob/master/j/JGS.Demo6Page.js">j/JGS.Demo6Page.js</a>
</dt>
<dd>This is the most relevant file. Contains all of the Dygraphs specific handling. 90% the same as example 3, but adds live
data loading and additional hooks to track mouse button to prevent redrawing with live data while user is interacting.
</dd>
</dl>
<dl>
<dt><a
href="https://github.com/kaliatech/dygraphs-dynamiczooming-example/blob/master/j/JGS.GraphDataProviderLive.js">j/JGS.GraphDataProviderLive.js</a>
</dt>
<dd>Responsible for getting range and detail data from the server/simulator and then aggregating,splicing, and
converting it for dygraphs. This file is same as the GraphDataProvider used for example 1 & 2 & 3, but uses
GraphDataSimulatorLive.js to source data.
</dd>
</dl>
<dl>
<dt><a
href="https://github.com/kaliatech/dygraphs-dynamiczooming-example/blob/master/j/JGS.ServerDataSimulatorLive.js">j/JGS.ServerDataSimulatorLive.js</a>
</dt>
<dd>Simulates a remote time series data service. Includes simulated delays. This file is the same as ServerDataSimulator used in example
1 & 2 & 3, but also simulates loading of new live data on each data load call. This is poorly coded and is meant only to support this demo.
</dd>
</dl>
</div>
</div>
<div class="row">
<div class="col-md-12">
<a href="https://kaliatech.github.io/dygraphs-dynamiczooming-example//">
<span class="glyphicon glyphicon-arrow-left"></span> Back to examples list
</a>
</div>
</div>
<footer>
<hr>
<div class="row">
<div class="col-md-12">
© 2016 JGS Technical LLC
</div>
</div>
</footer>
</div>
<script src="//code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/dygraph/1.1.1/dygraph-combined.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/spin.js/2.3.2/spin.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/moment.js/2.17.1/moment.min.js"></script>
<script src="j/JGS.ServerDataSimulator.js"></script>
<script src="j/JGS.ServerDataSimulatorLive.js"></script>
<script src="j/JGS.GraphDataProvider.js"></script>
<script src="j/JGS.GraphDataProviderLive.js"></script>
<script src="j/JGS.Demo6Page.js"></script>
<script>
$(document).ready(function () {
var pageCfg = {
$graphCont: $("#graph-cont-1"),
$rangeBtnsCont: $("#range-btns-cont-1")
};
var demo6Page = new JGS.Demo6Page(pageCfg);
demo6Page.init();
});
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-8344371-7', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>