bar.py
1.9 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
from ... import options as opts
from ... import types
from ...charts.chart import RectChart
from ...globals import ChartType
class Bar(RectChart):
"""
<<< Bar Chart >>>
Bar chart presents categorical data with rectangular bars
with heights or lengths proportional to the values that they represent.
"""
def add_yaxis(
self,
series_name: str,
yaxis_data: types.Sequence[types.Union[types.Numeric, opts.BarItem, dict]],
*,
is_selected: bool = True,
xaxis_index: types.Optional[types.Numeric] = None,
yaxis_index: types.Optional[types.Numeric] = None,
color: types.Optional[str] = None,
stack: types.Optional[str] = None,
category_gap: types.Union[types.Numeric, str] = "20%",
gap: types.Optional[str] = None,
label_opts: types.Label = opts.LabelOpts(),
markpoint_opts: types.MarkPoint = None,
markline_opts: types.MarkLine = None,
tooltip_opts: types.Tooltip = None,
itemstyle_opts: types.ItemStyle = None,
encode: types.Union[types.JSFunc, dict, None] = None,
):
self._append_color(color)
self._append_legend(series_name, is_selected)
if self.options.get("dataset") is not None:
yaxis_data = None
self.options.get("series").append(
{
"type": ChartType.BAR,
"name": series_name,
"xAxisIndex": xaxis_index,
"yAxisIndex": yaxis_index,
"data": yaxis_data,
"stack": stack,
"barCategoryGap": category_gap,
"barGap": gap,
"label": label_opts,
"markPoint": markpoint_opts,
"markLine": markline_opts,
"tooltip": tooltip_opts,
"itemStyle": itemstyle_opts,
"encode": encode,
}
)
return self