radar.py
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
from ... import options as opts
from ... import types
from ...charts.chart import Chart
from ...globals import ChartType
class Radar(Chart):
"""
<<< Radar >>>
Radar maps are mainly used to represent multivariable data.
"""
def add_schema(
self,
schema: types.Sequence[types.Union[opts.RadarIndicatorItem, dict]],
shape: types.Optional[str] = None,
center: types.Optional[types.Sequence] = None,
radius: types.Optional[types.Union[types.Sequence, str]] = None,
textstyle_opts: types.TextStyle = opts.TextStyleOpts(),
splitline_opt: types.SplitLine = opts.SplitLineOpts(is_show=True),
splitarea_opt: types.SplitArea = opts.SplitAreaOpts(),
axisline_opt: types.AxisLine = opts.AxisLineOpts(),
radiusaxis_opts: types.RadiusAxis = None,
angleaxis_opts: types.AngleAxis = None,
polar_opts: types.Polar = None,
):
self.options.update(
radiusAxis=radiusaxis_opts, angleAxis=angleaxis_opts, polar=polar_opts
)
indicators = []
for s in schema:
if isinstance(s, opts.RadarIndicatorItem):
s = s.opts
indicators.append(s)
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(
self,
series_name: str,
data: types.Sequence,
*,
is_selected: bool = True,
symbol: types.Optional[str] = None,
color: types.Optional[str] = None,
label_opts: opts.LabelOpts = opts.LabelOpts(),
linestyle_opts: opts.LineStyleOpts = opts.LineStyleOpts(),
areastyle_opts: opts.AreaStyleOpts = opts.AreaStyleOpts(),
tooltip_opts: types.Tooltip = None,
):
self._append_legend(series_name, is_selected)
self.options.get("series").append(
{
"type": ChartType.RADAR,
"name": series_name,
"data": data,
"symbol": symbol,
"label": label_opts,
"itemStyle": {"normal": {"color": color}},
"lineStyle": linestyle_opts,
"areaStyle": areastyle_opts,
"tooltip": tooltip_opts,
}
)
return self