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

Add LineGraph new properties: axis legend font and font size #624

Merged
merged 4 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/themes-screenshot-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ jobs:
name: themes-screenshots
path: |
screenshot-*.png
diff-*.png
diff-*.png
8 changes: 4 additions & 4 deletions library/lcd/lcd_comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
line_width: int = 2,
graph_axis: bool = True,
axis_color: Tuple[int, int, int] = (0, 0, 0),
font: str = "./res/fonts/roboto/Roboto-Black.ttf",
font_size: int = 10,
axis_font: str = "./res/fonts/roboto/Roboto-Black.ttf",
axis_font_size: int = 10,
background_color: Tuple[int, int, int] = (255, 255, 255),
background_image: str = None):
# Generate a plot graph and display it
Expand Down Expand Up @@ -434,13 +434,13 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
# Draw Legend
draw.line([0, 0, 1, 0], fill=axis_color)
text = f"{int(max_value)}"
ttfont = ImageFont.truetype(font, font_size)
ttfont = ImageFont.truetype(axis_font, axis_font_size)
left, top, right, bottom = ttfont.getbbox(text)
draw.text((2, 0 - top), text,
font=ttfont, fill=axis_color)

text = f"{int(min_value)}"
ttfont = ImageFont.truetype(font, font_size)
ttfont = ImageFont.truetype(axis_font, axis_font_size)
left, top, right, bottom = ttfont.getbbox(text)
draw.text((width - 1 - right, height - 2 - bottom), text,
font=ttfont, fill=axis_color)
Expand Down
2 changes: 2 additions & 0 deletions library/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ def display_themed_line_graph(theme_data, values):
line_width=theme_data.get("LINE_WIDTH", 2),
graph_axis=theme_data.get("AXIS", False),
axis_color=theme_data.get("AXIS_COLOR", line_color), # If no color specified, use line color for axis
axis_font=config.FONTS_DIR + theme_data.get("AXIS_FONT", "roboto/Roboto-Black.ttf"),
axis_font_size=theme_data.get("AXIS_FONT_SIZE", 10),
background_color=theme_data.get("BACKGROUND_COLOR", (0, 0, 0)),
background_image=get_theme_file_path(theme_data.get("BACKGROUND_IMAGE", None))
)
Expand Down
12 changes: 12 additions & 0 deletions res/themes/ColoredFlat/theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ STATS:
LINE_COLOR: 247, 227, 227
AXIS: true
AXIS_COLOR: 247, 227, 227
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
FREQUENCY:
INTERVAL: 1
Expand Down Expand Up @@ -152,6 +154,8 @@ STATS:
LINE_COLOR: 247, 227, 227
AXIS: True
AXIS_COLOR: 247, 227, 227
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
MEMORY:
GRAPH:
Expand Down Expand Up @@ -263,6 +267,8 @@ STATS:
LINE_COLOR: 247, 227, 227
AXIS: true
AXIS_COLOR: 247, 227, 227
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
USED:
SHOW: True
Expand Down Expand Up @@ -425,6 +431,8 @@ STATS:
LINE_COLOR: 247, 227, 227
AXIS: True
AXIS_COLOR: 247, 227, 227
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
UPLOADED:
TEXT:
Expand Down Expand Up @@ -457,6 +465,8 @@ STATS:
LINE_COLOR: 247, 227, 227
AXIS: True
AXIS_COLOR: 247, 227, 227
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
DOWNLOADED:
TEXT:
Expand Down Expand Up @@ -564,4 +574,6 @@ STATS:
LINE_COLOR: 247, 227, 227
AXIS: True
AXIS_COLOR: 247, 227, 227
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
2 changes: 2 additions & 0 deletions res/themes/CustomDataExample/theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ STATS:
LINE_COLOR: 61, 184, 225
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png


