1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 import crunchstat_summary.webchart
8 class DygraphsChart(crunchstat_summary.webchart.WebChart):
9 CSS = 'https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.css'
10 JSLIB = 'https://cdnjs.cloudflare.com/ajax/libs/dygraph/2.0.0/dygraph.min.js'
11 JSASSETS = ['synchronizer.js','dygraphs.js']
14 return '<link rel="stylesheet" href="{}">\n'.format(self.CSS)
16 def chartdata(self, label, tasks, stats):
17 '''For Crunch2, label is the name of container request,
18 tasks is the top level container and
19 stats is index by a tuple of (category, metric).
22 'data': self._collate_data(tasks, stats),
25 'connectSeparatedPoints': True,
26 'labels': ['elapsed'] + stats[1],
27 'title': '{}: {}'.format(label, stats[0]),
31 def _collate_data(self, tasks, stats):
34 # uuid is category for crunch2
35 for uuid, task in tasks.items():
36 # All stats in a category are assumed to have the same time base and same number of samples
38 series_names = stats[1]
40 series = task.series[(category,sn0)]
41 for i in range(len(series)):
43 vals = [task.series[(category,stat)][i][1] for stat in series_names[1:]]
44 data.append([pt[0].total_seconds()] + nulls + [pt[1]] + vals)