|
@@ -28,8 +28,7 @@ from ..widgets import (
|
|
FocusWidget,
|
|
FocusWidget,
|
|
AutoCompletePopUp,
|
|
AutoCompletePopUp,
|
|
NoTabCheckBox,
|
|
NoTabCheckBox,
|
|
- FlowBarGraph,
|
|
|
|
- FlowGraphVScale,
|
|
|
|
|
|
+ FlowBarGraphWithVScale,
|
|
)
|
|
)
|
|
from . import ActivityManager
|
|
from . import ActivityManager
|
|
from .Rating import Rating
|
|
from .Rating import Rating
|
|
@@ -101,6 +100,7 @@ class TransactionEditor(FocusWidget):
|
|
for (k, tf) in self.text_fields.items():
|
|
for (k, tf) in self.text_fields.items():
|
|
if k != 'dbview':
|
|
if k != 'dbview':
|
|
tf.set_text('')
|
|
tf.set_text('')
|
|
|
|
+ self.graph.set_data([],0)
|
|
return self.update()
|
|
return self.update()
|
|
|
|
|
|
def update(self):
|
|
def update(self):
|
|
@@ -132,7 +132,7 @@ class TransactionEditor(FocusWidget):
|
|
self.rating.update_rating(None, None, None, unit)
|
|
self.rating.update_rating(None, None, None, unit)
|
|
return
|
|
return
|
|
|
|
|
|
- df = self.query_manager.get_historic_prices_data(unit, product=product, organic=organic)
|
|
|
|
|
|
+ df = self.query_manager.get_historic_prices_data(unit, product=product, organic=organic, sort='ts')
|
|
if df.empty:
|
|
if df.empty:
|
|
self.rating.update_rating(None, None, None, unit)
|
|
self.rating.update_rating(None, None, None, unit)
|
|
return
|
|
return
|
|
@@ -143,23 +143,21 @@ class TransactionEditor(FocusWidget):
|
|
float(x) for x in df[['avg','min','max']].iloc[0]
|
|
float(x) for x in df[['avg','min','max']].iloc[0]
|
|
]
|
|
]
|
|
self.rating.update_rating(_avg, _min, _max, unit, price=price, quantity=quantity)
|
|
self.rating.update_rating(_avg, _min, _max, unit, price=price, quantity=quantity)
|
|
|
|
+ df = df.sort_values('ts_raw', ascending=True)
|
|
#print(df)
|
|
#print(df)
|
|
#input()
|
|
#input()
|
|
- self.graph._invalidate()
|
|
|
|
- top = 10 # need to set this same as in column widget
|
|
|
|
- scale = (df['max'].apply(float).iloc[0]/top)*(top+1)
|
|
|
|
- self.graph.set_bar_width(1)
|
|
|
|
# need to sort by ts and take last 45 items
|
|
# need to sort by ts and take last 45 items
|
|
- self.graph.set_data(df[['ts_raw','$/unit']].apply(
|
|
|
|
- lambda x, axis=None: (
|
|
|
|
- x['ts_raw'].timestamp(), float(x['$/unit'])
|
|
|
|
- ), axis=1), scale)
|
|
|
|
- self.graph_vscale._invalidate()
|
|
|
|
- self.graph_vscale.set_scale([
|
|
|
|
- ((_min*top)//scale, f'{_min:>5.2f} '),
|
|
|
|
- ((_avg*top)//scale, f'{_avg:>5.2f} '),
|
|
|
|
- ((_max*top)//scale, f'{_max:>5.2f} '),
|
|
|
|
- ], top)
|
|
|
|
|
|
+ self.graph.set_data(
|
|
|
|
+ df[['ts_raw','$/unit']].apply(
|
|
|
|
+ lambda x, axis=None: (
|
|
|
|
+ x['ts_raw'].timestamp(), float(x['$/unit'])
|
|
|
|
+ ), axis=1
|
|
|
|
+ ),
|
|
|
|
+ df['max'].apply(float).iloc[0],
|
|
|
|
+ labels=[_min, _avg, _max]
|
|
|
|
+ )
|
|
|
|
+ self.graph.set_bar_width(1)
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
def focus_on_product(self):
|
|
def focus_on_product(self):
|
|
@@ -202,8 +200,11 @@ class TransactionEditor(FocusWidget):
|
|
'spread': Text(''),
|
|
'spread': Text(''),
|
|
'marker': Text(''),
|
|
'marker': Text(''),
|
|
}
|
|
}
|
|
- self.graph = FlowBarGraph(['bg','badge_highlight','popup_focus', ], hatt=['dark red', 'dark red', 'dark red'])
|
|
|
|
- self.graph_vscale = FlowGraphVScale(self.graph, [], 0)
|
|
|
|
|
|
+ self.graph = FlowBarGraphWithVScale(
|
|
|
|
+ 50, 14,
|
|
|
|
+ ['bg','badge_highlight','popup_focus', ],
|
|
|
|
+ hatt=['dark red', 'dark red', 'dark red']
|
|
|
|
+ )
|
|
self.rating = Rating(dict(filter(
|
|
self.rating = Rating(dict(filter(
|
|
lambda x: x[0] in ('spread','rating','marker'),
|
|
lambda x: x[0] in ('spread','rating','marker'),
|
|
self.text_fields.items()
|
|
self.text_fields.items()
|
|
@@ -273,15 +274,12 @@ class TransactionEditor(FocusWidget):
|
|
lambda x: _widgets[x] if x is not None else Divider(),
|
|
lambda x: _widgets[x] if x is not None else Divider(),
|
|
bottom_pane
|
|
bottom_pane
|
|
)),
|
|
)),
|
|
- (50, Pile([
|
|
|
|
|
|
+ (self.graph.width, Pile([
|
|
LineBox(
|
|
LineBox(
|
|
AttrMap(components['badge'], 'badge'),
|
|
AttrMap(components['badge'], 'badge'),
|
|
title="Current Price", title_align='left',
|
|
title="Current Price", title_align='left',
|
|
),
|
|
),
|
|
- Columns([
|
|
|
|
- (6, self.graph_vscale),
|
|
|
|
- (44, self.graph),
|
|
|
|
- ])
|
|
|
|
|
|
+ self.graph,
|
|
])),
|
|
])),
|
|
])
|
|
])
|
|
})
|
|
})
|