Commit e245ddc9 authored by Vincent Pelletier's avatar Vincent Pelletier

Prepare "graph" function reuse.

parent e36ddfab
...@@ -674,12 +674,15 @@ def main(): ...@@ -674,12 +674,15 @@ def main():
out.write('<tr><td>%s</td><td>%s</td></tr>' % (date, hit)) out.write('<tr><td>%s</td><td>%s</td></tr>' % (date, hit))
out.write('</table>') out.write('</table>')
def graph(title, data, options={}): def graph(title, data, options={}):
out.write('<h2>%s</h2><div class="graph" ' result = []
append = result.append
append('<h2>%s</h2><div class="graph" '
'style="width:600px;height:300px" data-points="' % title) 'style="width:600px;height:300px" data-points="' % title)
out.write(escape(json.dumps(data), quote=True)) append(escape(json.dumps(data), quote=True))
out.write('" data-options="') append('" data-options="')
out.write(escape(json.dumps(options), quote=True)) append(escape(json.dumps(options), quote=True))
out.write('"></div>') append('"></div>')
return ''.join(result)
for site_id, data in per_site.iteritems(): for site_id, data in per_site.iteritems():
out.write('<h1>Site: %s</h1>' % site_id) out.write('<h1>Site: %s</h1>' % site_id)
daily_data = data.getApdexData() daily_data = data.getApdexData()
...@@ -703,7 +706,7 @@ def main(): ...@@ -703,7 +706,7 @@ def main():
# Guesstimation: 6px per digit. If only em were allowed... # Guesstimation: 6px per digit. If only em were allowed...
yLabelWidth = max(int(math.log10(max(x[2] for x in daily_data))) + 1, yLabelWidth = max(int(math.log10(max(x[2] for x in daily_data))) + 1,
3) * 6 3) * 6
graph('apdex', out.write(graph('apdex',
[zip(date_list, (x[1] for x in daily_data))], [zip(date_list, (x[1] for x in daily_data))],
{ {
'xaxis': { 'xaxis': {
...@@ -718,8 +721,8 @@ def main(): ...@@ -718,8 +721,8 @@ def main():
}, },
'lines': {'show': True}, 'lines': {'show': True},
}, },
) ))
graph('Hits (per %s)' % graph_period, out.write(graph('Hits (per %s)' % graph_period,
[zip(date_list, (x[2] for x in daily_data))], [zip(date_list, (x[2] for x in daily_data))],
{ {
'xaxis': { 'xaxis': {
...@@ -734,7 +737,7 @@ def main(): ...@@ -734,7 +737,7 @@ def main():
}, },
'lines': {'show': True}, 'lines': {'show': True},
}, },
) ))
out.write(data.asHTML(decimator)) out.write(data.asHTML(decimator))
end_stat_time = time.time() end_stat_time = time.time()
if args.stats: if args.stats:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment