diff --git a/piker/ui/_axes.py b/piker/ui/_axes.py index 43dc28ef..1a8a65a3 100644 --- a/piker/ui/_axes.py +++ b/piker/ui/_axes.py @@ -29,7 +29,7 @@ class PriceAxis(pg.AxisItem): }) self.setLabel(**{'font-size': '10pt'}) self.setTickFont(_font) - self.setWidth(50) + self.setWidth(40) # XXX: drop for now since it just eats up h space diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 14b7c1ce..2446fd5e 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -15,7 +15,10 @@ from ._axes import ( ) from ._graphics import CrossHair, BarItems from ._axes import YSticky -from ._style import _xaxis_at, _min_points_to_show, hcolor +from ._style import ( + _xaxis_at, _min_points_to_show, hcolor, + CHART_MARGINS, +) from ..data._source import Symbol from .. import brokers from .. import data @@ -31,9 +34,6 @@ from .. import fsp log = get_logger(__name__) -# margins -CHART_MARGINS = (0, 0, 5, 3) - class ChartSpace(QtGui.QWidget): """High level widget which contains layouts for organizing @@ -135,13 +135,16 @@ class LinkedSplitCharts(QtGui.QWidget): linked_charts=self ) - if _xaxis_at == 'bottom': - self.xaxis.setStyle(showValues=False) - else: - self.xaxis_ind.setStyle(showValues=False) + # if _xaxis_at == 'bottom': + # self.xaxis.setStyle(showValues=False) + # # self.xaxis.hide() + # else: + # self.xaxis_ind.setStyle(showValues=False) + # self.xaxis.hide() self.splitter = QtGui.QSplitter(QtCore.Qt.Vertical) - self.splitter.setHandleWidth(5) + self.splitter.setMidLineWidth(3) + self.splitter.setHandleWidth(0) self.layout = QtGui.QVBoxLayout(self) self.layout.setContentsMargins(0, 0, 0, 0) @@ -187,6 +190,8 @@ class LinkedSplitCharts(QtGui.QWidget): ) # add crosshair graphic self.chart.addItem(self._ch) + if _xaxis_at == 'bottom': + self.chart.hideAxis('bottom') # style? self.chart.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain) @@ -226,8 +231,9 @@ class LinkedSplitCharts(QtGui.QWidget): cpw.name = name cpw.plotItem.vb.linked_charts = self - cpw.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain) + cpw.setFrameStyle(QtGui.QFrame.StyledPanel) # | QtGui.QFrame.Plain) cpw.getPlotItem().setContentsMargins(*CHART_MARGINS) + cpw.hideButtons() # link chart x-axis to main quotes chart cpw.setXLink(self.chart) @@ -285,7 +291,6 @@ class ChartPlotWidget(pg.PlotWidget): background=hcolor('papas_special'), # parent=None, # plotItem=None, - # useOpenGL=True, **kwargs ) self._array = array # readonly view of data @@ -431,10 +436,11 @@ class ChartPlotWidget(pg.PlotWidget): size='4pt', ) label.setParentItem(self._vb) + # label.setParentItem(self.getPlotItem()) if overlay: # position bottom left if an overlay - label.anchor(itemPos=(0, 1), parentPos=(0, 1), offset=(0, 25)) + label.anchor(itemPos=(0, 1), parentPos=(0, 1), offset=(0, 14)) self._overlays[name] = curve label.show() @@ -512,6 +518,14 @@ class ChartPlotWidget(pg.PlotWidget): begin = 0 - extra end = len(self._array) - 1 + extra + # XXX: test code for only rendering lines for the bars in view. + # This turns out to be very very poor perf when scaling out to + # many bars (think > 1k) on screen. + # name = self.name + # bars = self._graphics[self.name] + # bars.draw_lines( + # istart=max(lbar, l), iend=min(rbar, r), just_history=True) + # bars_len = rbar - lbar # log.trace( # f"\nl: {l}, lbar: {lbar}, rbar: {rbar}, r: {r}\n" @@ -701,12 +715,12 @@ async def chart_from_quotes( # faster then msgs arrive.. needs some tinkering and # testing array = ohlcv.array - last = array[-1] chart.update_from_array( chart.name, array, ) # update sticky(s) + last = array[-1] last_price_sticky.update_from_data(*last[['index', 'close']]) chart._set_yrange() diff --git a/piker/ui/_graphics.py b/piker/ui/_graphics.py index 623c0e14..9dee4564 100644 --- a/piker/ui/_graphics.py +++ b/piker/ui/_graphics.py @@ -13,41 +13,6 @@ from PyQt5.QtCore import QLineF from ._style import _xaxis_at, hcolor from ._axes import YAxisLabel, XAxisLabel - -def rec2array( - rec: np.ndarray, - fields: List[str] = None -) -> np.ndarray: - """Convert record array to std array. - - Taken from: - https://github.com/scikit-hep/root_numpy/blob/master/root_numpy/_utils.py#L20 - """ - simplify = False - - if fields is None: - fields = rec.dtype.names - elif isinstance(fields, str): - fields = [fields] - simplify = True - - # Creates a copy and casts all data to the same type - arr = np.dstack([rec[field] for field in fields]) - - # Check for array-type fields. If none, then remove outer dimension. - # Only need to check first field since np.dstack will anyway raise an - # exception if the shapes don't match - # np.dstack will also fail if fields is an empty list - if not rec.dtype[fields[0]].shape: - arr = arr[0] - - if simplify: - # remove last dimension (will be of size 1) - arr = arr.reshape(arr.shape[:-1]) - - return arr - - # TODO: # - checkout pyqtgraph.PlotCurveItem.setCompositionMode diff --git a/piker/ui/_style.py b/piker/ui/_style.py index 8d8f5099..8f8dce60 100644 --- a/piker/ui/_style.py +++ b/piker/ui/_style.py @@ -13,7 +13,6 @@ _i3_rgba = QtGui.QColor.fromRgbF(*[0.14]*3 + [1]) # splitter widget config _xaxis_at = 'bottom' - # charting config _min_points_to_show = 3 CHART_MARGINS = (0, 0, 2, 2)