Commit e245ddc9 authored by Vincent Pelletier's avatar Vincent Pelletier

Prepare "graph" function reuse.

parent e36ddfab
......@@ -674,12 +674,15 @@ def main():
out.write('<tr><td>%s</td><td>%s</td></tr>' % (date, hit))
out.write('</table>')
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)
out.write(escape(json.dumps(data), quote=True))
out.write('" data-options="')
out.write(escape(json.dumps(options), quote=True))
out.write('"></div>')
append(escape(json.dumps(data), quote=True))
append('" data-options="')
append(escape(json.dumps(options), quote=True))
append('"></div>')
return ''.join(result)
for site_id, data in per_site.iteritems():
out.write('<h1>Site: %s</h1>' % site_id)
daily_data = data.getApdexData()
......@@ -703,7 +706,7 @@ def main():
# Guesstimation: 6px per digit. If only em were allowed...
yLabelWidth = max(int(math.log10(max(x[2] for x in daily_data))) + 1,
3) * 6
graph('apdex',
out.write(graph('apdex',
[zip(date_list, (x[1] for x in daily_data))],
{
'xaxis': {
......@@ -718,8 +721,8 @@ def main():
},
'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))],
{
'xaxis': {
......@@ -734,7 +737,7 @@ def main():
},
'lines': {'show': True},
},
)
))
out.write(data.asHTML(decimator))
end_stat_time = time.time()
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