Changeset 82648 in vbox for trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraphgooglechart.py
- Timestamp:
- Dec 23, 2019 8:53:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraphgooglechart.py
r82645 r82648 53 53 self.fpMax = None; 54 54 self.fpMin = 0.0; 55 self.fYInverted = False; 55 56 56 57 def setRangeMax(self, fpMax): … … 59 60 return None; 60 61 62 def invertYDirection(self): 63 """ Inverts the direction of the Y-axis direction. """ 64 self.fYInverted = True; 65 return None; 66 61 67 def renderGraph(self): 62 68 aoTable = self._oData.aoTable; # type: WuiHlpGraphDataTable 69 70 # Seems material (google.charts.Bar) cannot change the direction on the Y-axis, 71 # so we cannot get bars growing downwards from the top like we want for the 72 # reports. The classic charts OTOH cannot put X-axis labels on the top, but 73 # we just drop them all together instead, saving a little space. 74 fUseMaterial = False; 63 75 64 76 # Unique on load function. … … 81 93 ' "title": "%s",\n' \ 82 94 ' },\n' \ 83 ' };\n' \ 95 ' "vAxis": {\n' \ 96 ' "direction": %s,\n' \ 97 ' },\n' \ 84 98 % ( iGraph, 85 99 iGraph, 86 100 webutils.escapeAttrJavaScriptStringDQ(self._sTitle) if self._sTitle is not None else '', 87 101 webutils.escapeAttrJavaScriptStringDQ(aoTable[0].sName) if aoTable and aoTable[0].sName else '', 102 '-1' if self.fYInverted else '1', 88 103 ); 104 if fUseMaterial and self.fYInverted: 105 sHtml += ' "axes": { "x": { 0: { "side": "top" } }, "y": { "0": { "direction": -1, }, }, },\n'; 106 sHtml += ' };\n'; 89 107 90 108 # The data. … … 104 122 sHtml += ' oData.addRows([\n'; 105 123 for oRow in aoTable[1:]: 106 sRow = ' [ "%s"' % (webutils.escapeAttrJavaScriptStringDQ(oRow.sName),); 124 if oRow.sName: 125 sRow = ' [ "%s"' % (webutils.escapeAttrJavaScriptStringDQ(oRow.sName),); 126 else: 127 sRow = ' [ null'; 107 128 for iValue, oValue in enumerate(oRow.aoValues): 108 129 if not utils.isString(oValue): … … 129 150 130 151 # Create and draw. 131 sHtml += ' oGraph = new google.visualization.ColumnChart(document.getElementById("%s"));\n' \ 132 ' oGraph.draw(oData, dGraphOptions);\n' \ 133 % ( self._sId, ); 152 if not fUseMaterial: 153 sHtml += ' oGraph = new google.visualization.ColumnChart(document.getElementById("%s"));\n' \ 154 ' oGraph.draw(oData, dGraphOptions);\n' \ 155 % ( self._sId, ); 156 else: 157 sHtml += ' oGraph = new google.charts.Bar(document.getElementById("%s"));\n' \ 158 ' oGraph.draw(oData, google.charts.Bar.convertOptions(dGraphOptions));\n' \ 159 % ( self._sId, ); 134 160 135 161 # clean and return.
Note:
See TracChangeset
for help on using the changeset viewer.