Example #1
0
    def _initialize(self):
        """ set up erything we need """

        # Let's configure some custom colors for the graph
        ca = ColorAttributes()
        ca.back = '#333333'
        ca.canvas = '#333333'
        ca.shadea = '#000000'
        ca.shadeb = '#111111'
        ca.mgrid = '#CCCCCC'
        ca.axis = '#FFFFFF'
        ca.frame = '#AAAAAA'
        ca.font = '#FFFFFF'
        ca.arrow = '#FFFFFF'

        # Let's set up the objects that will be added to the graphs
        result = []
        for graphName, graphData in graphsDefinition.items():
            tmp = []
            for sourceName, sourceData in graphData["sources"].items():
                def1 = DEF(rrdfile=self._filename, vname=sourceName, dsName=sourceName)
                tmp.append(def1)
                if sourceName.startswith("zaehlerstand"):
                  cdef1 = CDEF(vname='verbrauchpros-'+def1.vname, rpn='%s,86400,*' % def1.vname)
                  tmp.append(cdef1) 
                if sourceData["type"] == "line":
                    tmp.append(LINE(value=sourceName, color=sourceData["color"], legend=sourceData["title"]))
                elif sourceData["type"] == "area":
                    tmp.append(AREA(value=sourceName, color=sourceData["color"], legend=sourceData["title"]))
                
            # Now that we've got everything set up, let's make a graph
            g = Graph('dummy.png', vertical_label=graphData["verticalLabel"], color=ca)
            g.data.extend(tmp)
            g.title = '"%s"' % graphData["title"]
            # create a new variable
            g.filenameBase = graphName
            if graphData.get("logarithmic"):
              g.logarithmic=True  
            result.append(g)
        return result