Skip to content

Commit 4f0d915

Browse files
committed
Add LineGraph new properties: axis legend font and font size
1 parent a0413a3 commit 4f0d915

File tree

7 files changed

+74
-8
lines changed

7 files changed

+74
-8
lines changed

library/lcd/lcd_comm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,8 +354,8 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
354354
line_width: int = 2,
355355
graph_axis: bool = True,
356356
axis_color: Tuple[int, int, int] = (0, 0, 0),
357-
font: str = "./res/fonts/roboto/Roboto-Black.ttf",
358-
font_size: int = 10,
357+
axis_font: str = "./res/fonts/roboto/Roboto-Black.ttf",
358+
axis_font_size: int = 10,
359359
background_color: Tuple[int, int, int] = (255, 255, 255),
360360
background_image: str = None):
361361
# Generate a plot graph and display it
@@ -434,13 +434,13 @@ def DisplayLineGraph(self, x: int, y: int, width: int, height: int,
434434
# Draw Legend
435435
draw.line([0, 0, 1, 0], fill=axis_color)
436436
text = f"{int(max_value)}"
437-
ttfont = ImageFont.truetype(font, font_size)
437+
ttfont = ImageFont.truetype(axis_font, axis_font_size)
438438
left, top, right, bottom = ttfont.getbbox(text)
439439
draw.text((2, 0 - top), text,
440440
font=ttfont, fill=axis_color)
441441

442442
text = f"{int(min_value)}"
443-
ttfont = ImageFont.truetype(font, font_size)
443+
ttfont = ImageFont.truetype(axis_font, axis_font_size)
444444
left, top, right, bottom = ttfont.getbbox(text)
445445
draw.text((width - 1 - right, height - 2 - bottom), text,
446446
font=ttfont, fill=axis_color)

library/stats.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ def display_themed_line_graph(theme_data, values):
234234
line_width=theme_data.get("LINE_WIDTH", 2),
235235
graph_axis=theme_data.get("AXIS", False),
236236
axis_color=theme_data.get("AXIS_COLOR", line_color), # If no color specified, use line color for axis
237+
axis_font=config.FONTS_DIR + theme_data.get("AXIS_FONT", "roboto/Roboto-Black.ttf"),
238+
axis_font_size=theme_data.get("AXIS_FONT_SIZE", 10),
237239
background_color=theme_data.get("BACKGROUND_COLOR", (0, 0, 0)),
238240
background_image=get_theme_file_path(theme_data.get("BACKGROUND_IMAGE", None))
239241
)

res/themes/ColoredFlat/theme.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ STATS:
6161
LINE_COLOR: 247, 227, 227
6262
AXIS: true
6363
AXIS_COLOR: 247, 227, 227
64+
AXIS_FONT: roboto/Roboto-Black.ttf
65+
AXIS_FONT_SIZE: 10
6466
BACKGROUND_IMAGE: background.png
6567
FREQUENCY:
6668
INTERVAL: 1
@@ -152,6 +154,8 @@ STATS:
152154
LINE_COLOR: 247, 227, 227
153155
AXIS: True
154156
AXIS_COLOR: 247, 227, 227
157+
AXIS_FONT: roboto/Roboto-Black.ttf
158+
AXIS_FONT_SIZE: 10
155159
BACKGROUND_IMAGE: background.png
156160
MEMORY:
157161
GRAPH:
@@ -263,6 +267,8 @@ STATS:
263267
LINE_COLOR: 247, 227, 227
264268
AXIS: true
265269
AXIS_COLOR: 247, 227, 227
270+
AXIS_FONT: roboto/Roboto-Black.ttf
271+
AXIS_FONT_SIZE: 10
266272
BACKGROUND_IMAGE: background.png
267273
USED:
268274
SHOW: True
@@ -425,6 +431,8 @@ STATS:
425431
LINE_COLOR: 247, 227, 227
426432
AXIS: True
427433
AXIS_COLOR: 247, 227, 227
434+
AXIS_FONT: roboto/Roboto-Black.ttf
435+
AXIS_FONT_SIZE: 10
428436
BACKGROUND_IMAGE: background.png
429437
UPLOADED:
430438
TEXT:
@@ -457,6 +465,8 @@ STATS:
457465
LINE_COLOR: 247, 227, 227
458466
AXIS: True
459467
AXIS_COLOR: 247, 227, 227
468+
AXIS_FONT: roboto/Roboto-Black.ttf
469+
AXIS_FONT_SIZE: 10
460470
BACKGROUND_IMAGE: background.png
461471
DOWNLOADED:
462472
TEXT:
@@ -564,4 +574,6 @@ STATS:
564574
LINE_COLOR: 247, 227, 227
565575
AXIS: True
566576
AXIS_COLOR: 247, 227, 227
577+
AXIS_FONT: roboto/Roboto-Black.ttf
578+
AXIS_FONT_SIZE: 10
567579
BACKGROUND_IMAGE: background.png

