Skip to content

Commit c8ced7f

Browse files
committed
Added min/max formatter to DisplayLineGraph(), useful for CPU load where min/max can be usually within 0 to 1.
1 parent 25acaab commit c8ced7f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

library/lcd/lcd_comm.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
380380
axis_font: str = "./res/fonts/roboto/Roboto-Black.ttf",
381381
axis_font_size: int = 10,
382382
background_color: Color = (255, 255, 255),
383-
background_image: Optional[str] = None):
383+
background_image: Optional[str] = None,
384+
axis_minmax_format: str = "{:0.0f}"):
384385
# Generate a plot graph and display it
385386
# Provide the background image path to display plot graph with transparent background
386387

@@ -451,13 +452,13 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
451452

452453
# Draw Legend
453454
draw.line([0, 0, 1, 0], fill=axis_color)
454-
text = f"{int(max_value)}"
455+
text = axis_minmax_format.format(max_value)
455456
ttfont = self.open_font(axis_font, axis_font_size)
456457
_, top, right, bottom = ttfont.getbbox(text)
457458
draw.text((2, 0 - top), text,
458459
font=ttfont, fill=axis_color)
459460

460-
text = f"{int(min_value)}"
461+
text = axis_minmax_format.format(min_value)
461462
_, top, right, bottom = ttfont.getbbox(text)
462463
draw.text((width - 1 - right, height - 2 - bottom), text,
463464
font=ttfont, fill=axis_color)

0 commit comments

Comments
 (0)