Commit d6683265 authored by Vincent Pelletier's avatar Vincent Pelletier

Improve axis & tick rendering.

Add axis label (requires flot "axislabel" module).
Workaround default axis label color.
Save horizontal space between labels.
Provide minimal interval between ticks so label don't overflow on
each other.
Provide label width for Y axis so consecutive graphs are correctly
lined up.
parent 6ad4f152
...@@ -39,6 +39,7 @@ from urllib import splittype, splithost ...@@ -39,6 +39,7 @@ from urllib import splittype, splithost
import argparse import argparse
import gzip import gzip
import json import json
import math
import os import os
import re import re
import sys import sys
...@@ -527,9 +528,11 @@ def main(): ...@@ -527,9 +528,11 @@ def main():
'.warning { background-color: #f80; color: white; } ' '.warning { background-color: #f80; color: white; } '
'h1 { background-color: #ccc; } ' 'h1 { background-color: #ccc; } '
'h2 { background-color: #eee; } ' 'h2 { background-color: #eee; } '
'.axisLabels { color: rgb(84,84,84) !important; }'
'.flot-x-axis .tickLabel { text-align: center; } '
'</style>') '</style>')
for script in ('jquery.js', 'jquery.flot.js', 'jquery.flot.time.js', for script in ('jquery.js', 'jquery.flot.js', 'jquery.flot.time.js',
'main.js'): 'jquery.flot.axislabels.js', 'main.js'):
if args.js_embed: if args.js_embed:
out.write('<script type="text/javascript">//<![CDATA[') out.write('<script type="text/javascript">//<![CDATA[')
out.write(getResource(script)) out.write(getResource(script))
...@@ -562,11 +565,26 @@ def main(): ...@@ -562,11 +565,26 @@ def main():
daily_data = data.getApdexData() daily_data = data.getApdexData()
date_list = [int(time.mktime(time.strptime(x[0], '%Y/%m/%d' + { date_list = [int(time.mktime(time.strptime(x[0], '%Y/%m/%d' + {
'day': ' %H'}.get(args.period, ''))) * 1000) for x in daily_data] 'day': ' %H'}.get(args.period, ''))) * 1000) for x in daily_data]
timeformat = '%Y<br/>%m/%d<br/>%H:%M'
# There is room for about 10 labels on the X axis.
minTickSize = (max(1,
(date_list[-1] - date_list[0]) / (60 * 60 * 1000 * 10)), 'hour')
# Guesstimation: 6px per digit. If only em were allowed...
yLabelWidth = max(int(math.log10(max(x[4] for x in daily_data))) + 1,
3) * 6
graph('Apdex', graph('Apdex',
[zip(date_list, (x[1] for x in daily_data))], [zip(date_list, (x[1] for x in daily_data))],
{ {
'xaxis': {'mode': 'time'}, 'xaxis': {
'yaxis': {'max': 100}, 'mode': 'time',
'timeformat': timeformat,
'minTickSize': minTickSize,
},
'yaxis': {
'max': 100,
'axisLabel': '%',
'labelWidth': yLabelWidth,
},
'lines': {'show': True}, 'lines': {'show': True},
'points': {'show': True}, 'points': {'show': True},
}, },
...@@ -574,7 +592,15 @@ def main(): ...@@ -574,7 +592,15 @@ def main():
graph('Hits', graph('Hits',
[zip(date_list, (x[4] for x in daily_data))], [zip(date_list, (x[4] for x in daily_data))],
{ {
'xaxis': {'mode': 'time'}, 'xaxis': {
'mode': 'time',
'timeformat': timeformat,
'minTickSize': minTickSize,
},
'yaxis': {
'axisLabel': 'Hits',
'labelWidth': yLabelWidth,
},
'lines': {'show': True}, 'lines': {'show': True},
'points': {'show': True}, 'points': {'show': True},
}, },
......
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