Differentiate array schema by close field

bar_select
Tyler Goodlet 2020-10-19 11:37:28 -04:00
parent c7d5ea6e15
commit d3dc8fb219
1 changed files with 9 additions and 7 deletions

View File

@ -28,7 +28,7 @@ class PriceAxis(pg.AxisItem):
# 'tickTextWidth': 40, # 'tickTextWidth': 40,
# 'autoExpandTextSpace': True, # 'autoExpandTextSpace': True,
# 'maxTickLength': -20, # 'maxTickLength': -20,
# 'stopAxisAtTick': (True, True), # 'stopAxisAtTick': (True, True), # doesn't work well on price
}) })
# self.setLabel(**{'font-size': '10pt'}) # self.setLabel(**{'font-size': '10pt'})
self.setWidth(40) self.setWidth(40)
@ -244,9 +244,11 @@ class YSticky(YAxisLabel):
def update_on_resize(self, vr, r): def update_on_resize(self, vr, r):
# TODO: add an `.index` to the array data-buffer layer # TODO: add an `.index` to the array data-buffer layer
# and make this way less shitty... # and make this way less shitty...
a = self._chart._array chart = self._chart
name = chart.name
a = chart._array
fields = a.dtype.fields fields = a.dtype.fields
if fields and 'index' in fields: if fields and 'close' in fields:
index, last = a[-1][['index', 'close']] index, last = a[-1][['index', 'close']]
else: else:
# non-ohlc case # non-ohlc case
@ -260,9 +262,9 @@ class YSticky(YAxisLabel):
def update_from_data( def update_from_data(
self, self,
index: int, index: int,
last: float, value: float,
) -> None: ) -> None:
self.update_label( self.update_label(
self._chart.mapFromView(QPointF(index, last)), self._chart.mapFromView(QPointF(index, value)),
last value
) )