-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate.qtpl
302 lines (250 loc) · 8.93 KB
/
template.qtpl
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
{% func RickshawExtensionsReport(data TemplateData) %}
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css">
<link type="text/css" rel="stylesheet" href="{%s data.RickshawURL %}/src/css/graph.css">
<link type="text/css" rel="stylesheet" href="{%s data.RickshawURL %}/src/css/detail.css">
<link type="text/css" rel="stylesheet" href="{%s data.RickshawURL %}/src/css/legend.css">
<link type="text/css" rel="stylesheet" href="{%s data.RickshawURL %}/examples/css/extensions.css?v=2">
<script src="{%s data.RickshawURL %}/vendor/d3.v3.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script>
jQuery.noConflict();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Class.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Compat.ClassList.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Renderer.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Renderer.Area.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Renderer.Line.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Renderer.Bar.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Renderer.ScatterPlot.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Renderer.Stack.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.RangeSlider.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.RangeSlider.Preview.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.HoverDetail.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Annotate.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Legend.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Axis.Time.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Behavior.Series.Toggle.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Behavior.Series.Order.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Behavior.Series.Highlight.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Smoother.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Fixtures.Time.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Fixtures.Time.Local.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Fixtures.Number.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Fixtures.RandomData.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Fixtures.Color.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Color.Palette.js"></script>
<script src="{%s data.RickshawURL %}/src/js/Rickshaw.Graph.Axis.Y.js"></script>
<script src="{%s data.RickshawURL %}/examples/js/extensions.js"></script>
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/css/jquery.dataTables.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.9.4/jquery.dataTables.min.js"></script>
</head>
<body>
{%s= data.HeaderHTML %}
<div id="content">
<form id="side_panel">
<h1>{%s data.ReportName %}</h1>
<div>Link: {%s= data.ReportLink %}</div>
<section><div id="legend"></div></section>
<section>
<div id="renderer_form" class="toggler">
<input type="radio" name="renderer" id="area" value="area" checked>
<label for="area">area</label>
<input type="radio" name="renderer" id="bar" value="bar">
<label for="bar">bar</label>
<input type="radio" name="renderer" id="line" value="line">
<label for="line">line</label>
<input type="radio" name="renderer" id="scatter" value="scatterplot">
<label for="scatter">scatter</label>
</div>
</section>
<section>
<div id="offset_form">
<label for="stack">
<input type="radio" name="offset" id="stack" value="zero" checked>
<span>stack</span>
</label>
<label for="stream">
<input type="radio" name="offset" id="stream" value="wiggle">
<span>stream</span>
</label>
<label for="pct">
<input type="radio" name="offset" id="pct" value="expand">
<span>pct</span>
</label>
<label for="value">
<input type="radio" name="offset" id="value" value="value">
<span>value</span>
</label>
</div>
<div id="interpolation_form">
<label for="cardinal">
<input type="radio" name="interpolation" id="cardinal" value="cardinal" checked>
<span>cardinal</span>
</label>
<label for="linear">
<input type="radio" name="interpolation" id="linear" value="linear">
<span>linear</span>
</label>
<label for="step">
<input type="radio" name="interpolation" id="step" value="step-after">
<span>step</span>
</label>
</div>
</section>
<section>
<h6>Smoothing</h6>
<div id="smoother"></div>
</section>
<section></section>
</form>
<div id="chart_container">
<div id="chart"></div>
<div id="timeline"></div>
<div id="preview"></div>
</div>
</div>
<script>
// set up our data series with 150 random data points
var seriesData = [ [], [], [], [], [], [], [], [], [] ];
var random = new Rickshaw.Fixtures.RandomData(150);
for (var i = 0; i < 150; i++) {
random.addData(seriesData);
}
var palette = new Rickshaw.Color.Palette( { scheme: 'classic9' } );
// instantiate our graph!
var series = {%v= string(data.FormattedDataJSON()) %};
for (i = 0; i < series.length; i++) {
series[i]["color"] = palette.color();
}
var graph = new Rickshaw.Graph( {
element: document.getElementById("chart"),
width: 900,
height: 500,
renderer: 'area',
stroke: true,
preserve: true,
series: series
} );
graph.render();
var preview = new Rickshaw.Graph.RangeSlider( {
graph: graph,
element: document.getElementById('preview'),
} );
var hoverDetail = new Rickshaw.Graph.HoverDetail( {
graph: graph,
xFormatter: function(x) {
return new Date(x * 1000).toString();
}
} );
var annotator = new Rickshaw.Graph.Annotate( {
graph: graph,
element: document.getElementById('timeline')
} );
var legend = new Rickshaw.Graph.Legend( {
graph: graph,
element: document.getElementById('legend')
} );
var shelving = new Rickshaw.Graph.Behavior.Series.Toggle( {
graph: graph,
legend: legend
} );
var order = new Rickshaw.Graph.Behavior.Series.Order( {
graph: graph,
legend: legend
} );
var highlighter = new Rickshaw.Graph.Behavior.Series.Highlight( {
graph: graph,
legend: legend
} );
var smoother = new Rickshaw.Graph.Smoother( {
graph: graph,
element: document.querySelector('#smoother')
} );
var ticksTreatment = 'glow';
var xAxis = new Rickshaw.Graph.Axis.Time( {
graph: graph,
ticksTreatment: ticksTreatment,
timeFixture: new Rickshaw.Fixtures.Time.Local()
} );
xAxis.render();
var yAxis = new Rickshaw.Graph.Axis.Y( {
graph: graph,
tickFormat: Rickshaw.Fixtures.Number.formatKMBT,
ticksTreatment: ticksTreatment
} );
yAxis.render();
var controls = new RenderControls( {
element: document.querySelector('form'),
graph: graph
} );
// add some data every so often
var messages = [
"Changed home page welcome message",
"Minified JS and CSS",
"Changed button color from blue to green",
"Refactored SQL query to use indexed columns",
"Added additional logging for debugging",
"Fixed typo",
"Rewrite conditional logic for clarity",
"Added documentation for new methods"
];
setInterval( function() {
random.removeData(seriesData);
random.addData(seriesData);
graph.update();
}, 3000 );
function addAnnotation(force) {
if (messages.length > 0 && (force || Math.random() >= 0.95)) {
annotator.add(seriesData[2][seriesData[2].length-1].x, messages.shift());
annotator.update();
}
}
addAnnotation(true);
setTimeout( function() { setInterval( addAnnotation, 6000 ) }, 6000 );
var previewXAxis = new Rickshaw.Graph.Axis.Time({
graph: preview.previews[0],
timeFixture: new Rickshaw.Fixtures.Time.Local(),
ticksTreatment: ticksTreatment
});
previewXAxis.render();
</script>
{% if data.IncludeDataTable %}
<style>
body,h3,th {font-family:Arial,sans-serif}
</style>
<h3>Data</h3>
{% code
tableHeader, tableData := data.TableData()
%}
<table id="myTable" style="border:1px #aaa solid;font-size:80%">
<thead>
{% for _, thValue := range tableHeader %}
<th>{%s thValue %}</th>
{% endfor %}
</thead><tbody>
{% for _, dtRow := range tableData %}
<tr>
{% for _, dtValue := range dtRow %}
<td>{%s dtValue %}</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
<script>
jQuery(document).ready(function(){
jQuery('#myTable').dataTable({
"iDisplayLength": 100
});
});
</script>
{% endif %}
</body>
</html>
{% endfunc %}