class pyecharts.charts.Bar(RectChart)
pyecharts/charts/basic_charts/bar.py
from ... import options as optsfrom ... import typesfrom ...charts.chart import RectChartfrom ...globals import ChartTypeclass Bar(RectChart):"""<<< Bar Chart >>>Bar chart presents categorical data with rectangular barswith 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,):self._append_color(color)self._append_legend(series_name, is_selected)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,})return self
下面分别介绍其方法
class Bar(
    # 初始化配置项,参考 `global_options.InitOpts`
    init_opts: opts.InitOpts = opts.InitOpts()
)
func pyecharts.charts.Bar.add_yaxis
def add_yaxis(
    # 系列名称,用于 tooltip 的显示,legend 的图例筛选。
    series_name: str,
    # 系列数据
    y_axis: Sequence[Numeric, opts.BarItem, dict],
    # 是否选中图例
    is_selected: bool = True,
    # 使用的 x 轴的 index,在单个图表实例中存在多个 x 轴的时候有用。
    xaxis_index: Optional[Numeric] = None,
    # 使用的 y 轴的 index,在单个图表实例中存在多个 y 轴的时候有用。
    yaxis_index: Optional[Numeric] = None,
    # 系列 label 颜色
    color: Optional[str] = None,
    # 数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置。
    stack: Optional[str] = None,
    # 同一系列的柱间距离,默认为类目间距的 20%,可设固定值
    category_gap: Union[Numeric, str] = "20%",
    # 不同系列的柱间距离,为百分比(如 '30%',表示柱子宽度的 30%)。
    # 如果想要两个系列的柱子重叠,可以设置 gap 为 '-100%'。这在用柱子做背景的时候有用。
    gap: Optional[str] = None,
    # 标签配置项,参考 `series_options.LabelOpts`
    label_opts: Union[opts.LabelOpts, dict] = opts.LabelOpts(),
    # 标记点配置项,参考 `series_options.MarkPointOpts`
    markpoint_opts: Union[opts.MarkPointOpts, dict, None] = None,
    # 标记线配置项,参考 `series_options.MarkLineOpts`
    markline_opts: Union[opts.MarkLineOpts, dict, None] = None,
    # 提示框组件配置项,参考 `series_options.TooltipOpts`
    tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
    # 图元样式配置项,参考 `series_options.ItemStyleOpts`
    itemstyle_opts: Union[opts.ItemStyleOpts, dict, None] = None,
    # 可以定义 data 的哪个维度被编码成什么。
    encode: types.Union[types.JSFunc, dict, None] = None,
)
BarItem:柱状图数据项
class BarItem(
    # 数据项名称。
    name: Optional[str] = None,
    # 单个数据项的数值。
    value: Optional[Numeric] = None,
    # 单个柱条文本的样式设置,参考 `series_options.LabelOpts`。
    label_opts: Union[LabelOpts, dict, None] = None,
    # 图元样式配置项,参考 `series_options.ItemStyleOpts`
    itemstyle_opts: Union[ItemStyleOpts, dict, None] = None,
    # 提示框组件配置项,参考 `series_options.TooltipOpts`
    tooltip_opts: Union[TooltipOpts, dict, None] = None,
)
                    