fix(ui): Correct DPG plot syntax and axis limit handling

This commit is contained in:
2026-02-23 15:00:59 -05:00
parent 2a35df9cbe
commit c2f4b161b4

16
gui.py
View File

@@ -2188,11 +2188,11 @@ class App:
dpg.add_text("Frame:") dpg.add_text("Frame:")
dpg.add_text("0.0ms", tag="perf_frame_text", color=(100, 200, 255)) dpg.add_text("0.0ms", tag="perf_frame_text", color=(100, 200, 255))
with dpg.add_plot(label="Frame Time (ms)", height=100, width=-1, no_mouse_pos=True): dpg.add_plot(label="Frame Time (ms)", tag="plot_frame", height=100, width=-1, no_mouse_pos=True)
dpg.add_plot_axis(dpg.mvXAxis, label="samples", no_tick_labels=True) dpg.add_plot_axis(dpg.mvXAxis, label="samples", no_tick_labels=True, parent="plot_frame")
with dpg.plot_axis(dpg.mvYAxis, label="ms"): with dpg.plot_axis(dpg.mvYAxis, label="ms", tag="axis_frame_y", parent="plot_frame"):
dpg.add_line_series(list(range(100)), self.perf_history["frame_time"], label="frame time", tag="perf_frame_plot") dpg.add_line_series(list(range(100)), self.perf_history["frame_time"], label="frame time", tag="perf_frame_plot")
dpg.set_axis_limits(dpg.last_item(), 0, 50) dpg.set_axis_limits("axis_frame_y", 0, 50)
with dpg.group(horizontal=True): with dpg.group(horizontal=True):
dpg.add_text("CPU:") dpg.add_text("CPU:")
@@ -2201,11 +2201,11 @@ class App:
dpg.add_text("Input Lag:") dpg.add_text("Input Lag:")
dpg.add_text("0.0ms", tag="perf_lag_text", color=(255, 180, 80)) dpg.add_text("0.0ms", tag="perf_lag_text", color=(255, 180, 80))
with dpg.add_plot(label="CPU Usage (%)", height=100, width=-1, no_mouse_pos=True): dpg.add_plot(label="CPU Usage (%)", tag="plot_cpu", height=100, width=-1, no_mouse_pos=True)
dpg.add_plot_axis(dpg.mvXAxis, label="samples", no_tick_labels=True) dpg.add_plot_axis(dpg.mvXAxis, label="samples", no_tick_labels=True, parent="plot_cpu")
with dpg.plot_axis(dpg.mvYAxis, label="%"): with dpg.plot_axis(dpg.mvYAxis, label="%", tag="axis_cpu_y", parent="plot_cpu"):
dpg.add_line_series(list(range(100)), self.perf_history["cpu"], label="cpu usage", tag="perf_cpu_plot") dpg.add_line_series(list(range(100)), self.perf_history["cpu"], label="cpu usage", tag="perf_cpu_plot")
dpg.set_axis_limits(dpg.last_item(), 0, 100) dpg.set_axis_limits("axis_cpu_y", 0, 100)
def run(self): def run(self):
dpg.create_context() dpg.create_context()