Skip to content

Commit 6105b92

Browse files
committed
Format large numbers in graph popup info.
1 parent 8248dd6 commit 6105b92

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

flask-dashboard/dashboard/routings/result.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pygal
2+
import math
23
from flask import session, url_for, render_template
34
from werkzeug.routing import BuildError
45

@@ -36,9 +37,12 @@ def show_graph(end):
3637
list_avg.append(d.avg)
3738
list_max.append(d.max)
3839
list_count.append(d.count)
39-
times_chart.add('Minimum', list_min, formatter=lambda x: '%.2f ms' % x)
40-
times_chart.add('Average', list_avg, formatter=lambda x: '%.2f ms' % x)
41-
times_chart.add('Maximum', list_max, formatter=lambda x: '%.2f ms' % x)
40+
times_chart.add('Minimum', list_min, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
41+
round(x % 1000, 2)))
42+
times_chart.add('Average', list_avg, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
43+
round(x % 1000, 2)))
44+
times_chart.add('Maximum', list_max, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
45+
round(x % 1000, 2)))
4246
times_data = times_chart.render_data_uri()
4347

4448
hits_chart = pygal.HorizontalBar(height=100+len(data)*30, show_legend=False)
@@ -90,12 +94,14 @@ def show_graph(end):
9094
data = []
9195
for v in versions:
9296
data.append(user_data[d][v])
93-
dot_chart_user.add(d, data, formatter=lambda x: '%.2f ms' % x)
97+
dot_chart_user.add(d, data, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
98+
round(x % 1000, 2)))
9499
for d in [str(c.ip) for c in get_endpoint_column(end, FunctionCall.ip)]:
95100
data = []
96101
for v in versions:
97102
data.append(ip_data[d][v])
98-
dot_chart_ip.add(d, data, formatter=lambda x: '%.2f ms' % x)
103+
dot_chart_ip.add(d, data, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
104+
round(x % 1000, 2)))
99105

100106
return render_template('show-graph.html', link=config.link, session=session, rule=rule, url=url,
101107
times_data=times_data, hits_data=hits_data, dot_chart_user=dot_chart_user.render_data_uri(),

flask-dashboard/dashboard/routings/setup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import datetime
1515
import time
1616
import pygal
17+
import math
1718

1819

1920
@blueprint.route('/settings', methods=['GET', 'POST'])
@@ -117,9 +118,12 @@ def testmonitor():
117118
list_avg.append(d.avg)
118119
list_max.append(d.max)
119120
list_count.append(d.count)
120-
times_chart.add('Minimum', list_min, formatter=lambda x: '%.2f ms' % x)
121-
times_chart.add('Average', list_avg, formatter=lambda x: '%.2f ms' % x)
122-
times_chart.add('Maximum', list_max, formatter=lambda x: '%.2f ms' % x)
121+
times_chart.add('Minimum', list_min, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
122+
round(x % 1000, 2)))
123+
times_chart.add('Average', list_avg, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
124+
round(x % 1000, 2)))
125+
times_chart.add('Maximum', list_max, formatter=lambda x: '{0}s and {1}ms'.format(math.floor(x/1000),
126+
round(x % 1000, 2)))
123127
times_data = times_chart.render_data_uri()
124128

125129
return render_template('testmonitor.html', link=config.link, session=session, curr=3, form=form, tests=get_tests(),

0 commit comments

Comments
 (0)