13
13
class MultiLineTextChart (ChartBase ):
14
14
def __init__ (self , init_opts : opts .InitOpts = opts .InitOpts ()):
15
15
super ().__init__ (init_opts = init_opts )
16
- self ._text_data = [] # 存储多行文本数据
17
16
self ._last_x = 50 # 默认起始 x 坐标
18
17
self ._last_y = 5 # 默认起始 y 坐标
19
18
self ._line_height = 20 # 默认行高
@@ -24,13 +23,7 @@ def reset_position(self, x=None, y=None):
24
23
if y is not None :
25
24
self ._last_y = y
26
25
27
- def add (
28
- self ,
29
- text : str ,
30
- x = None ,
31
- y = None ,
32
- text_style = None ,
33
- ):
26
+ def add (self , text : str , x = None , y = None , text_style = None ):
34
27
"""
35
28
添加多行文本
36
29
@@ -203,7 +196,7 @@ def kplot_line(kdata: KData):
203
196
xaxis_index = [0 , 1 ], # 同时控制k线图和volume图的x轴缩放
204
197
type_ = "slider" ,
205
198
pos_top = "85%" ,
206
- range_start = 200 * 100 / len (datetimes ),
199
+ range_start = ( 100 - 200 * 100 / len (datetimes )) if len ( datetimes ) > 200 else 0 ,
207
200
range_end = 100 ,
208
201
),
209
202
],
@@ -363,7 +356,7 @@ def iplot(indicator, kref: KData = None, chart=None, ilongname=False):
363
356
xaxis_index = 0 ,
364
357
type_ = "slider" ,
365
358
pos_top = "92%" ,
366
- range_start = 200 * 100 / len (datetimes ) if len (datetimes ) > 200 else 0 ,
359
+ range_start = ( 100 - 200 * 100 / len (datetimes ) ) if len (datetimes ) > 200 else 0 ,
367
360
range_end = 100 ,
368
361
)
369
362
],
@@ -572,13 +565,13 @@ def sys_performance(sys, ref_stk=None):
572
565
573
566
line = iplot (ref_return , ref_k )
574
567
line = iplot (funds_return , ref_k , line )
575
- line .set_global_opts ( datazoom_opts = [
568
+ line .get_options (). update ( dataZoom = [
576
569
opts .DataZoomOpts (
577
570
is_show = len (ref_dates ) > 500 ,
578
571
xaxis_index = 0 ,
579
572
type_ = "slider" ,
580
573
pos_top = "92%" ,
581
- range_start = 500 * 100 / len (ref_dates ) if len (ref_dates ) > 500 else 0 ,
574
+ range_start = ( 100 - 500 * 100 / len (ref_dates ) ) if len (ref_dates ) > 500 else 0 ,
582
575
range_end = 100 ,
583
576
),
584
577
])
0 commit comments