Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
sunhailin-Leo committed Mar 4, 2020
1 parent 8e6c5a1 commit 8896529
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 46 deletions.
17 changes: 5 additions & 12 deletions example/treemap_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,23 @@ def treemap_levels_example():
levels=[
opts.TreeMapLevelsOpts(
treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(
border_color="#555",
border_width=4,
gap_width=4,
border_color="#555", border_width=4, gap_width=4
)
),
opts.TreeMapLevelsOpts(
color_saturation=[0.3, 0.6],
treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(
border_color_saturation=0.7,
gap_width=2,
border_width=2,
border_color_saturation=0.7, gap_width=2, border_width=2
),
),
opts.TreeMapLevelsOpts(
color_saturation=[0.3, 0.5],
treemap_itemstyle_opts=opts.TreeMapItemStyleOpts(
border_color_saturation=0.6,
gap_width=1,
border_color_saturation=0.6, gap_width=1
),
),
opts.TreeMapLevelsOpts(
color_saturation=[0.3, 0.5],
),
]
opts.TreeMapLevelsOpts(color_saturation=[0.3, 0.5]),
],
)
.set_global_opts(title_opts=opts.TitleOpts(title="TreeMap-Levels-配置"))
)
Expand Down
44 changes: 22 additions & 22 deletions pyecharts/charts/basic_charts/sankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ class Sankey(Chart):
"""

def add(
self,
series_name: str,
nodes: types.Sequence,
links: types.Sequence,
*,
is_selected: bool = True,
pos_left: types.Union[str, types.Numeric] = "5%",
pos_top: types.Union[str, types.Numeric] = "5%",
pos_right: types.Union[str, types.Numeric] = "20%",
pos_bottom: types.Union[str, types.Numeric] = "5%",
node_width: types.Numeric = 20,
node_gap: types.Numeric = 8,
node_align: str = "justify",
layout_iterations: types.Numeric = 32,
orient: str = "horizontal",
is_draggable: bool = True,
focus_node_adjacency: types.Union[bool, str] = False,
levels: types.SankeyLevel = None,
label_opts: types.Label = opts.LabelOpts(),
linestyle_opt: types.LineStyle = opts.LineStyleOpts(),
tooltip_opts: types.Tooltip = None,
itemstyle_opts: types.ItemStyle = None,
self,
series_name: str,
nodes: types.Sequence,
links: types.Sequence,
*,
is_selected: bool = True,
pos_left: types.Union[str, types.Numeric] = "5%",
pos_top: types.Union[str, types.Numeric] = "5%",
pos_right: types.Union[str, types.Numeric] = "20%",
pos_bottom: types.Union[str, types.Numeric] = "5%",
node_width: types.Numeric = 20,
node_gap: types.Numeric = 8,
node_align: str = "justify",
layout_iterations: types.Numeric = 32,
orient: str = "horizontal",
is_draggable: bool = True,
focus_node_adjacency: types.Union[bool, str] = False,
levels: types.SankeyLevel = None,
label_opts: types.Label = opts.LabelOpts(),
linestyle_opt: types.LineStyle = opts.LineStyleOpts(),
tooltip_opts: types.Tooltip = None,
itemstyle_opts: types.ItemStyle = None,
):
if layout_iterations < 32:
layout_iterations = 32
Expand Down
8 changes: 5 additions & 3 deletions pyecharts/charts/basic_charts/wordcloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ def _create_mask_image_variable(self, data: str) -> JsCode:
if image_str is None:
raise WordCloudMaskImageException(data=data)
current_chart_id = self.chart_id
self.add_js_funcs(f"""
self.add_js_funcs(
f"""
var maskImage_{current_chart_id} = new Image();
maskImage_{current_chart_id}.src = '{image_str}';
""")
"""
)
return JsCode(f"maskImage_{current_chart_id}")

def _encode_image_to_base64(self, image_or_path: str) -> types.Optional[str]:
Expand Down Expand Up @@ -129,7 +131,7 @@ def add(
"emphasis": {
"shadowBlur": emphasis_shadow_blur,
"shadowColor": emphasis_shadow_color,
}
},
},
}
)
Expand Down
12 changes: 7 additions & 5 deletions pyecharts/charts/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,13 @@ def add_dataset(
dimensions: types.Optional[types.Sequence] = None,
source_header: types.Optional[bool] = None,
):
self.options.update(dataset={
"source": source,
"dimensions": dimensions,
"sourceHeader": source_header,
})
self.options.update(
dataset={
"source": source,
"dimensions": dimensions,
"sourceHeader": source_header,
}
)
return self


Expand Down
5 changes: 1 addition & 4 deletions test/test_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,7 @@
"children": [
{"name": "B"},
{
"children": [
{"children": [{"name": "I"}], "name": "E"},
{"name": "F"},
],
"children": [{"children": [{"name": "I"}], "name": "E"}, {"name": "F"}],
"name": "C",
},
{
Expand Down

0 comments on commit 8896529

Please sign in to comment.