Example #1
0
  def _render(self, params):
    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'

    currentTime = int(time.time())

    start = currentTime - getIntOrElse(params, "start", (3 * hour))
    end = currentTime - getIntOrElse(params, "end", 0)
    logarithmic = getBooleanOrElse(params, "logarithmic", False)
    step = getIntOrElse(params, "step", 60)
    width = getIntOrElse(params, "width", 800)
    height = getIntOrElse(params, "height", 400)
    graphs = getStringOrElse(params, "graphs", getAllZaehlerNames())

    upperlimit = getIntOrElse(params, "upperlimit", None)
    lowerlimit = getIntOrElse(params, "lowerlimit", None)

    generated_file = "/tmp/%d-%d.png" % (time.time(),random.randint(0, 100000))

    g = Graph(generated_file, start=start, end=end, vertical_label='100mWh/min', color=ca)
    g.data.extend(self._createLines(graphs))
    g.width = width
    g.height = height
    g.step = step
    g.logarithmic = logarithmic

    if upperlimit:
      g.upper_limit=upperlimit
    if lowerlimit:
      g.lower_limit=lowerlimit

    g.rigid=True
    g.write()

    return generated_file