res/themes/CustomDataExample/theme.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ STATS:
9898
LINE_COLOR: 61, 184, 225
9999
AXIS: True
100100
AXIS_COLOR: 255, 135, 0
101+
AXIS_FONT: roboto/Roboto-Black.ttf
102+
AXIS_FONT_SIZE: 10
101103
BACKGROUND_IMAGE: background.png
102104

103105

res/themes/LandscapeModernDevice35/theme.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ STATS:
5353
AXIS: True
5454
#AXIS_COLOR: 100, 207, 213
5555
AXIS_COLOR: 255, 255, 50
56+
AXIS_FONT: roboto/Roboto-Black.ttf
57+
AXIS_FONT_SIZE: 10
5658
BACKGROUND_IMAGE: background.png
5759
TEMPERATURE:
5860
INTERVAL: 5
@@ -239,6 +241,8 @@ STATS:
239241
LINE_WIDTH: 1
240242
AXIS: True
241243
AXIS_COLOR: 255, 255, 50
244+
AXIS_FONT: roboto/Roboto-Black.ttf
245+
AXIS_FONT_SIZE: 10
242246
BACKGROUND_IMAGE: background.png
243247
TEXT:
244248
SHOW: True
@@ -265,6 +269,8 @@ STATS:
265269
LINE_WIDTH: 1
266270
AXIS: True
267271
AXIS_COLOR: 255, 255, 50
272+
AXIS_FONT: roboto/Roboto-Black.ttf
273+
AXIS_FONT_SIZE: 10
268274
BACKGROUND_IMAGE: background.png
269275
TEXT:
270276
SHOW: True
@@ -292,6 +298,8 @@ STATS:
292298
LINE_WIDTH: 1
293299
AXIS: True
294300
AXIS_COLOR: 255, 255, 50
301+
AXIS_FONT: roboto/Roboto-Black.ttf
302+
AXIS_FONT_SIZE: 10
295303
BACKGROUND_IMAGE: background.png
296304
TEXT:
297305
SHOW: True
@@ -319,6 +327,8 @@ STATS:
319327
LINE_WIDTH: 1
320328
AXIS: True
321329
AXIS_COLOR: 255, 255, 50
330+
AXIS_FONT: roboto/Roboto-Black.ttf
331+
AXIS_FONT_SIZE: 10
322332
BACKGROUND_IMAGE: background.png
323333
TEXT:
324334
SHOW: True

res/themes/TaskManager5inch/theme.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ STATS:
145145
AUTOSCALE: False
146146
LINE_COLOR: 0, 64, 128
147147
AXIS: False
148-
AXIS_COLOR: 255, 135, 0
149148
# BACKGROUND_COLOR: 0, 0, 0
150149
BACKGROUND_IMAGE: background.png
151150
TEXT:
@@ -171,6 +170,8 @@ STATS:
171170
LINE_COLOR: 61, 184, 225
172171
AXIS: True
173172
AXIS_COLOR: 255, 135, 0
173+
AXIS_FONT: roboto/Roboto-Black.ttf
174+
AXIS_FONT_SIZE: 10
174175
# BACKGROUND_COLOR: 0, 0, 0
175176
BACKGROUND_IMAGE: background.png
176177
TEMPERATURE:
@@ -187,6 +188,8 @@ STATS:
187188
LINE_COLOR: 61, 184, 225
188189
AXIS: True
189190
AXIS_COLOR: 255, 135, 0
191+
AXIS_FONT: roboto/Roboto-Black.ttf
192+
AXIS_FONT_SIZE: 10
190193
# BACKGROUND_COLOR: 0, 0, 0
191194
BACKGROUND_IMAGE: background.png
192195
FPS:
@@ -203,6 +206,8 @@ STATS:
203206
LINE_COLOR: 61, 184, 225
204207
AXIS: True
205208
AXIS_COLOR: 255, 135, 0
209+
AXIS_FONT: roboto/Roboto-Black.ttf
210+
AXIS_FONT_SIZE: 10
206211
# BACKGROUND_COLOR: 0, 0, 0
207212
BACKGROUND_IMAGE: background.png
208213
FAN_SPEED:
@@ -219,6 +224,8 @@ STATS:
219224
LINE_COLOR: 61, 184, 225
220225
AXIS: True
221226
AXIS_COLOR: 255, 135, 0
227+
AXIS_FONT: roboto/Roboto-Black.ttf
228+
AXIS_FONT_SIZE: 10
222229
# BACKGROUND_COLOR: 0, 0, 0
223230
BACKGROUND_IMAGE: background.png
224231
MEMORY:
@@ -236,7 +243,6 @@ STATS:
236243
AUTOSCALE: False
237244
LINE_COLOR: 255, 128, 255
238245
AXIS: False
239-
AXIS_COLOR: 255, 135, 0
240246
# BACKGROUND_COLOR: 0, 0, 0
241247
BACKGROUND_IMAGE: background.png
242248
PERCENT_TEXT:
@@ -272,7 +278,6 @@ STATS:
272278
AUTOSCALE: False
273279
LINE_COLOR: 0, 255, 0
274280
AXIS: False
275-
AXIS_COLOR: 255, 135, 0
276281
# BACKGROUND_COLOR: 0, 0, 0
277282
BACKGROUND_IMAGE: background.png
278283
PERCENT_TEXT:
@@ -300,7 +305,6 @@ STATS:
300305
AUTOSCALE: True
301306
LINE_COLOR: 128, 0, 0
302307
AXIS: False
303-
AXIS_COLOR: 255, 135, 0
304308
# BACKGROUND_COLOR: 0, 0, 0
305309
BACKGROUND_IMAGE: background.png
306310
TEXT:

