@@ -16,6 +16,14 @@ def __init__(self, color):
16
16
self .set_bg_main_stop (lv .STATE .DEFAULT , 0 );
17
17
self .set_bg_grad_stop (lv .STATE .DEFAULT , 128 );
18
18
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
+
19
27
class ShadowStyle (lv .style_t ):
20
28
def __init__ (self ):
21
29
super ().__init__ ()
@@ -164,11 +172,11 @@ def __init__(self, app, page):
164
172
self .page = page
165
173
self .chart = AnimatedChart (page , 100 , 1000 )
166
174
self .chart .set_width (page .get_width () - 100 )
167
- self .chart .align (page , lv .ALIGN .CENTER , 0 , 0 )
168
175
self .series1 = self .chart .add_series (lv .color_hex (0xFF0000 ))
169
176
self .chart .set_type (self .chart .TYPE .LINE )
170
177
self .chart .set_style_local_line_width (self .chart .PART .SERIES , lv .STATE .DEFAULT , 3 )
171
178
self .chart .add_style (self .chart .PART .SERIES , ColorStyle (0x055 ))
179
+ self .chart .add_style (self .chart .PART .BG , ChartPaddingStyle ())
172
180
self .chart .set_range (0 ,100 )
173
181
self .chart .init_points (self .series1 , 10 )
174
182
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):
177
185
self .chart .set_y_tick_texts ('1\n 2\n 3\n 4\n 5' , 2 , lv .chart .AXIS .DRAW_LAST_TICK )
178
186
self .chart .set_y_tick_length (10 , 5 )
179
187
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 )
181
190
182
191
# Create a slider that controls the chart animation speed
183
192
0 commit comments