X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/daa3cc42efa55ad17df2a151aebaac515d10cc52..44c95f99098fa6c6acbfa82d4b6cbc6015eb6e39:/tools/crunchstat-summary/crunchstat_summary/chartjs.py diff --git a/tools/crunchstat-summary/crunchstat_summary/chartjs.py b/tools/crunchstat-summary/crunchstat_summary/chartjs.py index fb30041889..bd8af8ca2d 100644 --- a/tools/crunchstat-summary/crunchstat_summary/chartjs.py +++ b/tools/crunchstat-summary/crunchstat_summary/chartjs.py @@ -1,7 +1,12 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + from __future__ import print_function import cgi import json +import math import pkg_resources from crunchstat_summary import logger @@ -35,12 +40,25 @@ class ChartJS(object): } for s in self.summarizers] + def _axisY(self, tasks, stat): + ymax = 1 + for task in tasks.itervalues(): + for pt in task.series[stat]: + ymax = max(ymax, pt[1]) + ytick = math.exp((1+math.floor(math.log(ymax, 2)))*math.log(2))/4 + return { + 'gridColor': '#cccccc', + 'gridThickness': 1, + 'interval': ytick, + 'minimum': 0, + 'maximum': ymax, + 'valueFormatString': "''", + } + def charts(self, label, tasks): return [ { - 'axisY': { - 'minimum': 0, - }, + 'axisY': self._axisY(tasks=tasks, stat=stat), 'data': [ { 'type': 'line',