VirtualBox

source: vbox/trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraph.py@ 78352

Last change on this file since 78352 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
1# -*- coding: utf-8 -*-
2# $Id: wuihlpgraph.py 76553 2019-01-01 01:45:53Z vboxsync $
3
4"""
5Test Manager Web-UI - Graph Helpers.
6"""
7
8__copyright__ = \
9"""
10Copyright (C) 2012-2019 Oracle Corporation
11
12This file is part of VirtualBox Open Source Edition (OSE), as
13available from http://www.virtualbox.org. This file is free software;
14you can redistribute it and/or modify it under the terms of the GNU
15General Public License (GPL) as published by the Free Software
16Foundation, in version 2 as it comes in the "COPYING" file of the
17VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19
20The contents of this file may alternatively be used under the terms
21of the Common Development and Distribution License Version 1.0
22(CDDL) only, as it comes in the "COPYING.CDDL" file of the
23VirtualBox OSE distribution, in which case the provisions of the
24CDDL are applicable instead of those of the GPL.
25
26You may elect to license modified versions of this file under the
27terms and conditions of either the GPL or the CDDL or both.
28"""
29__version__ = "$Revision: 76553 $"
30
31
32class WuiHlpGraphDataTable(object): # pylint: disable=R0903
33 """
34 Data table container.
35 """
36
37 class Row(object): # pylint: disable=R0903
38 """A row."""
39 def __init__(self, sGroup, aoValues, asValues = None):
40 self.sName = sGroup;
41 self.aoValues = aoValues;
42 if asValues is None:
43 self.asValues = [str(oVal) for oVal in aoValues];
44 else:
45 assert len(asValues) == len(aoValues);
46 self.asValues = asValues;
47
48 def __init__(self, sGroupLable, asMemberLabels):
49 self.aoTable = [ WuiHlpGraphDataTable.Row(sGroupLable, asMemberLabels), ];
50
51 def addRow(self, sGroup, aoValues, asValues = None):
52 """Adds a row to the data table."""
53 self.aoTable.append(WuiHlpGraphDataTable.Row(sGroup, aoValues, asValues));
54 return True;
55
56 def getGroupCount(self):
57 """Gets the number of data groups (rows)."""
58 return len(self.aoTable) - 1;
59
60
61class WuiHlpGraphDataTableEx(object): # pylint: disable=R0903
62 """
63 Data container for an table/graph with optional error bars on the Y values.
64 """
65
66 class DataSeries(object): # pylint: disable=R0903
67 """
68 A data series.
69
70 The aoXValues, aoYValues and aoYErrorBars are parallel arrays, making a
71 series of (X,Y,Y-err-above-delta,Y-err-below-delta) points.
72
73 The error bars are optional.
74 """
75 def __init__(self, sName, aoXValues, aoYValues, asHtmlTooltips = None, aoYErrorBarBelow = None, aoYErrorBarAbove = None):
76 self.sName = sName;
77 self.aoXValues = aoXValues;
78 self.aoYValues = aoYValues;
79 self.asHtmlTooltips = asHtmlTooltips;
80 self.aoYErrorBarBelow = aoYErrorBarBelow;
81 self.aoYErrorBarAbove = aoYErrorBarAbove;
82
83 def __init__(self, sXUnit, sYUnit):
84 self.sXUnit = sXUnit;
85 self.sYUnit = sYUnit;
86 self.aoSeries = [];
87
88 def addDataSeries(self, sName, aoXValues, aoYValues, asHtmlTooltips = None, aoYErrorBarBelow = None, aoYErrorBarAbove = None):
89 """Adds an data series to the table."""
90 self.aoSeries.append(WuiHlpGraphDataTableEx.DataSeries(sName, aoXValues, aoYValues, asHtmlTooltips,
91 aoYErrorBarBelow, aoYErrorBarAbove));
92 return True;
93
94 def getDataSeriesCount(self):
95 """Gets the number of data series."""
96 return len(self.aoSeries);
97
98
99#
100# Dynamically choose implementation.
101#
102if True: # pylint: disable=W0125
103 from testmanager.webui import wuihlpgraphgooglechart as GraphImplementation;
104else:
105 try:
106 import matplotlib; # pylint: disable=W0611,F0401,import-error,wrong-import-order
107 from testmanager.webui import wuihlpgraphmatplotlib as GraphImplementation; # pylint: disable=ungrouped-imports
108 except:
109 from testmanager.webui import wuihlpgraphsimple as GraphImplementation;
110
111# pylint: disable=C0103
112WuiHlpBarGraph = GraphImplementation.WuiHlpBarGraph;
113WuiHlpLineGraph = GraphImplementation.WuiHlpLineGraph;
114WuiHlpLineGraphErrorbarY = GraphImplementation.WuiHlpLineGraphErrorbarY;
115
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette