10000 Fixed advanced demo chart according to https://github.com/lvgl/lv_bin… · mhepp63/lv_binding_micropython@a06c487 · GitHub
[go: up one dir, main page]

Skip to content

Commit a06c487

Browse files
committed
Fixed advanced demo chart according to lvgl#75 (comment)
1 parent ba7c99c commit a06c487

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

examples/advanced_demo.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ def __init__(self, color):
1616
self.set_bg_main_stop(lv.STATE.DEFAULT, 0);
1717
self.set_bg_grad_stop(lv.STATE.DEFAULT, 128);
1818

19+
class ChartPaddingStyle(lv.style_t):
20+
def __init__(self):
21+
super().__init__()
22+
self.set_pad_left(lv.STATE.DEFAULT, 40);
23+
self.set_pad_right(lv.STATE.DEFAULT, 20);
24+
self.set_pad_bottom(lv.STATE.DEFAULT, 50);
25+
self.set_pad_top(lv.STATE.DEFAULT, 20);
26+
1927
class ShadowStyle(lv.style_t):
2028
def __init__(self):
2129
super().__init__()
@@ -164,11 +172,11 @@ def __init__(self, app, page):
164172
self.page = page
165173
self.chart = AnimatedChart(page, 100, 1000)
166174
self.chart.set_width(page.get_width() - 100)
167-
self.chart.align(page, lv.ALIGN.CENTER, 0, 0)
168175
self.series1 = self.chart.add_series(lv.color_hex(0xFF0000))
169176
self.chart.set_type(self.chart.TYPE.LINE)
170177
self.chart.set_style_local_line_width(self.chart.PART.SERIES, lv.STATE.DEFAULT, 3)
171178
self.chart.add_style(self.chart.PART.SERIES, ColorStyle(0x055))
179+
self.chart.add_style(self.chart.PART.BG, ChartPaddingStyle())
172180
self.chart.set_range(0,100)
173181
self.chart.init_points(self.series1, 10)
174182
self.chart.set_points(self.series1, [10,20,30,20,10,40,50,90,95,90])
@@ -177,7 +185,8 @@ def __init__(self, app, page):
177185
self.chart.set_y_tick_texts('1\n2\n3\n4\n5', 2, lv.chart.AXIS.DRAW_LAST_TICK)
178186
self.chart.set_y_tick_length(10, 5)
179187
self.chart.set_div_line_count(3, 3)
180-
self.chart.set_height(self.page.get_height() - 30)
188+
self.chart.set_height(self.page.get_height() - 60)
189+
self.chart.align(page, lv.ALIGN.CENTER, 0, 0)
181190

182191
# Create a slider that controls the chart animation speed
183192

0 commit comments

Comments
 (0)
0