Add `ChartPlotWidget.in_view()` shm-compatible array slicer
parent
39b7c9340d
commit
4d4f745918
|
@ -376,12 +376,15 @@ class LinkedSplits(QWidget):
|
||||||
'''
|
'''
|
||||||
ln = len(self.subplots)
|
ln = len(self.subplots)
|
||||||
|
|
||||||
if not prop:
|
|
||||||
# proportion allocated to consumer subcharts
|
# proportion allocated to consumer subcharts
|
||||||
if ln < 2:
|
if not prop:
|
||||||
prop = 1/3
|
prop = 3/8*5/8
|
||||||
elif ln >= 2:
|
|
||||||
prop = 3/8
|
# if ln < 2:
|
||||||
|
# prop = 3/8*5/8
|
||||||
|
|
||||||
|
# elif ln >= 2:
|
||||||
|
# prop = 3/8
|
||||||
|
|
||||||
major = 1 - prop
|
major = 1 - prop
|
||||||
min_h_ind = int((self.height() * prop) / ln)
|
min_h_ind = int((self.height() * prop) / ln)
|
||||||
|
@ -844,7 +847,7 @@ class ChartPlotWidget(pg.PlotWidget):
|
||||||
log.warning(f'array for {self.name} not loaded yet?')
|
log.warning(f'array for {self.name} not loaded yet?')
|
||||||
return
|
return
|
||||||
|
|
||||||
begin = xlast - _bars_to_left_in_follow_mode
|
begin = xlast - 1000
|
||||||
end = xlast + _bars_from_right_in_follow_mode
|
end = xlast + _bars_from_right_in_follow_mode
|
||||||
|
|
||||||
# remove any custom user yrange setttings
|
# remove any custom user yrange setttings
|
||||||
|
@ -858,6 +861,11 @@ class ChartPlotWidget(pg.PlotWidget):
|
||||||
padding=0,
|
padding=0,
|
||||||
)
|
)
|
||||||
view._set_yrange()
|
view._set_yrange()
|
||||||
|
self.view.maybe_downsample_graphics()
|
||||||
|
try:
|
||||||
|
self.linked.graphics_cycle()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def increment_view(
|
def increment_view(
|
||||||
self,
|
self,
|
||||||
|
@ -1003,12 +1011,6 @@ class ChartPlotWidget(pg.PlotWidget):
|
||||||
# on data reads and makes graphics rendering no faster
|
# on data reads and makes graphics rendering no faster
|
||||||
# clipToView=True,
|
# clipToView=True,
|
||||||
|
|
||||||
# TODO: see how this handles with custom ohlcv bars graphics
|
|
||||||
# and/or if we can implement something similar for OHLC graphics
|
|
||||||
# autoDownsample=True,
|
|
||||||
# downsample=60,
|
|
||||||
# downsampleMethod='subsample',
|
|
||||||
|
|
||||||
**pdi_kwargs,
|
**pdi_kwargs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1198,6 +1200,23 @@ class ChartPlotWidget(pg.PlotWidget):
|
||||||
else:
|
else:
|
||||||
return ohlc['index'][-1]
|
return ohlc['index'][-1]
|
||||||
|
|
||||||
|
def in_view(
|
||||||
|
self,
|
||||||
|
array: np.ndarray,
|
||||||
|
|
||||||
|
) -> np.ndarray:
|
||||||
|
'''
|
||||||
|
Slice an input struct array providing only datums
|
||||||
|
"in view" of this chart.
|
||||||
|
|
||||||
|
'''
|
||||||
|
l, lbar, rbar, r = self.bars_range()
|
||||||
|
ifirst = array[0]['index']
|
||||||
|
# slice data by offset from the first index
|
||||||
|
# available in the passed datum set.
|
||||||
|
start = lbar - ifirst
|
||||||
|
return array[lbar - ifirst:(rbar - ifirst) + 1]
|
||||||
|
|
||||||
def maxmin(
|
def maxmin(
|
||||||
self,
|
self,
|
||||||
name: Optional[str] = None,
|
name: Optional[str] = None,
|
||||||
|
|
Loading…
Reference in New Issue