res/themes/theme_example.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ STATS:
139139
LINE_WIDTH: 2
140140
AXIS: True
141141
AXIS_COLOR: 255, 135, 0
142+
AXIS_FONT: roboto/Roboto-Black.ttf
143+
AXIS_FONT_SIZE: 10
142144
# BACKGROUND_COLOR: 0, 0, 0
143145
BACKGROUND_IMAGE: background.png
144146
FREQUENCY:
@@ -211,6 +213,8 @@ STATS:
211213
LINE_WIDTH: 2
212214
AXIS: True
213215
AXIS_COLOR: 255, 135, 0
216+
AXIS_FONT: roboto/Roboto-Black.ttf
217+
AXIS_FONT_SIZE: 10
214218
# BACKGROUND_COLOR: 0, 0, 0
215219
BACKGROUND_IMAGE: background.png
216220
LOAD:
@@ -345,6 +349,8 @@ STATS:
345349
LINE_WIDTH: 2
346350
AXIS: True
347351
AXIS_COLOR: 255, 135, 0
352+
AXIS_FONT: roboto/Roboto-Black.ttf
353+
AXIS_FONT_SIZE: 10
348354
# BACKGROUND_COLOR: 0, 0, 0
349355
BACKGROUND_IMAGE: background.png
350356
FAN_SPEED:
@@ -417,6 +423,8 @@ STATS:
417423
LINE_WIDTH: 2
418424
AXIS: True
419425
AXIS_COLOR: 255, 135, 0
426+
AXIS_FONT: roboto/Roboto-Black.ttf
427+
AXIS_FONT_SIZE: 10
420428
# BACKGROUND_COLOR: 0, 0, 0
421429
BACKGROUND_IMAGE: background.png
422430
GPU:
@@ -491,6 +499,8 @@ STATS:
491499
LINE_WIDTH: 2
492500
AXIS: True
493501
AXIS_COLOR: 255, 135, 0
502+
AXIS_FONT: roboto/Roboto-Black.ttf
503+
AXIS_FONT_SIZE: 10
494504
# BACKGROUND_COLOR: 0, 0, 0
495505
BACKGROUND_IMAGE: background.png
496506
MEMORY_PERCENT:
@@ -559,6 +569,8 @@ STATS:
559569
LINE_WIDTH: 2
560570
AXIS: True
561571
AXIS_COLOR: 255, 135, 0
572+
AXIS_FONT: roboto/Roboto-Black.ttf
573+
AXIS_FONT_SIZE: 10
562574
# BACKGROUND_COLOR: 0, 0, 0
563575
BACKGROUND_IMAGE: background.png
564576
MEMORY_USED:
@@ -665,6 +677,8 @@ STATS:
665677
LINE_WIDTH: 2
666678
AXIS: True
667679
AXIS_COLOR: 255, 135, 0
680+
AXIS_FONT: roboto/Roboto-Black.ttf
681+
AXIS_FONT_SIZE: 10
668682
# BACKGROUND_COLOR: 0, 0, 0
669683
BACKGROUND_IMAGE: background.png
670684
FPS:
@@ -733,6 +747,8 @@ STATS:
733747
LINE_WIDTH: 2
734748
AXIS: True
735749
AXIS_COLOR: 255, 135, 0
750+
AXIS_FONT: roboto/Roboto-Black.ttf
751+
AXIS_FONT_SIZE: 10
736752
# BACKGROUND_COLOR: 0, 0, 0
737753
BACKGROUND_IMAGE: background.png
738754
FAN_SPEED:
@@ -801,6 +817,8 @@ STATS:
801817
LINE_WIDTH: 2
802818
AXIS: True
803819
AXIS_COLOR: 255, 135, 0
820+
AXIS_FONT: roboto/Roboto-Black.ttf
821+
AXIS_FONT_SIZE: 10
804822
# BACKGROUND_COLOR: 0, 0, 0
805823
BACKGROUND_IMAGE: background.png
806824
FREQUENCY:
@@ -869,6 +887,8 @@ STATS:
869887
LINE_WIDTH: 2
870888
AXIS: True
871889
AXIS_COLOR: 255, 135, 0
890+
AXIS_FONT: roboto/Roboto-Black.ttf
891+
AXIS_FONT_SIZE: 10
872892
# BACKGROUND_COLOR: 0, 0, 0
873893
BACKGROUND_IMAGE: background.png
874894
MEMORY:
@@ -924,6 +944,8 @@ STATS:
924944
LINE_WIDTH: 2
925945
AXIS: True
926946
AXIS_COLOR: 255, 135, 0
947+
AXIS_FONT: roboto/Roboto-Black.ttf
948+
AXIS_FONT_SIZE: 10
927949
# BACKGROUND_COLOR: 0, 0, 0
928950
BACKGROUND_IMAGE: background.png
929951
VIRTUAL:
@@ -974,6 +996,8 @@ STATS:
974996
LINE_WIDTH: 2
975997
AXIS: True
976998
AXIS_COLOR: 255, 135, 0
999+
AXIS_FONT: roboto/Roboto-Black.ttf
1000+
AXIS_FONT_SIZE: 10
9771001
# BACKGROUND_COLOR: 0, 0, 0
9781002
BACKGROUND_IMAGE: background.png
9791003
USED:
@@ -1098,6 +1122,8 @@ STATS:
10981122
LINE_WIDTH: 2
10991123
AXIS: True
11001124
AXIS_COLOR: 255, 135, 0
1125+
AXIS_FONT: roboto/Roboto-Black.ttf
1126+
AXIS_FONT_SIZE: 10
11011127
# BACKGROUND_COLOR: 0, 0, 0
11021128
BACKGROUND_IMAGE: background.png
11031129
TEXT:
@@ -1209,6 +1235,8 @@ STATS:
12091235
LINE_WIDTH: 2
12101236
AXIS: True
12111237
AXIS_COLOR: 255, 135, 0
1238+
AXIS_FONT: roboto/Roboto-Black.ttf
1239+
AXIS_FONT_SIZE: 10
12121240
# BACKGROUND_COLOR: 0, 0, 0
12131241
BACKGROUND_IMAGE: background.png
12141242
UPLOADED:
@@ -1261,6 +1289,8 @@ STATS:
12611289
LINE_WIDTH: 2
12621290
AXIS: True
12631291
AXIS_COLOR: 255, 135, 0
1292+
AXIS_FONT: roboto/Roboto-Black.ttf
1293+
AXIS_FONT_SIZE: 10
12641294
# BACKGROUND_COLOR: 0, 0, 0
12651295
BACKGROUND_IMAGE: background.png
12661296
DOWNLOADED:
@@ -1314,6 +1344,8 @@ STATS:
13141344
LINE_WIDTH: 2
13151345
AXIS: True
13161346
AXIS_COLOR: 255, 135, 0
1347+
AXIS_FONT: roboto/Roboto-Black.ttf
1348+
AXIS_FONT_SIZE: 10
13171349
# BACKGROUND_COLOR: 0, 0, 0
13181350
BACKGROUND_IMAGE: background.png
13191351
UPLOADED:
@@ -1366,6 +1398,8 @@ STATS:
13661398
LINE_WIDTH: 2
13671399
AXIS: True
13681400
AXIS_COLOR: 255, 135, 0
1401+
AXIS_FONT: roboto/Roboto-Black.ttf
1402+
AXIS_FONT_SIZE: 10
13691403
# BACKGROUND_COLOR: 0, 0, 0
13701404
BACKGROUND_IMAGE: background.png
13711405
DOWNLOADED:
@@ -1563,6 +1597,8 @@ STATS:
15631597
LINE_WIDTH: 2
15641598
AXIS: True
15651599
AXIS_COLOR: 255, 135, 0
1600+
AXIS_FONT: roboto/Roboto-Black.ttf
1601+
AXIS_FONT_SIZE: 10
15661602
# BACKGROUND_COLOR: 0, 0, 0
15671603
BACKGROUND_IMAGE: background.png
15681604
TEXT:

0 commit comments

Comments
 (0)