Expand Down
10 changes: 10 additions & 0 deletions res/themes/LandscapeModernDevice35/theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ STATS:
AXIS: True
#AXIS_COLOR: 100, 207, 213
AXIS_COLOR: 255, 255, 50
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
TEMPERATURE:
INTERVAL: 5
Expand Down Expand Up @@ -239,6 +241,8 @@ STATS:
LINE_WIDTH: 1
AXIS: True
AXIS_COLOR: 255, 255, 50
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
TEXT:
SHOW: True
Expand All @@ -265,6 +269,8 @@ STATS:
LINE_WIDTH: 1
AXIS: True
AXIS_COLOR: 255, 255, 50
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
TEXT:
SHOW: True
Expand Down Expand Up @@ -292,6 +298,8 @@ STATS:
LINE_WIDTH: 1
AXIS: True
AXIS_COLOR: 255, 255, 50
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
TEXT:
SHOW: True
Expand Down Expand Up @@ -319,6 +327,8 @@ STATS:
LINE_WIDTH: 1
AXIS: True
AXIS_COLOR: 255, 255, 50
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
BACKGROUND_IMAGE: background.png
TEXT:
SHOW: True
Expand Down
12 changes: 8 additions & 4 deletions res/themes/TaskManager5inch/theme.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ STATS:
AUTOSCALE: False
LINE_COLOR: 0, 64, 128
AXIS: False
AXIS_COLOR: 255, 135, 0
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
TEXT:
Expand All @@ -171,6 +170,8 @@ STATS:
LINE_COLOR: 61, 184, 225
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
TEMPERATURE:
Expand All @@ -187,6 +188,8 @@ STATS:
LINE_COLOR: 61, 184, 225
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FPS:
Expand All @@ -203,6 +206,8 @@ STATS:
LINE_COLOR: 61, 184, 225
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FAN_SPEED:
Expand All @@ -219,6 +224,8 @@ STATS:
LINE_COLOR: 61, 184, 225
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
MEMORY:
Expand All @@ -236,7 +243,6 @@ STATS:
AUTOSCALE: False
LINE_COLOR: 255, 128, 255
AXIS: False
AXIS_COLOR: 255, 135, 0
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
PERCENT_TEXT:
Expand Down Expand Up @@ -272,7 +278,6 @@ STATS:
AUTOSCALE: False
LINE_COLOR: 0, 255, 0
AXIS: False
AXIS_COLOR: 255, 135, 0
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
PERCENT_TEXT:
Expand Down Expand Up @@ -300,7 +305,6 @@ STATS:
AUTOSCALE: True
LINE_COLOR: 128, 0, 0
AXIS: False
AXIS_COLOR: 255, 135, 0
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
TEXT:
Expand Down
36 changes: 36 additions & 0 deletions res/themes/theme_example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FREQUENCY:
Expand Down Expand Up @@ -211,6 +213,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
LOAD:
Expand Down Expand Up @@ -345,6 +349,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FAN_SPEED:
Expand Down Expand Up @@ -417,6 +423,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
GPU:
Expand Down Expand Up @@ -491,6 +499,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
MEMORY_PERCENT:
Expand Down Expand Up @@ -559,6 +569,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
MEMORY_USED:
Expand Down Expand Up @@ -665,6 +677,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FPS:
Expand Down Expand Up @@ -733,6 +747,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FAN_SPEED:
Expand Down Expand Up @@ -801,6 +817,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
FREQUENCY:
Expand Down Expand Up @@ -869,6 +887,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
MEMORY:
Expand Down Expand Up @@ -924,6 +944,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
VIRTUAL:
Expand Down Expand Up @@ -974,6 +996,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
USED:
Expand Down Expand Up @@ -1098,6 +1122,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
TEXT:
Expand Down Expand Up @@ -1209,6 +1235,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
UPLOADED:
Expand Down Expand Up @@ -1261,6 +1289,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
DOWNLOADED:
Expand Down Expand Up @@ -1314,6 +1344,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
UPLOADED:
Expand Down Expand Up @@ -1366,6 +1398,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
DOWNLOADED:
Expand Down Expand Up @@ -1563,6 +1597,8 @@ STATS:
LINE_WIDTH: 2
AXIS: True
AXIS_COLOR: 255, 135, 0
AXIS_FONT: roboto/Roboto-Black.ttf
AXIS_FONT_SIZE: 10
# BACKGROUND_COLOR: 0, 0, 0
BACKGROUND_IMAGE: background.png
TEXT:
Expand Down
Loading