Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Add stepMode to BasePlotCurveItem #1096

Merged
merged 3 commits into from
Jul 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions pydm/widgets/baseplot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import functools
import json
import warnings
from abc import abstractmethod
from qtpy.QtGui import QColor, QBrush, QMouseEvent
from qtpy.QtCore import Signal, Slot, Property, QTimer, Qt, QEvent, QObject, QRect
from qtpy.QtWidgets import QToolTip, QWidget
Expand Down Expand Up @@ -234,6 +235,39 @@ def y_axis_name(self, axis_name: str) -> None:
"""
self._y_axis_name = axis_name

@property
def stepMode(self) -> str:
"""
Returns the stepMode of the curve.

Returns
-------
str
The stepMode for the curve, one of ["center", "left", "right", None]
"""
return self.opts.get("stepMode", None)

@stepMode.setter
def stepMode(self, new_step: str) -> None:
"""
Set a new stepMode for the curve. Options are below:
- "" or None: Draw lines directly from y-value to y-value.
- "left" or "right": Draw the step with the associated y-value
to the left or right. Ensure that `len(x) == len(y)`
- "center": Draw the step with the associated y-value in the center
of the step. Ensure that `len(x) == len(y) + 1`

Parameters
----------
new_step : str
The new stepMode for the curve, can be one of
["center", "left", "right", None]
"""
if new_step == self.stepMode:
return
self.setData(stepMode=new_step)
self.redrawCurve()

@property
def lineStyle(self) -> Qt.PenStyle:
"""
Expand Down Expand Up @@ -388,6 +422,11 @@ def to_dict(self) -> OrderedDict:
]
)

@abstractmethod
def redrawCurve(self) -> None:
pass

@abstractmethod
def close(self) -> None:
pass

Expand Down
Loading