From 20610bb024c44dec300ff9c686efad06cc626b40 Mon Sep 17 00:00:00 2001
From: sunhailinLeo <379978424@qq.com>
Date: Mon, 8 Feb 2021 14:58:15 +0800
Subject: [PATCH 001/150] Update some config for echarts V5
---
pyecharts/charts/basic_charts/calendar.py | 5 +++-
pyecharts/charts/basic_charts/gauge.py | 7 +++--
pyecharts/charts/basic_charts/map.py | 2 +-
pyecharts/charts/basic_charts/pie.py | 4 ++-
pyecharts/charts/basic_charts/radar.py | 21 ++++++++++++--
pyecharts/charts/basic_charts/sankey.py | 6 ++--
pyecharts/charts/chart.py | 35 ++++++++++++++++++-----
pyecharts/options/charts_options.py | 12 ++++++--
pyecharts/options/global_options.py | 8 ++++--
pyecharts/options/series_options.py | 2 +-
test/test_sankey.py | 2 --
11 files changed, 79 insertions(+), 25 deletions(-)
diff --git a/pyecharts/charts/basic_charts/calendar.py b/pyecharts/charts/basic_charts/calendar.py
index eff3d7b54..c4b1c97fd 100644
--- a/pyecharts/charts/basic_charts/calendar.py
+++ b/pyecharts/charts/basic_charts/calendar.py
@@ -22,7 +22,10 @@ def add(
yaxis_data: types.Sequence,
*,
is_selected: bool = True,
- label_opts: types.Label = opts.LabelOpts(),
+ label_opts: types.Label = opts.LabelOpts(
+ is_show=False,
+ position="inside",
+ ),
calendar_opts: types.Calendar = None,
tooltip_opts: types.Tooltip = None,
itemstyle_opts: types.ItemStyle = None,
diff --git a/pyecharts/charts/basic_charts/gauge.py b/pyecharts/charts/basic_charts/gauge.py
index ab80597a7..d9d176f8f 100644
--- a/pyecharts/charts/basic_charts/gauge.py
+++ b/pyecharts/charts/basic_charts/gauge.py
@@ -24,9 +24,12 @@ def add(
start_angle: types.Numeric = 225,
end_angle: types.Numeric = -45,
is_clock_wise: bool = True,
- title_label_opts: types.GaugeTitle = opts.GaugeTitleOpts(),
+ title_label_opts: types.GaugeTitle = opts.GaugeTitleOpts(
+ offset_center=["0%", "20%"],
+ ),
detail_label_opts: types.GaugeDetail = opts.GaugeDetailOpts(
- formatter="{value}%"
+ formatter="{value}%",
+ offset_center=["0%", "40%"],
),
pointer: types.GaugePointer = opts.GaugePointerOpts(),
tooltip_opts: types.Tooltip = None,
diff --git a/pyecharts/charts/basic_charts/map.py b/pyecharts/charts/basic_charts/map.py
index 3fa175f68..98b192542 100644
--- a/pyecharts/charts/basic_charts/map.py
+++ b/pyecharts/charts/basic_charts/map.py
@@ -60,7 +60,7 @@ def add(
"name": series_name,
"symbol": symbol,
"label": label_opts,
- "mapType": maptype,
+ "map": maptype,
"data": data,
"roam": is_roam,
"aspectScale": aspect_scale,
diff --git a/pyecharts/charts/basic_charts/pie.py b/pyecharts/charts/basic_charts/pie.py
index e6de03f64..49cfe30fd 100644
--- a/pyecharts/charts/basic_charts/pie.py
+++ b/pyecharts/charts/basic_charts/pie.py
@@ -23,8 +23,9 @@ def add(
center: types.Optional[types.Sequence] = None,
rosetype: types.Optional[str] = None,
is_clockwise: bool = True,
+ start_angle: types.Numeric = 90,
label_opts: types.Label = opts.LabelOpts(),
- label_line_opts: types.PieLabelLine = None,
+ label_line_opts: types.PieLabelLine = opts.PieLabelLineOpts(),
tooltip_opts: types.Tooltip = None,
itemstyle_opts: types.ItemStyle = None,
encode: types.Union[types.JSFunc, dict, None] = None,
@@ -58,6 +59,7 @@ def add(
"type": ChartType.PIE,
"name": series_name,
"clockwise": is_clockwise,
+ "startAngle": start_angle,
"data": data,
"radius": radius,
"center": center,
diff --git a/pyecharts/charts/basic_charts/radar.py b/pyecharts/charts/basic_charts/radar.py
index e687fa1aa..916525e0e 100644
--- a/pyecharts/charts/basic_charts/radar.py
+++ b/pyecharts/charts/basic_charts/radar.py
@@ -36,8 +36,11 @@ def add_schema(
s = s.opts
indicators.append(s)
- self.options.update(
- radar={
+ if self.options.get("radar") is None:
+ self.options.update(radar=[])
+
+ self.options.get("radar").append(
+ {
"indicator": indicators,
"shape": shape,
"center": center,
@@ -48,6 +51,18 @@ def add_schema(
"axisLine": axisline_opt,
}
)
+ # self.options.update(
+ # radar={
+ # "indicator": indicators,
+ # "shape": shape,
+ # "center": center,
+ # "radius": radius,
+ # "name": {"textStyle": textstyle_opts},
+ # "splitLine": splitline_opt,
+ # "splitArea": splitarea_opt,
+ # "axisLine": axisline_opt,
+ # }
+ # )
return self
def add(
@@ -59,6 +74,7 @@ def add(
symbol: types.Optional[str] = None,
color: types.Optional[str] = None,
label_opts: opts.LabelOpts = opts.LabelOpts(),
+ radar_index: types.Numeric = None,
linestyle_opts: opts.LineStyleOpts = opts.LineStyleOpts(),
areastyle_opts: opts.AreaStyleOpts = opts.AreaStyleOpts(),
tooltip_opts: types.Tooltip = None,
@@ -75,6 +91,7 @@ def add(
"data": data,
"symbol": symbol,
"label": label_opts,
+ "radarIndex": radar_index,
"itemStyle": {"normal": {"color": color}},
"lineStyle": linestyle_opts,
"areaStyle": areastyle_opts,
diff --git a/pyecharts/charts/basic_charts/sankey.py b/pyecharts/charts/basic_charts/sankey.py
index 03edf80ea..efff4f859 100644
--- a/pyecharts/charts/basic_charts/sankey.py
+++ b/pyecharts/charts/basic_charts/sankey.py
@@ -30,7 +30,7 @@ def add(
layout_iterations: types.Numeric = 32,
orient: str = "horizontal",
is_draggable: bool = True,
- focus_node_adjacency: types.Union[bool, str] = False,
+ focus_node_mode: str = 'none',
levels: types.SankeyLevel = None,
label_opts: types.Label = opts.LabelOpts(),
linestyle_opt: types.LineStyle = opts.LineStyleOpts(),
@@ -57,7 +57,9 @@ def add(
"layoutIteration": layout_iterations,
"orient": orient,
"draggable": is_draggable,
- "focusNodeAdjacency": focus_node_adjacency,
+ "emphasis": {
+ "focus": focus_node_mode,
+ },
"levels": levels,
"label": label_opts,
"lineStyle": linestyle_opt,
diff --git a/pyecharts/charts/chart.py b/pyecharts/charts/chart.py
index fb156a677..185d72507 100644
--- a/pyecharts/charts/chart.py
+++ b/pyecharts/charts/chart.py
@@ -12,10 +12,10 @@ def __init__(self, init_opts: types.Init = opts.InitOpts()):
temp_opts.update(**init_opts)
init_opts = temp_opts
super().__init__(init_opts=init_opts)
+ # Change to Echarts V5 default color list
self.colors = (
- "#c23531 #2f4554 #61a0a8 #d48265 #749f83 #ca8622 #bda29a #6e7074 "
- "#546570 #c4ccd3 #f05b72 #ef5b9c #f47920 #905a3d #fab27b #2a5caa "
- "#444693 #726930 #b2d235 #6d8346 #ac6767 #1d953f #6950a1 #918597"
+ "#5470c6 #91cc75 #fac858 #ee6666 #73c0de #3ba272 #fc8452 #9a60b4 "
+ "#ea7ccc"
).split()
if init_opts.opts.get("theme") == ThemeType.WHITE:
self.options.update(color=self.colors)
@@ -26,6 +26,25 @@ def __init__(self, init_opts: types.Init = opts.InitOpts()):
)
self._chart_type: Optional[str] = None
+ def set_dark_mode(
+ self,
+ dark_mode_colors: Optional[Sequence[str]] = None,
+ dark_mode_bg_color: str = "#100C2A"
+ ):
+ # [Hard Code Here] The Echarts default Dark Mode Configurations
+ if dark_mode_colors is None:
+ dark_mode_colors = (
+ "#4992ff #7cffb2 #fddd60 #ff6e76 #58d9f9 #05c091 #ff8a45 "
+ "#8d48e3 #dd79ff"
+ ).split()
+ self.options.update(
+ backgroundColor=dark_mode_bg_color,
+ darkMode=True,
+ color=dark_mode_colors,
+ )
+ self.theme = ThemeType.DARK
+ return self
+
def set_colors(self, colors: Sequence[str]):
self.options.update(color=colors)
return self
@@ -86,7 +105,8 @@ def set_series_opts(
def _append_legend(self, name, is_selected):
self.options.get("legend")[0].get("data").append(name)
- self.options.get("legend")[0].get("selected").update({name: is_selected})
+ if self.options.get("legend")[0].get("selected") is not None:
+ self.options.get("legend")[0].get("selected").update({name: is_selected})
def _append_color(self, color: Optional[str]):
if color:
@@ -194,9 +214,10 @@ def overlap(self, chart: Base):
self.options.get("legend")[0].get("data").extend(
chart.options.get("legend")[0].get("data")
)
- self.options.get("legend")[0].get("selected").update(
- chart.options.get("legend")[0].get("selected")
- )
+ if self.options.get("legend")[0].get("selected") is not None:
+ self.options.get("legend")[0].get("selected").update(
+ chart.options.get("legend")[0].get("selected")
+ )
self.options.get("series").extend(chart.options.get("series"))
return self
diff --git a/pyecharts/options/charts_options.py b/pyecharts/options/charts_options.py
index cae6d369a..638f91b0f 100644
--- a/pyecharts/options/charts_options.py
+++ b/pyecharts/options/charts_options.py
@@ -1145,7 +1145,7 @@ def __init__(
border_color: str = "transparent",
offset_center: Sequence = None,
formatter: Optional[JSFunc] = None,
- color: str = "auto",
+ color: str = "#464646",
font_style: str = "normal",
font_weight: str = "normal",
font_family: str = "sans-serif",
@@ -1194,17 +1194,23 @@ class PieLabelLineOpts(BasicOpts):
def __init__(
self,
is_show: bool = True,
- length: Numeric = None,
- length_2: Numeric = None,
+ is_show_above: bool = False,
+ length: Numeric = 15,
+ length_2: Numeric = 15,
smooth: Union[bool, Numeric] = False,
+ min_turn_angle: Numeric = 90,
linestyle_opts: Union[LineStyleOpts, dict, None] = None,
+ max_surface_angle: Numeric = 90,
):
self.opts: dict = {
"show": is_show,
+ "showAbove": is_show_above,
"length": length,
"length2": length_2,
"smooth": smooth,
+ "minTurnAngle": min_turn_angle,
"lineStyle": linestyle_opts,
+ "maxSurfaceAngle": max_surface_angle,
}
diff --git a/pyecharts/options/global_options.py b/pyecharts/options/global_options.py
index 0cf8015f8..699796bbc 100644
--- a/pyecharts/options/global_options.py
+++ b/pyecharts/options/global_options.py
@@ -337,10 +337,10 @@ def __init__(
self,
title: Optional[str] = None,
title_link: Optional[str] = None,
- title_target: Optional[str] = None,
+ title_target: Optional[str] = "blank",
subtitle: Optional[str] = None,
subtitle_link: Optional[str] = None,
- subtitle_target: Optional[str] = None,
+ subtitle_target: Optional[str] = "blank",
pos_left: Optional[str] = None,
pos_right: Optional[str] = None,
pos_top: Optional[str] = None,
@@ -415,6 +415,7 @@ def __init__(
self,
type_: Optional[str] = None,
selected_mode: Union[str, bool, None] = None,
+ selected_map: Optional[dict] = None,
is_show: bool = True,
pos_left: Union[str, Numeric, None] = None,
pos_right: Union[str, Numeric, None] = None,
@@ -433,6 +434,7 @@ def __init__(
self.opts: dict = {
"type": type_,
"selectedMode": selected_mode,
+ "selected": selected_map,
"show": is_show,
"left": pos_left,
"right": pos_right,
@@ -649,7 +651,7 @@ def __init__(
axispointer_opts: Union[AxisPointerOpts, dict, None] = None,
name_textstyle_opts: Union[TextStyleOpts, dict, None] = None,
splitarea_opts: Union[SplitAreaOpts, dict, None] = None,
- splitline_opts: Union[SplitLineOpts, dict] = SplitLineOpts(),
+ splitline_opts: Union[SplitLineOpts, dict] = SplitLineOpts(is_show=True),
minor_tick_opts: Union[MinorTickOpts, dict, None] = None,
minor_split_line_opts: Union[MinorSplitLineOpts, dict, None] = None,
):
diff --git a/pyecharts/options/series_options.py b/pyecharts/options/series_options.py
index b6c5b6e5c..a57c368a2 100644
--- a/pyecharts/options/series_options.py
+++ b/pyecharts/options/series_options.py
@@ -351,7 +351,7 @@ def __init__(
class AreaStyleOpts(BasicOpts):
- def __init__(self, opacity: Optional[Numeric] = 0, color: Optional[str] = None):
+ def __init__(self, opacity: Optional[Numeric] = 0, color: Optional[JSFunc] = None):
self.opts: dict = {"opacity": opacity, "color": color}
diff --git a/test/test_sankey.py b/test/test_sankey.py
index a5dabb8ba..90a1c92fb 100644
--- a/test/test_sankey.py
+++ b/test/test_sankey.py
@@ -50,7 +50,6 @@ def test_sankey_new_opts(fake_writer):
nodes,
links,
pos_bottom="10%",
- focus_node_adjacency="allEdges",
orient="vertical",
levels=[
opts.SankeyLevelsOpts(
@@ -67,4 +66,3 @@ def test_sankey_new_opts(fake_writer):
assert_in("bottom", content)
assert_in("orient", content)
assert_in("levels", content)
- assert_in("focusNodeAdjacency", content)
From dc38504df9970a22725f4f67b4e0c5f9a7ed699c Mon Sep 17 00:00:00 2001
From: sunhailinLeo <379978424@qq.com>
Date: Mon, 8 Feb 2021 15:14:06 +0800
Subject: [PATCH 002/150] fix toolbox bug
---
pyecharts/options/global_options.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/pyecharts/options/global_options.py b/pyecharts/options/global_options.py
index 699796bbc..7150ddb37 100644
--- a/pyecharts/options/global_options.py
+++ b/pyecharts/options/global_options.py
@@ -145,8 +145,8 @@ def __init__(
back_title: str = "区域缩放还原",
zoom_icon: Optional[JSFunc] = None,
back_icon: Optional[JSFunc] = None,
- xaxis_index: Union[Numeric, Sequence, bool] = False,
- yaxis_index: Union[Numeric, Sequence, bool] = False,
+ xaxis_index: Union[Numeric, Sequence, bool] = None,
+ yaxis_index: Union[Numeric, Sequence, bool] = None,
filter_mode: str = "filter",
):
self.opts: dict = {
@@ -248,7 +248,7 @@ def __init__(
magic_type: Union[
ToolBoxFeatureMagicTypeOpts, dict
] = ToolBoxFeatureMagicTypeOpts(),
- brush: Union[ToolBoxFeatureBrushOpts, dict] = ToolBoxFeatureBrushOpts(),
+ brush: Union[ToolBoxFeatureBrushOpts, dict] = None,
):
self.opts: dict = {
"saveAsImage": save_as_image,
From 93a27d22c320e018a7eb0484fab81cc4e6ed36ef Mon Sep 17 00:00:00 2001
From: "Zhongxiang.Wang"
-
-
-
-
-
+
+
From d085837000d620793d4482f0d33d9f6d961c3524 Mon Sep 17 00:00:00 2001
From: dongdong
-
- }1thUS9-h!_(i8g_F(nx7pDiHuhJ#;1^_3i4TtC)pn iW3mJ+j)=>b@`j7?ESD-*lUO5CZUoDycy_Qd
z^j1bbcB;$IpzPIta)3(6-~$gi@iI%mYk=FJI*ib#mjQYnq) SD8U15VOW^#j)R$tl`
zNV&XGt0Qc-0d3=Mf7IoRxC0??BofSIQY1-KIicI`-oUj-YHnd_j}l`tL*zvcrqxG)
zfgQm-4@oaWSM0&$&reMK)XYat0l2n&*PLlv(rs^P5GKZ%${dq7a_6Bv+E-iG1V71<
z<1{hOR_0}COVn=h`YqPDquTovw~A6ze`)B+_uh%s2M$U(P2tBW%uwWvW#L7F_}&Y6
zjeluRer`{EW=(uzj{S!z@}K7TCpN%q?o$hR*vwzu<>yiUEL}ZKpd{HpI7+{I$)l)n
zl|wtn97G@O$0(@aZNU_OX-xvJzjX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