Skip to content

Commit 54bd1f5

Browse files
author
chuazhou
committed
fix dataZoom opts issue.
1 parent 5f83f4f commit 54bd1f5

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

hikyuu/draw/drawplot/echarts_draw.py

+5-12
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
class MultiLineTextChart(ChartBase):
1414
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
1515
super().__init__(init_opts=init_opts)
16-
self._text_data = [] # 存储多行文本数据
1716
self._last_x = 50 # 默认起始 x 坐标
1817
self._last_y = 5 # 默认起始 y 坐标
1918
self._line_height = 20 # 默认行高
@@ -24,13 +23,7 @@ def reset_position(self, x=None, y=None):
2423
if y is not None:
2524
self._last_y = y
2625

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):
3427
"""
3528
添加多行文本
3629
@@ -203,7 +196,7 @@ def kplot_line(kdata: KData):
203196
xaxis_index=[0, 1], # 同时控制k线图和volume图的x轴缩放
204197
type_="slider",
205198
pos_top="85%",
206-
range_start=200 * 100 / len(datetimes),
199+
range_start=(100 - 200 * 100 / len(datetimes)) if len(datetimes) > 200 else 0,
207200
range_end=100,
208201
),
209202
],
@@ -363,7 +356,7 @@ def iplot(indicator, kref: KData = None, chart=None, ilongname=False):
363356
xaxis_index=0,
364357
type_="slider",
365358
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,
367360
range_end=100,
368361
)
369362
],
@@ -572,13 +565,13 @@ def sys_performance(sys, ref_stk=None):
572565

573566
line = iplot(ref_return, ref_k)
574567
line = iplot(funds_return, ref_k, line)
575-
line.set_global_opts(datazoom_opts=[
568+
line.get_options().update(dataZoom=[
576569
opts.DataZoomOpts(
577570
is_show=len(ref_dates) > 500,
578571
xaxis_index=0,
579572
type_="slider",
580573
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,
582575
range_end=100,
583576
),
584577
])

0 commit comments

Comments
 (0)