Update plot.py

This commit is contained in:
waheebyaqub 2014-09-28 18:20:33 +04:00
parent 7cff7e31d5
commit fb7136227b
1 changed files with 29 additions and 13 deletions

View File

@ -7,11 +7,17 @@ import datetime
from electrum.util import format_satoshis from electrum.util import format_satoshis
try:
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import matplotlib.dates as md import matplotlib.dates as md
from matplotlib.patches import Ellipse from matplotlib.patches import Ellipse
from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, DrawingArea, HPacker from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, DrawingArea, HPacker
flag_matlib=True
except:
flag_matlib=False
class Plugin(BasePlugin): class Plugin(BasePlugin):
@ -23,6 +29,21 @@ class Plugin(BasePlugin):
def description(self): def description(self):
return '%s\n%s' % (_("Ability to plot transaction history in graphical mode."), _("Warning: Requires matplotlib library.")) return '%s\n%s' % (_("Ability to plot transaction history in graphical mode."), _("Warning: Requires matplotlib library."))
def is_available(self):
if flag_matlib:
return True
else:
return False
def is_enabled(self):
if not self.is_available():
return False
else:
return True
@hook @hook
def init_qt(self, gui): def init_qt(self, gui):
self.win = gui.main_window self.win = gui.main_window
@ -58,6 +79,8 @@ class Plugin(BasePlugin):
if timestamp is not None: if timestamp is not None:
try: try:
datenums.append(md.date2num(datetime.datetime.fromtimestamp(timestamp))) datenums.append(md.date2num(datetime.datetime.fromtimestamp(timestamp)))
balance_string = format_satoshis(balance, False)
balance_Val.append(float((format_satoshis(balance,False)))*1000.0)
except [RuntimeError, TypeError, NameError] as reason: except [RuntimeError, TypeError, NameError] as reason:
unknown_trans=unknown_trans+1 unknown_trans=unknown_trans+1
pass pass
@ -68,11 +91,13 @@ class Plugin(BasePlugin):
if value is not None: if value is not None:
value_string = format_satoshis(value, True) value_string = format_satoshis(value, True)
value_val.append(float(value_string)*1000.0)
else: else:
value_string = '--' value_string = '--'
if fee is not None: if fee is not None:
fee_string = format_satoshis(fee, True) fee_string = format_satoshis(fee, True)
fee_val.append(float(fee_string))
else: else:
fee_string = '0' fee_string = '0'
@ -82,14 +107,6 @@ class Plugin(BasePlugin):
else: else:
label = "" label = ""
balance_string = format_satoshis(balance, False)
balance_Val.append(float((format_satoshis(balance,False)))*1000.0)
fee_val.append(float(fee_string))
value_val.append(float(value_string)*1000.0)
f, axarr = plt.subplots(2, sharex=True) f, axarr = plt.subplots(2, sharex=True)
@ -102,7 +119,6 @@ class Plugin(BasePlugin):
box1.set_text(test11) box1.set_text(test11)
box = HPacker(children=[box1], box = HPacker(children=[box1],
align="center", align="center",
pad=0.1, sep=15) pad=0.1, sep=15)