gauge.py
1.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
from ... import options as opts
from ... import types
from ...charts.chart import Chart
from ...globals import ChartType
class Gauge(Chart):
"""
<<< Gauge >>>
The gauge displays a single key business measure.
"""
def add(
self,
series_name: str,
data_pair: types.Sequence,
*,
is_selected: bool = True,
min_: types.Numeric = 0,
max_: types.Numeric = 100,
split_number: types.Numeric = 10,
radius: types.Union[types.Numeric, str] = "75%",
start_angle: types.Numeric = 225,
end_angle: types.Numeric = -45,
title_label_opts: types.Label = opts.LabelOpts(),
detail_label_opts: types.Label = opts.LabelOpts(formatter="{value}%"),
tooltip_opts: types.Tooltip = None,
axisline_opts: types.AxisLine = None,
itemstyle_opts: types.ItemStyle = None,
):
self._append_legend(series_name, is_selected)
self.options.get("series").append(
{
"type": ChartType.GAUGE,
"title": title_label_opts,
"detail": detail_label_opts,
"name": series_name,
"min": min_,
"max": max_,
"splitNumber": split_number,
"radius": radius,
"startAngle": start_angle,
"endAngle": end_angle,
"data": [{"name": n, "value": v} for n, v in data_pair],
"tooltip": tooltip_opts,
"axisLine": axisline_opts,
"itemStyle": itemstyle_opts,
}
)
return self