|
1 | 1 | import datetime |
| 2 | +import math |
2 | 3 | import plotly |
3 | 4 | import plotly.graph_objs as go |
4 | 5 |
|
|
18 | 19 | from dashboard.colors import get_color |
19 | 20 |
|
20 | 21 |
|
| 22 | +# Constants |
| 23 | +BUBBLE_SIZE_RATIO = 1250 |
| 24 | + |
| 25 | + |
21 | 26 | @blueprint.route('/result/<end>/heatmap') |
22 | 27 | @secure |
23 | 28 | def result_heatmap(end): |
@@ -197,7 +202,8 @@ def get_hits_per_hour(end): |
197 | 202 | def get_time_per_version_per_user(end, versions): |
198 | 203 | user_data = {} |
199 | 204 | data = [t.execution_time for t in get_all_measurement(end)] |
200 | | - average = sum(data) / len(data) |
| 205 | + # compute the average for determining the size of the bubbles in the plot |
| 206 | + average = math.sqrt(sum(data) / len(data)) / BUBBLE_SIZE_RATIO |
201 | 207 |
|
202 | 208 | for d in [str(c.group_by) for c in get_endpoint_column(end, FunctionCall.group_by)]: |
203 | 209 | user_data[d] = {} |
@@ -228,9 +234,9 @@ def get_time_per_version_per_user(end, versions): |
228 | 234 | name=d, |
229 | 235 | mode='markers', |
230 | 236 | marker=dict( |
231 | | - color=[get_color(h) for h in versions], |
232 | | - size=data, |
233 | | - sizeref=average/1250, # larger sizeref decreases size of the dot |
| 237 | + color=[get_color(d)] * len(versions), |
| 238 | + size=[math.sqrt(d) for d in data], |
| 239 | + sizeref=average, |
234 | 240 | sizemode='area' |
235 | 241 | ) |
236 | 242 | )) |
@@ -283,7 +289,8 @@ class SelectionForm(FlaskForm): |
283 | 289 | def get_time_per_version_per_ip(end, versions): |
284 | 290 | ip_data = {} |
285 | 291 | data = [t.execution_time for t in get_all_measurement(end)] |
286 | | - average = sum(data) / len(data) |
| 292 | + # compute the average for determining the default size |
| 293 | + average = math.sqrt(sum(data) / len(data)) / 1250 |
287 | 294 | for d in [str(c.ip) for c in get_endpoint_column(end, FunctionCall.ip)]: |
288 | 295 | ip_data[d] = {} |
289 | 296 | for v in versions: |
@@ -314,9 +321,9 @@ def get_time_per_version_per_ip(end, versions): |
314 | 321 | name=d, |
315 | 322 | mode='markers', |
316 | 323 | marker=dict( |
317 | | - color=[get_color(h) for h in versions], |
318 | | - size=data, |
319 | | - sizeref=average / 1250, # larger sizeref decreases size of the dot |
| 324 | + color=[get_color(d)] * len(versions), |
| 325 | + size=[math.sqrt(d) for d in data], |
| 326 | + sizeref=average, |
320 | 327 | sizemode='area' |
321 | 328 | ) |
322 | 329 | )) |
@@ -354,7 +361,7 @@ def get_time_per_version(end, versions): |
354 | 361 | data.append(go.Box( |
355 | 362 | x=values, |
356 | 363 | marker=dict( |
357 | | - color=get_color(v.version) |
| 364 | + color=get_color(end) |
358 | 365 | ), |
359 | 366 | name="{0} {1}".format(v.version, v.startedUsingOn.strftime("%b %d %H:%M")))) |
360 | 367 |
|
|
0 commit comments