mirror of
https://github.com/pyecharts/pyecharts.git
synced 2026-01-25 17:06:27 +00:00
Update: 为图表新增 ItemStyle 配置项
This commit is contained in:
parent
4af76aeba4
commit
f41c11495f
@ -96,6 +96,36 @@ def kline_datazoom_slider() -> Kline:
|
||||
return c
|
||||
|
||||
|
||||
@C.funcs
|
||||
def kline_itemstyle() -> Kline:
|
||||
c = (
|
||||
Kline()
|
||||
.add_xaxis(["2017/7/{}".format(i + 1) for i in range(31)])
|
||||
.add_yaxis(
|
||||
"kline",
|
||||
data,
|
||||
itemstyle_opts=opts.ItemStyleOpts(
|
||||
color="#ec0000",
|
||||
color0="#00da3c",
|
||||
border_color="#8A0000",
|
||||
border_color0="#008F28",
|
||||
),
|
||||
)
|
||||
.set_global_opts(
|
||||
xaxis_opts=opts.AxisOpts(is_scale=True),
|
||||
yaxis_opts=opts.AxisOpts(
|
||||
is_scale=True,
|
||||
splitarea_opts=opts.SplitAreaOpts(
|
||||
is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)
|
||||
),
|
||||
),
|
||||
datazoom_opts=[opts.DataZoomOpts(type_="inside")],
|
||||
title_opts=opts.TitleOpts(title="Kline-ItemStyle"),
|
||||
)
|
||||
)
|
||||
return c
|
||||
|
||||
|
||||
@C.funcs
|
||||
def kline_datazoom_inside() -> Kline:
|
||||
c = (
|
||||
|
||||
@ -31,6 +31,7 @@ class Bar(RectChart):
|
||||
markpoint_opts: Union[opts.MarkPointOpts, dict, None] = None,
|
||||
markline_opts: Union[opts.MarkLineOpts, dict, None] = None,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -40,6 +41,8 @@ class Bar(RectChart):
|
||||
markline_opts = markline_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_color(color)
|
||||
self._append_legend(series_name, is_selected)
|
||||
@ -56,6 +59,7 @@ class Bar(RectChart):
|
||||
"markPoint": markpoint_opts,
|
||||
"markLine": markline_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -29,6 +29,7 @@ class Boxplot(RectChart):
|
||||
markpoint_opts: Union[opts.MarkPointOpts, dict] = opts.MarkPointOpts(),
|
||||
markline_opts: Union[opts.MarkLineOpts, dict] = opts.MarkLineOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -38,6 +39,8 @@ class Boxplot(RectChart):
|
||||
markline_opts = markline_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("series").append(
|
||||
@ -51,6 +54,7 @@ class Boxplot(RectChart):
|
||||
"markPoint": markpoint_opts,
|
||||
"markLine": markline_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
@ -74,6 +78,6 @@ class Boxplot(RectChart):
|
||||
elif m == 3 / 4:
|
||||
res.append(d[k - 1] * 0.25 + d[k] * 0.75)
|
||||
data.append([d[0]] + res + [d[-1]])
|
||||
except Exception:
|
||||
except:
|
||||
pass
|
||||
return data
|
||||
|
||||
@ -25,6 +25,7 @@ class Calendar(Chart):
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
calendar_opts: Union[opts.CalendarOpts, dict, None] = None,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -32,6 +33,8 @@ class Calendar(Chart):
|
||||
calendar_opts = calendar_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
if calendar_opts:
|
||||
self.options.update(calendar=calendar_opts)
|
||||
@ -45,6 +48,7 @@ class Calendar(Chart):
|
||||
"data": yaxis_data,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -30,6 +30,7 @@ class EffectScatter(RectChart):
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
effect_opts: Union[opts.EffectOpts, dict] = opts.EffectOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -37,6 +38,8 @@ class EffectScatter(RectChart):
|
||||
effect_opts = effect_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_color(color)
|
||||
self._append_legend(series_name, is_selected)
|
||||
@ -53,6 +56,7 @@ class EffectScatter(RectChart):
|
||||
"data": [list(z) for z in zip(self._xaxis_data, y_axis)],
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -24,11 +24,14 @@ class Funnel(Chart):
|
||||
gap: Numeric = 0,
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_color(color)
|
||||
data = [{"name": n, "value": v} for n, v in data_pair]
|
||||
@ -47,6 +50,7 @@ class Funnel(Chart):
|
||||
"gap": gap,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -24,9 +24,12 @@ class Gauge(Chart):
|
||||
start_angle: Numeric = 225,
|
||||
end_angle: Numeric = -45,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("series").append(
|
||||
@ -40,6 +43,7 @@ class Gauge(Chart):
|
||||
"endAngle": end_angle,
|
||||
"data": [{"name": n, "value": v} for n, v in data_pair],
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -82,6 +82,7 @@ class Geo(Chart):
|
||||
effect_opts: Union[opts.EffectOpts, dict] = opts.EffectOpts(),
|
||||
linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -91,6 +92,8 @@ class Geo(Chart):
|
||||
linestyle_opts = linestyle_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._zlevel += 1
|
||||
data = []
|
||||
@ -116,6 +119,7 @@ class Geo(Chart):
|
||||
"data": data,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
|
||||
@ -132,6 +136,7 @@ class Geo(Chart):
|
||||
"data": data,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
|
||||
@ -143,6 +148,7 @@ class Geo(Chart):
|
||||
"coordinateSystem": "geo",
|
||||
"data": data,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
|
||||
@ -158,6 +164,7 @@ class Geo(Chart):
|
||||
"data": data,
|
||||
"lineStyle": linestyle_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -36,6 +36,7 @@ class Graph(Chart):
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -43,6 +44,8 @@ class Graph(Chart):
|
||||
linestyle_opts = linestyle_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
_nodes = []
|
||||
for n in nodes:
|
||||
@ -87,6 +90,7 @@ class Graph(Chart):
|
||||
"edgeSymbolSize": edge_symbol_size,
|
||||
"links": _links,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -31,6 +31,7 @@ class HeatMap(RectChart):
|
||||
markpoint_opts: Union[opts.MarkPointOpts, dict, None] = None,
|
||||
markline_opts: Union[opts.MarkLineOpts, dict, None] = None,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -40,6 +41,8 @@ class HeatMap(RectChart):
|
||||
markline_opts = markline_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("yAxis")[0].update(data=yaxis_data)
|
||||
@ -54,6 +57,7 @@ class HeatMap(RectChart):
|
||||
"markLine": markline_opts,
|
||||
"markPoint": markpoint_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -31,6 +31,7 @@ class Kline(RectChart):
|
||||
markline_opts: Union[opts.MarkLineOpts, dict, None] = None,
|
||||
markpoint_opts: Union[opts.MarkPointOpts, dict, None] = None,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
|
||||
if isinstance(markpoint_opts, opts.MarkPointOpts):
|
||||
@ -39,6 +40,8 @@ class Kline(RectChart):
|
||||
markline_opts = markline_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("series").append(
|
||||
@ -51,6 +54,7 @@ class Kline(RectChart):
|
||||
"markPoint": markpoint_opts,
|
||||
"markLine": markline_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -34,10 +34,10 @@ class Line(RectChart):
|
||||
markpoint_opts: Union[opts.MarkPointOpts, dict, None] = None,
|
||||
markline_opts: Union[opts.MarkLineOpts, dict, None] = None,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
|
||||
areastyle_opts: Union[opts.AreaStyleOpts, dict] = opts.AreaStyleOpts(),
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict] = opts.ItemStyleOpts(),
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
|
||||
@ -27,11 +27,14 @@ class Map(Chart):
|
||||
is_map_symbol_show: bool = True,
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self.js_dependencies.add(maptype)
|
||||
data = [{"name": n, "value": v} for n, v in data_pair]
|
||||
@ -47,6 +50,7 @@ class Map(Chart):
|
||||
"roam": is_roam,
|
||||
"showLegendSymbol": is_map_symbol_show,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -32,11 +32,14 @@ class Parallel(Chart):
|
||||
is_selected: bool = True,
|
||||
linestyle_opts: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(linestyle_opts, opts.LineStyleOpts):
|
||||
linestyle_opts = linestyle_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self.options.update(parallel=opts.ParallelOpts().opts)
|
||||
self._append_legend(series_name, is_selected)
|
||||
@ -48,6 +51,7 @@ class Parallel(Chart):
|
||||
"name": series_name,
|
||||
"data": data,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -26,11 +26,14 @@ class Pie(Chart):
|
||||
rosetype: Optional[str] = None,
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
data = [{"name": n, "value": v} for n, v in data_pair]
|
||||
|
||||
@ -58,6 +61,7 @@ class Pie(Chart):
|
||||
"roseType": rosetype,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Chart
|
||||
from ...commons.types import Numeric, Optional, Sequence, Union
|
||||
from ...globals import ChartType
|
||||
|
||||
|
||||
class Polar(Chart):
|
||||
@ -41,6 +42,7 @@ class Polar(Chart):
|
||||
areastyle_opts: Union[opts.AreaStyleOpts, dict] = opts.AreaStyleOpts(),
|
||||
effect_opts: Union[opts.EffectOpts, dict] = opts.EffectOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -50,11 +52,13 @@ class Polar(Chart):
|
||||
effect_opts = effect_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.update(polar={})
|
||||
|
||||
if type_ in ("scatter", "line", "bar"):
|
||||
if type_ in (ChartType.SCATTER, ChartType.LINE, ChartType.BAR):
|
||||
self.options.get("series").append(
|
||||
{
|
||||
"type": type_,
|
||||
@ -67,10 +71,11 @@ class Polar(Chart):
|
||||
"label": label_opts,
|
||||
"areaStyle": areastyle_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
|
||||
elif type_ == "effectScatter":
|
||||
elif type_ == ChartType.EFFECT_SCATTER:
|
||||
self.options.get("series").append(
|
||||
{
|
||||
"type": type_,
|
||||
@ -83,6 +88,7 @@ class Polar(Chart):
|
||||
"data": data,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -28,6 +28,7 @@ class Sankey(Chart):
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
linestyle_opt: Union[opts.LineStyleOpts, dict] = opts.LineStyleOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -35,6 +36,8 @@ class Sankey(Chart):
|
||||
linestyle_opt = linestyle_opt.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("series").append(
|
||||
@ -48,6 +51,7 @@ class Sankey(Chart):
|
||||
"label": label_opts,
|
||||
"lineStyle": linestyle_opt,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -32,6 +32,7 @@ class Scatter(RectChart):
|
||||
markpoint_opts: Union[opts.MarkPointOpts, dict, None] = None,
|
||||
markline_opts: Union[opts.MarkLineOpts, dict, None] = None,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -41,6 +42,8 @@ class Scatter(RectChart):
|
||||
markpoint_opts = markpoint_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_color(color)
|
||||
self._append_legend(series_name, is_selected)
|
||||
@ -58,6 +61,7 @@ class Scatter(RectChart):
|
||||
"markPoint": markpoint_opts,
|
||||
"markLine": markline_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -22,8 +22,9 @@ class ThemeRiver(Chart):
|
||||
*,
|
||||
is_selected: bool = True,
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
singleaxis_opts: Union[opts.SingleAxisOpts, dict] = opts.SingleAxisOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -31,6 +32,8 @@ class ThemeRiver(Chart):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(singleaxis_opts, opts.SingleAxisOpts):
|
||||
singleaxis_opts = singleaxis_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
for n in series_name:
|
||||
self._append_legend(n, is_selected)
|
||||
@ -42,6 +45,7 @@ class ThemeRiver(Chart):
|
||||
"data": data,
|
||||
"label": label_opts,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -51,6 +51,7 @@ class Tree(Chart):
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
leaves_label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
@ -58,6 +59,8 @@ class Tree(Chart):
|
||||
leaves_label_opts = leaves_label_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
_data = self._set_collapse_interval(data, collapse_interval)
|
||||
self.options.get("series").append(
|
||||
@ -76,6 +79,7 @@ class Tree(Chart):
|
||||
"label": label_opts,
|
||||
"leaves": {"label": leaves_label_opts},
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -32,11 +32,14 @@ class TreeMap(Chart):
|
||||
visible_max: Optional[Numeric] = None,
|
||||
label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("series").append(
|
||||
@ -54,6 +57,7 @@ class TreeMap(Chart):
|
||||
"visibleMin": visible_min,
|
||||
"visibleMax": visible_max,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -39,9 +39,12 @@ class WordCloud(Chart):
|
||||
word_size_range=None,
|
||||
rotate_step: Numeric = 45,
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
|
||||
data = []
|
||||
for n, v in data_pair:
|
||||
@ -69,6 +72,7 @@ class WordCloud(Chart):
|
||||
"sizeRange": word_size_range,
|
||||
"data": data,
|
||||
"tooltip": tooltip_opts,
|
||||
"itemStyle": itemstyle_opts,
|
||||
}
|
||||
)
|
||||
return self
|
||||
|
||||
@ -37,6 +37,7 @@ class Chart(Base):
|
||||
markarea_opts: Union[opts.MarkAreaOpts, dict, None] = None,
|
||||
effect_opts: Union[opts.EffectOpts, dict] = opts.EffectOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
|
||||
):
|
||||
_series = self.options.get("series")
|
||||
if label_opts:
|
||||
@ -98,6 +99,13 @@ class Chart(Base):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
for s in _series:
|
||||
s.update(tooltip=tooltip_opts)
|
||||
|
||||
if itemstyle_opts:
|
||||
if isinstance(itemstyle_opts, opts.ItemStyleOpts):
|
||||
itemstyle_opts = itemstyle_opts.opts
|
||||
for s in _series:
|
||||
s.update(itemStyle=itemstyle_opts)
|
||||
|
||||
return self
|
||||
|
||||
def _append_legend(self, name, is_selected):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user