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

[sinks/dashboard] HOTFIX - IMPORTANT: Set Plot Title to 100 char max instead of 50 + Break into 2 lines #367

Merged
merged 6 commits into from
Mar 7, 2025
Merged
Changes from 5 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
29 changes: 14 additions & 15 deletions sinks/dashboard/items/plot_dash_item.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
from publisher import publisher
from pyqtgraph.Qt.QtWidgets import QGridLayout, QMenu
from pyqtgraph.parametertree.parameterTypes import ChecklistParameter
from pyqtgraph.Qt.QtCore import QEvent
from pyqtgraph.Qt.QtWidgets import QGridLayout
import pyqtgraph as pg
import numpy as np

from .dashboard_item import DashboardItem
import config
Expand Down Expand Up @@ -40,8 +37,8 @@ def __init__(self, *args):
publisher.subscribe(series, self.on_data_update)

# a default color list for plotting multiple curves
# yellow green cyan white blue magenta
self.color = ['k', 'g', 'c', 'w', 'b', 'm']
# black blue magenta green cyan white
self.color = ['k', 'b', 'm', 'g', 'c', 'w']

# create the plot
self.plot = self.create_plot()
Expand Down Expand Up @@ -152,22 +149,24 @@ def on_data_update(self, stream, payload):
self.plot.setXRange(t - config.GRAPH_DURATION + config.GRAPH_STEP,
t + config.GRAPH_STEP, padding=0)

series_name: str = ""
# data series name
series_name += " / ".join(self.series) # join all data series on plot

# value readout in the title for at most 2 series
title = ""
current_values: str = ""
if len(self.series) <= 2:
# avg values
title += " current: "
current_values += "Current: "
last_values = [self.points[item][-1]
if self.points[item] else 0 for item in self.series]
for v in last_values:
title += f"[{v: < 4.4f}]"
title += " "
# data series name
title += "/".join(self.series)
if len(title) > 50:
title = title[:50]
current_values += f"[{v: < 4.4f}] "

# 100 CHARS MAX for title
series_name = f"{series_name[:100]}..." if len(series_name) > 100 else series_name[:100]

self.plot.setTitle(title)
self.plot.setTitle(title=f"<div style='font-size: 16pt;'><br/><b>{series_name}</b><br/>{current_values}</div>")

@staticmethod
def get_name():
Expand Down