1 | # -*- coding: utf-8 -*-
|
---|
2 | # $Id: wuihlpgraphbase.py 82968 2020-02-04 10:35:17Z vboxsync $
|
---|
3 |
|
---|
4 | """
|
---|
5 | Test Manager Web-UI - Graph Helpers - Base Class.
|
---|
6 | """
|
---|
7 |
|
---|
8 | __copyright__ = \
|
---|
9 | """
|
---|
10 | Copyright (C) 2012-2020 Oracle Corporation
|
---|
11 |
|
---|
12 | This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
13 | available from http://www.virtualbox.org. This file is free software;
|
---|
14 | you can redistribute it and/or modify it under the terms of the GNU
|
---|
15 | General Public License (GPL) as published by the Free Software
|
---|
16 | Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
17 | VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
18 | hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
19 |
|
---|
20 | The contents of this file may alternatively be used under the terms
|
---|
21 | of the Common Development and Distribution License Version 1.0
|
---|
22 | (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
23 | VirtualBox OSE distribution, in which case the provisions of the
|
---|
24 | CDDL are applicable instead of those of the GPL.
|
---|
25 |
|
---|
26 | You may elect to license modified versions of this file under the
|
---|
27 | terms and conditions of either the GPL or the CDDL or both.
|
---|
28 | """
|
---|
29 | __version__ = "$Revision: 82968 $"
|
---|
30 |
|
---|
31 |
|
---|
32 | class WuiHlpGraphBase(object):
|
---|
33 | """
|
---|
34 | Base class for the Graph helpers.
|
---|
35 | """
|
---|
36 |
|
---|
37 | ## Set of colors that can be used by child classes to color data series.
|
---|
38 | kasColors = \
|
---|
39 | [
|
---|
40 | '#0000ff', # Blue
|
---|
41 | '#00ff00', # Green
|
---|
42 | '#ff0000', # Red
|
---|
43 | '#000000', # Black
|
---|
44 |
|
---|
45 | '#00ffff', # Cyan/Aqua
|
---|
46 | '#ff00ff', # Magenta/Fuchsia
|
---|
47 | '#ffff00', # Yellow
|
---|
48 | '#8b4513', # SaddleBrown
|
---|
49 |
|
---|
50 | '#7b68ee', # MediumSlateBlue
|
---|
51 | '#ffc0cb', # Pink
|
---|
52 | '#bdb76b', # DarkKhaki
|
---|
53 | '#008080', # Teal
|
---|
54 |
|
---|
55 | '#bc8f8f', # RosyBrown
|
---|
56 | '#000080', # Navy(Blue)
|
---|
57 | '#dc143c', # Crimson
|
---|
58 | '#800080', # Purple
|
---|
59 |
|
---|
60 | '#daa520', # Goldenrod
|
---|
61 | '#40e0d0', # Turquoise
|
---|
62 | '#00bfff', # DeepSkyBlue
|
---|
63 | '#c0c0c0', # Silver
|
---|
64 | ];
|
---|
65 |
|
---|
66 |
|
---|
67 | def __init__(self, sId, oData, oDisp):
|
---|
68 | self._sId = sId;
|
---|
69 | self._oData = oData;
|
---|
70 | self._oDisp = oDisp;
|
---|
71 | # Graph output dimensions.
|
---|
72 | self._cxGraph = 1024;
|
---|
73 | self._cyGraph = 448;
|
---|
74 | self._cDpiGraph = 96;
|
---|
75 | # Other graph attributes
|
---|
76 | self._sTitle = None;
|
---|
77 | self._cPtFont = 8;
|
---|
78 |
|
---|
79 | def headerContent(self):
|
---|
80 | """
|
---|
81 | Returns content that goes into the HTML header.
|
---|
82 | """
|
---|
83 | return '';
|
---|
84 |
|
---|
85 | def renderGraph(self):
|
---|
86 | """
|
---|
87 | Renders the graph.
|
---|
88 | Returning HTML.
|
---|
89 | """
|
---|
90 | return '<p>renderGraph needs to be overridden by the child class!</p>';
|
---|
91 |
|
---|
92 | def setTitle(self, sTitle):
|
---|
93 | """ Sets the graph title. """
|
---|
94 | self._sTitle = sTitle;
|
---|
95 | return True;
|
---|
96 |
|
---|
97 | def setWidth(self, cx):
|
---|
98 | """ Sets the graph width. """
|
---|
99 | self._cxGraph = cx;
|
---|
100 | return True;
|
---|
101 |
|
---|
102 | def setHeight(self, cy):
|
---|
103 | """ Sets the graph height. """
|
---|
104 | self._cyGraph = cy;
|
---|
105 | return True;
|
---|
106 |
|
---|
107 | def setDpi(self, cDotsPerInch):
|
---|
108 | """ Sets the graph DPI. """
|
---|
109 | self._cDpiGraph = cDotsPerInch;
|
---|
110 | return True;
|
---|
111 |
|
---|
112 | def setFontSize(self, cPtFont):
|
---|
113 | """ Sets the default font size. """
|
---|
114 | self._cPtFont = cPtFont;
|
---|
115 | return True;
|
---|
116 |
|
---|
117 |
|
---|
118 | @staticmethod
|
---|
119 | def calcSeriesColor(iSeries):
|
---|
120 | """ Returns a #rrggbb color code for the given series. """
|
---|
121 | return WuiHlpGraphBase.kasColors[iSeries % len(WuiHlpGraphBase.kasColors)];
|
---|