Add line dots cursors to curves by default

bar_select
Tyler Goodlet 2020-10-21 10:46:56 -04:00
parent 1f6b5da17e
commit 875bc8be24
1 changed files with 14 additions and 6 deletions

View File

@ -13,7 +13,11 @@ from ._axes import (
DynamicDateAxis, DynamicDateAxis,
PriceAxis, PriceAxis,
) )
from ._graphics import CrossHair, BarItems, h_line from ._graphics import (
CrossHair,
BarItems,
h_line,
)
from ._axes import YSticky from ._axes import YSticky
from ._style import ( from ._style import (
hcolor, hcolor,
@ -231,6 +235,7 @@ class LinkedSplitCharts(QtGui.QWidget):
parent=self.splitter, parent=self.splitter,
axisItems={'bottom': xaxis, 'right': PriceAxis()}, axisItems={'bottom': xaxis, 'right': PriceAxis()},
viewBox=cv, viewBox=cv,
cursor=self._ch,
**cpw_kwargs, **cpw_kwargs,
) )
# this name will be used to register the primary # this name will be used to register the primary
@ -245,15 +250,15 @@ class LinkedSplitCharts(QtGui.QWidget):
# link chart x-axis to main quotes chart # link chart x-axis to main quotes chart
cpw.setXLink(self.chart) cpw.setXLink(self.chart)
# add to cross-hair's known plots
self._ch.add_plot(cpw)
# draw curve graphics # draw curve graphics
if ohlc: if ohlc:
cpw.draw_ohlc(name, array) cpw.draw_ohlc(name, array)
else: else:
cpw.draw_curve(name, array) cpw.draw_curve(name, array)
# add to cross-hair's known plots
self._ch.add_plot(cpw)
if not _is_main: if not _is_main:
# track by name # track by name
self.subplots[name] = cpw self.subplots[name] = cpw
@ -290,6 +295,7 @@ class ChartPlotWidget(pg.PlotWidget):
# the data view we generate graphics from # the data view we generate graphics from
array: np.ndarray, array: np.ndarray,
static_yrange: Optional[Tuple[float, float]] = None, static_yrange: Optional[Tuple[float, float]] = None,
cursor: Optional[CrossHair] = None,
**kwargs, **kwargs,
): ):
"""Configure chart display settings. """Configure chart display settings.
@ -309,6 +315,7 @@ class ChartPlotWidget(pg.PlotWidget):
self._vb = self.plotItem.vb self._vb = self.plotItem.vb
self._static_yrange = static_yrange # for "known y-range style" self._static_yrange = static_yrange # for "known y-range style"
self._view_mode: str = 'follow' self._view_mode: str = 'follow'
self._cursor = cursor # placehold for mouse
# show only right side axes # show only right side axes
self.hideAxis('left') self.hideAxis('left')
@ -359,8 +366,6 @@ class ChartPlotWidget(pg.PlotWidget):
def bars_range(self) -> Tuple[int, int, int, int]: def bars_range(self) -> Tuple[int, int, int, int]:
"""Return a range tuple for the bars present in view. """Return a range tuple for the bars present in view.
""" """
# vr = self.viewRect()
# l, r = int(vr.left()), int(vr.right())
l, r = self.view_range() l, r = self.view_range()
lbar = max(l, 0) lbar = max(l, 0)
rbar = min(r, len(self._array)) rbar = min(r, len(self._array))
@ -503,6 +508,9 @@ class ChartPlotWidget(pg.PlotWidget):
self._add_sticky(name) self._add_sticky(name)
if self._cursor:
self._cursor.add_curve_cursor(self, curve)
return curve return curve
def _add_sticky( def _add_sticky(