Skip to content
Open
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
16 changes: 13 additions & 3 deletions trace/widgets/control_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,10 @@ def add_curve(self, pv: str = None) -> "CurveItem":
if pv.startswith("f://"):
return last_axis.add_formula_curve(pv)
else:
return last_axis.add_curve(pv)
curve = last_axis.add_curve(pv)
curve.move_to_axis_from_unit() # Move to axis based on unit

return curve

def clear_all(self) -> None:
"""Clear all axes and curves from the plot and control panel."""
Expand Down Expand Up @@ -950,11 +953,18 @@ def __init__(self, axis_item: AxisItem, source: ArchivePlotCurveItem | FormulaCu

self.variable_name = self.control_panel.key_gen.send(self.source)
self.control_panel.curve_dict[self.variable_name] = self.source
if not self.is_formula_curve():
self.source.unitSignal.connect(lambda unit: self.control_panel.move_curve_to_axis(self, unit))

self.setup_layout()

def move_to_axis_from_unit(self):
"""Automatically move curve to axis based on unit"""
if not self.is_formula_curve():
unit = self.source.units
if unit:
self.control_panel.move_curve_to_axis(self, unit)
else:
self.source.unitSignal.connect(lambda unit: self.control_panel.move_curve_to_axis(self, unit))

@property
def plot(self):
"""Get the PlotWidget that this CurveItem belongs to."""
Expand Down
Loading