Mercurial > ~darius > hgwebdir.cgi > vanlogger
diff graph.py @ 8:30e7adf283ca
Add depth of discharge annotation when plotting state_of_charge
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Fri, 22 Dec 2017 13:10:23 +0100 |
parents | a7e9775b33f6 |
children | 899bc9c22787 |
line wrap: on
line diff
--- a/graph.py Fri Dec 22 13:05:05 2017 +0100 +++ b/graph.py Fri Dec 22 13:10:23 2017 +0100 @@ -13,20 +13,21 @@ import tzlocal class Column(object): - def __init__(self, rowname, title, table, units, limits = (None, None), conv = None): + def __init__(self, rowname, title, table, units, limits = (None, None), conv = None, annofn = None): self.rowname = rowname self.title = title self.table = table self.units = units self.limits = limits - self.conv = None + self.conv = conv + self.annofn = annofn columns = [ Column('main_voltage', 'Battery Voltage', 'eprolog', 'Vdc'), Column('aux_voltage', 'Aux Voltage', 'eprolog', 'Vdc'), Column('battery_curr', 'Battery Current', 'eprolog', 'A'), Column('amp_hours', 'Battery Amp Hours', 'eprolog', 'Ah'), - Column('state_of_charge', 'State of Charge', 'eprolog', '%', (0, 100)), + Column('state_of_charge', 'State of Charge', 'eprolog', '%', (0, 100), annofn = lambda xdata, ydata: 'DoD: %.1f' % (100 - ydata.min())), Column('time_remaining', 'Time Remaining', 'eprolog', 'min'), Column('battery_temp', 'Battery Temperature', 'eprolog', 'C'), @@ -165,7 +166,10 @@ scale_min, scale_max = c.limits # DoD? - c.annotation = None + if c.annofn != None: + c.annotation = c.annofn(c.xdata, c.ydata) + else: + c.annotation = None # Work out which axis to plot on if c.units == yaxisunits1: