VirtualBox

Ignore:
Timestamp:
Dec 23, 2019 8:53:40 PM (5 years ago)
Author:
vboxsync
Message:

TestManager/wuihlpgraphgooglechart.py++: Bar graph invertion and other tweaks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testmanager/webui/wuihlpgraphgooglechart.py

    r82645 r82648  
    5353        self.fpMax = None;
    5454        self.fpMin = 0.0;
     55        self.fYInverted = False;
    5556
    5657    def setRangeMax(self, fpMax):
     
    5960        return None;
    6061
     62    def invertYDirection(self):
     63        """ Inverts the direction of the Y-axis direction. """
     64        self.fYInverted = True;
     65        return None;
     66
    6167    def renderGraph(self):
    6268        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;
    6375
    6476        # Unique on load function.
     
    8193                 '             "title": "%s",\n' \
    8294                 '         },\n' \
    83                  '    };\n' \
     95                 '         "vAxis": {\n' \
     96                 '             "direction": %s,\n' \
     97                 '         },\n' \
    8498                % ( iGraph,
    8599                    iGraph,
    86100                    webutils.escapeAttrJavaScriptStringDQ(self._sTitle) if self._sTitle is not None else '',
    87101                    webutils.escapeAttrJavaScriptStringDQ(aoTable[0].sName) if aoTable and aoTable[0].sName else '',
     102                    '-1' if self.fYInverted else '1',
    88103                  );
     104        if fUseMaterial and self.fYInverted:
     105            sHtml +=  '        "axes": { "x": { 0: { "side": "top" } }, "y": { "0": { "direction": -1, }, }, },\n';
     106        sHtml += '    };\n';
    89107
    90108        # The data.
     
    104122            sHtml += '    oData.addRows([\n';
    105123            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';
    107128                for iValue, oValue in enumerate(oRow.aoValues):
    108129                    if not utils.isString(oValue):
     
    129150
    130151        # 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, );
    134160
    135161        # clean and return.
Note: See TracChangeset for help on using the changeset viewer.

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