Esempio n. 1
0
    def __add(self, name, x_axis, y_axis, is_stack=False, **kwargs):
        """

        :param name:
            图例名称
        :param x_axis:
            x 坐标轴数据
        :param y_axis:
            y 坐标轴数据
        :param is_stack:
            数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置
        :param kwargs:
        """
        if isinstance(x_axis, list) and isinstance(y_axis, list):
            assert len(x_axis) == len(y_axis)
            kwargs.update(x_axis=x_axis)
            chart = get_all_options(**kwargs)
            is_stack = "stack" if is_stack else ""
            xaxis, yaxis = chart['xy_axis']
            self._option.update(xAxis=xaxis, yAxis=yaxis)
            self._option.get('legend').get('data').append(name)
            self._option.get('series').append({
                "type": "bar",
                "name": name,
                "data": y_axis,
                "stack": is_stack,
                "label": chart['label'],
                "markPoint": chart['mark_point'],
                "markLine": chart['mark_line']
            })
            self._legend_visualmap_colorlst(**kwargs)
        else:
            raise TypeError("x_axis and y_axis must be list")
Esempio n. 2
0
    def __add(self, name, x_axis, y_axis, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updating data and configuration with setOption.
        :param x_axis:
            data of xAxis
        :param y_axis:
            data pf yAxis
            Data should be the two-dimensional array shown as follow. -> [[],[]]
            Every data item (each line in the example above) represents a box,
            which contains 4 values. They are: [open, close, lowest, highest]
            (namely: [opening value, closing value, lowest value, highest value])
        :param kwargs:
        :return:
        """
        kwargs.update(type="candlestick", x_axis=x_axis)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "candlestick",
            "name": name,
            "data": y_axis,
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 3
0
    def __add(self, name, data,
              grid3d_opacity=1,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param data:
            数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
        :param grid3d_opacity:
            3D 笛卡尔坐标系组的透明度(线的透明度),默认为 1,完全不透明。
        :param kwargs:
        """
        kwargs.update(xaxis3d_type='value',
                      yaxis3d_type='value',
                      zaxis3d_type='value')
        chart = get_all_options(**kwargs)

        self._option.get('legend')[0].get('data').append(name)
        self._option.update(
            xAxis3D=chart['xaxis3D'],
            yAxis3D=chart['yaxis3D'],
            zAxis3D=chart['zaxis3D'],
            grid3D=chart['grid3D']
        )

        self._option.get('series').append({
            "type": "line3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "itemStyle": {"opacity": grid3d_opacity}
        })
        self._config_components(**kwargs)
Esempio n. 4
0
    def __add(self, name, data, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param data:
            数据项。数据中,每一行是一个『数据项』,每一列属于一个『维度』。
        :param kwargs:
        """
        chart = get_all_options(**kwargs)
        self._option.update(parallel={
            "left": "5%",
            "right": "13%",
            "bottom": "10%",
            "top": "20%"
        })
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "parallel",
            "coordinateSystem": "parallel",
            "lineStyle": chart['line_style'],
            "name": name,
            "data": data,
        })
        self._config_components(**kwargs)
Esempio n. 5
0
    def __add(self, name, x_axis, y_axis,
              symbol_size=10,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            data of xAxis
        :param y_axis:
            data of yAxis
        :param symbol_size:
            symbol size
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(type="scatter", x_axis=x_axis)
        chart = get_all_options(**kwargs)
        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "scatter",
            "name": name,
            "symbol": chart['symbol'],
            "symbolSize": symbol_size,
            "data": [list(z) for z in zip(x_axis, y_axis)],
            "label": chart['label'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 6
0
    def __add(self, name, attr, value, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param attr:
            name of attribute
        :param value:
            value of attribute
        :param kwargs:
        """
        if isinstance(attr, list) and isinstance(value, list):
            assert len(attr) == len(value)
            chart = get_all_options(**kwargs)
            _data = []
            for data in zip(attr, value):
                _name, _value = data
                _data.append({"name": _name, "value": _value})
            for a in attr:
                self._option.get('legend')[0].get('data').append(a)
            _dset = set(self._option.get('legend')[0].get('data'))
            self._option.get('legend')[0].update(data=list(_dset))
            self._option.get('series').append({
                "type": "funnel",
                "name": name,
                "data": _data,
                "label": chart['label']
            })
            self._legend_visualmap_colorlst(**kwargs)
        else:
            raise TypeError("attr and value must be list")
Esempio n. 7
0
    def __add(self, name, x_axis, y_axis, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据,二维数组的每一数组项(上例中的每行)是渲染一个 box。
            它含有五个量值,依次是:[min, Q1, median (or Q2), Q3, max]。
        :param kwargs:
        """
        kwargs.update(x_axis=x_axis)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "boxplot",
            "name": name,
            "data": y_axis,
            "label": chart['label'],
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 8
0
    def __add(self, name, x_value, y_value,
              symbol_size=10,
              **kwargs):
        """

        :param name:
            图例名称
        :param x_axis:
            x 坐标轴数据
        :param y_axis:
            y 坐标轴数据
        :param symbol_size:
            标记图形大小
        :param kwargs:
        """
        if isinstance(x_value, list) and isinstance(y_value, list):
            assert len(x_value) == len(y_value)
            kwargs.update(type="scatter")
            chart = get_all_options(**kwargs)
            xaxis, yaxis = chart['xy_axis']
            self._option.update(xAxis=xaxis, yAxis=yaxis)
            self._option.get('legend').get('data').append(name)
            self._option.get('series').append({
                "type": "effectScatter",
                "name": name,
                "showEffectOn":"render",
                "rippleEffect": chart['effect'],
                "symbol": chart['symbol'],
                "symbolSize": symbol_size,
                "data": [list(z) for z in zip(x_value, y_value)],
                "label": chart['label'],
            })
            self._legend_visualmap_colorlst(**kwargs)
        else:
            raise TypeError("x_axis and y_axis must be list")
Esempio n. 9
0
 def addData(self,
             serisesName,
             data,
             is_stack=False,
             bar_category_gap="20%",
             **kwargs):
     chart = get_all_options(**kwargs)
     is_stack = "stack_" + str(
         self._option['series_id']) if is_stack else ""
     self._option.get('legend')[0].get('data').append(serisesName)
     self._option.get('series').append({
         "type":
         "bar",
         "name":
         serisesName,
         "data":
         data,
         "stack":
         is_stack,
         "barCategoryGap":
         bar_category_gap,
         "label":
         chart['label'],
         "markPoint":
         chart['mark_point'],
         "markLine":
         chart['mark_line'],
         "seriesId":
         self._option.get('series_id'),
     })
Esempio n. 10
0
    def __add(self, name, attr, value, **kwargs):
        """

        :param name:
            图例名称
        :param attr:
            属性名称
        :param value:
            属性所对应的值
        :param kwargs:
        """
        if isinstance(attr, list) and isinstance(value, list):
            assert len(attr) == len(value)
            chart = get_all_options(**kwargs)
            _data = []
            for data in zip(attr, value):
                _name, _value = data
                _data.append({"name": _name, "value": _value})
            for a in attr:
                self._option.get('legend')[0].get('data').append(a)
            _dset = set(self._option.get('legend')[0].get('data'))
            self._option.get('legend')[0].update(data=list(_dset))
            self._option.get('series').append({
                "type": "funnel",
                "name": name,
                "data": _data,
                "label": chart['label']
            })
            self._legend_visualmap_colorlst(**kwargs)
        else:
            raise TypeError("attr and value must be list")
Esempio n. 11
0
    def __add(self, name, x_axis, y_axis,
              is_stack=False,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            data of xAixs
        :param y_axis:
            data of yAxis
        :param is_stack:
            It specifies whether to stack category axis.
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(x_axis=x_axis)
        chart = get_all_options(**kwargs)
        is_stack = "stack" if is_stack else ""
        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "bar",
            "name": name,
            "data": y_axis,
            "stack": is_stack,
            "label": chart['label'],
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 12
0
    def __add(self, name, x_axis, y_axis, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据,二维数组的每一数组项(上例中的每行)是渲染一个 box。
            它含有五个量值,依次是:[min, Q1, median (or Q2), Q3, max]。
        :param kwargs:
        """
        kwargs.update(x_axis=x_axis)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "boxplot",
            "name": name,
            "data": y_axis,
            "label": chart['label'],
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 13
0
    def __add(self, name, value, item_color=None, **kwargs):
        """

        :param name:
            图例名称
        :param value:
            数据项,类型为包含列表的列表 [[]]。数据中,每一行是一个『数据项』,每一列属于一个『维度』
        :param item_color:
            指定单图例颜色
        :param kwargs:
        """
        kwargs.update(flag=True, type='radar')
        chart = get_all_options(**kwargs)
        self._option.get('legend').get('data').append(name)
        self._option.get('series').append({
            "type": "radar",
            "name": name,
            "data": value,
            "symbol": chart['symbol'],
            "itemStyle": {
                "normal": {
                    "color": item_color
                }
            },
            "lineStyle": chart['line_style'],
            "areaStyle": {
                "normal": chart['area_style']
            }
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 14
0
    def __add(self, name, attr, value, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updating data and configuration with setOption.
        :param attr:
            name of attribute
        :param value:
            value of attribute
        :param kwargs:
        """
        assert len(attr) == len(value)
        chart = get_all_options(**kwargs)

        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})
        for a in attr:
            self._option.get('legend')[0].get('data').append(a)
        _dset = set(self._option.get('legend')[0].get('data'))
        self._option.get('legend')[0].update(data=list(_dset))

        self._option.get('series').append({
            "type": "funnel",
            "name": name,
            "data": _data,
            "label": chart['label']
        })
        self._config_components(**kwargs)
Esempio n. 15
0
    def __add(self, name, x_axis, y_axis, **kwargs):
        """

        :param name:
            图例名称
        :param x_axis:
            x 坐标轴数据
        :param y_axis:
            y 坐标轴数据,类型为包含列表的列表 [[]]。数据中,每一行是一个『数据项』,每一列属于一个『维度』。
            数据项具体为 [open, close, lowest, highest] (即:[开盘值, 收盘值, 最低值, 最高值])
        :param kwargs:
        :return:
        """
        chart = get_all_options(**kwargs)
        self._option.update(xAxis={
            "type": "category",
            "data": x_axis,
            "scale": True,
            "boundaryGap": False
        },
                            yAxis={
                                "scale": True,
                                "splitArea": {
                                    "show": True
                                }
                            })
        self._option.get('legend').get('data').append(name)
        self._option.get('series').append({
            "type": "candlestick",
            "name": name,
            "data": y_axis,
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line']
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 16
0
    def __add(self, name, value, item_color=None, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param value:
            data array of series, it is represented by a two-dimension array -> [[],[]]
        :param item_color:
            Specify a single legend color
        :param kwargs:
        """
        kwargs.update(flag=True, type='radar')
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "radar",
            "name": name,
            "data": value,
            "symbol": chart['symbol'],
            "itemStyle": {"normal": {"color": item_color}},
            "lineStyle": chart['line_style'],
            "areaStyle": {"normal": chart['area_style']},
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 17
0
    def __add(self, name, x_axis, y_axis,
              is_stack=False,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            data of xAixs
        :param y_axis:
            data of yAxis
        :param is_stack:
            It specifies whether to stack category axis.
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(x_axis=x_axis)
        chart = get_all_options(**kwargs)
        is_stack = "stack" if is_stack else ""
        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "bar",
            "name": name,
            "data": y_axis,
            "stack": is_stack,
            "label": chart['label'],
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 18
0
    def __add(self, name, value, item_color=None, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选
        :param value:
            数据项。数据中,每一行是一个『数据项』,每一列属于一个『维度』
        :param item_color:
            指定单图例颜色
        :param kwargs:
        """
        kwargs.update(flag=True, type='radar')
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "radar",
            "name": name,
            "data": value,
            "symbol": chart['symbol'],
            "label": chart['label'],
            "itemStyle": {
                "normal": {
                    "color": item_color
                }
            },
            "lineStyle": chart['line_style'],
            "areaStyle": {
                "normal": chart['area_style']
            },
        })
        self._config_components(**kwargs)
Esempio n. 19
0
    def __add(self, name, data, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。类型必须为 list。
        :param data:
            数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
            每个数据项至少需要三个维度,如 ['2015/11/08', 10, 'DQ'],分别为
            [时间,数值,种类(图例名)]。
        :param kwargs:
        """
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').extend(name)

        self._option.get('series').append({
            "type":
            "themeRiver",
            "name":
            name,
            "data":
            data,
            "label":
            chart['label'],
            "seriesId":
            self._option.get('series_id'),
        })

        self._option.update(singleAxis={"type": "time"})
        self._config_components(**kwargs)
        self._option.get('tooltip').update(trigger='axis')
Esempio n. 20
0
    def __add(self, name, attr, value, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param attr:
            name of attribute
        :param value:
            value of attribute
        :param kwargs:
        """
        assert len(attr) == len(value)
        chart = get_all_options(**kwargs)
        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})
        for a in attr:
            self._option.get('legend')[0].get('data').append(a)
        _dset = set(self._option.get('legend')[0].get('data'))
        self._option.get('legend')[0].update(data=list(_dset))
        self._option.get('series').append({
            "type": "funnel",
            "name": name,
            "data": _data,
            "label": chart['label']
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 21
0
    def __add(self, name, x_axis, y_axis,
              symbol_size=10,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。
        :param symbol_size:
            标记图形大小。
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(type="scatter")
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "effectScatter",
            "name": name,
            "showEffectOn":"render",
            "rippleEffect": chart['effect'],
            "symbol": chart['symbol'],
            "symbolSize": symbol_size,
            "data": [list(z) for z in zip(x_axis, y_axis)],
            "label": chart['label'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 22
0
    def __add(self, name, x_axis, y_axis,
              symbol_size=10,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。
        :param symbol_size:
            标记图形大小。
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(type="scatter")
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "effectScatter",
            "name": name,
            "showEffectOn": "render",
            "rippleEffect": chart['effect'],
            "symbol": chart['symbol'],
            "symbolSize": symbol_size,
            "data": [list(z) for z in zip(x_axis, y_axis)],
            "label": chart['label'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 23
0
    def _config_components(self,
                           is_visualmap=False,
                           is_more_utils=False,
                           is_toolbox_show=True,
                           **kwargs):
        """ 图形组件配置项

        :param is_visualmap:
            指定是否使用 visualMap 组件
        :param is_datazoom_show:
            指定是否使用 dataZoom 组件
        :param is_more_utils:
            指定是否提供更多的实用小工具
        :param is_toolbox_show:
            指定是否显示工具箱
        :param kwargs:
        """
        kwargs.update(colorlst=self._colorlst)
        chart = get_all_options(**kwargs)
        self._option.update(color=chart['color'])

        # legend
        self._option.get('legend')[0].update(chart['legend'])

        # tooltip
        self._option.update(tooltip=chart['tooltip'])

        # dataZoom,勿改动
        if kwargs.get('is_datazoom_show', None) is True:
            self._option.update(dataZoom=chart['datazoom'])

        # visualMap
        if is_visualmap:
            self._option.update(visualMap=chart['visual_map'])

        # toolbox
        if is_more_utils:
            self._option.get('toolbox').get('feature').update(magicType={
                "show":
                True,
                "type": ['line', 'bar', 'stack', 'tiled'],
                "title": {
                    "line": "折线图",
                    "bar": "柱状图",
                    "stack": "堆叠",
                    "tiled": "平铺"
                }
            },
                                                              dataZoom={
                                                                  "show": True,
                                                                  "title": {
                                                                      "zoom":
                                                                      "区域缩放",
                                                                      "back":
                                                                      "缩放还原"
                                                                  }
                                                              })

        if not is_toolbox_show:
            self._option.pop("toolbox", None)
Esempio n. 24
0
    def __add(self, name, data, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updating data and configuration with setOption.It must be a list.
        :param data:
            data array of series, it is represented by a two-dimension array -> [[],[]]
            every data item need three value, for example
            ['2015/11/08',10,'DQ'] -> [time, value, legend(category)]
        :param kwargs:
        :return:
        """
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').extend(name)

        self._option.get('series').append({
            "type": "themeRiver",
            "name": name,
            "data": data,
            "label": chart['label'],
            "seriesId": self._option.get('series_id'),
        })

        self._option.update(singleAxis={"type": "time"})
        self._config_components(**kwargs)
        self._option.get('tooltip').update(trigger='axis')
Esempio n. 25
0
    def __add(self, name, data,
              grid3d_opacity=1,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering
            with legend, or updaing data and configuration with setOption.
        :param data:
            data of line3D
        :param grid3d_opacity:
            opacity of gird3D item
        :param kwargs:
        :return:
        """
        kwargs.update(xaxis3d_type='value',
                      yaxis3d_type='value',
                      zaxis3d_type='value')
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)
        self._option.update(
            xAxis3D=chart['xaxis3D'],
            yAxis3D=chart['yaxis3D'],
            zAxis3D=chart['zaxis3D'],
            grid3D=chart['grid3D']
        )
        self._option.get('series').append({
            "type": "line3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "itemStyle": {"opacity": grid3d_opacity}
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 26
0
    def __add(self, name, x_axis, y_axis,
              is_symbol_show=True,
              symbol_size=4,
              is_smooth=False,
              is_stack=False,
              is_step=False,
              is_fill=False,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。
        :param is_symbol_show:
            是否显示标记图形,默认为 True。
        :param is_smooth:
            是否平滑曲线显示,默认为 False。
        :param is_stack:
            数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置。默认为 False。
        :param is_step:
            是否是阶梯线图。可以设置为 True 显示成阶梯线图。默认为 False。
            也支持设置成'start', 'middle', 'end'分别配置在当前点,当前点与下个
            点的中间下个点拐弯。
        :param is_fill:
            是否填充曲线所绘制面积,默认为 False。
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(x_axis=x_axis, type="line", flag=True)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        if is_stack:
            is_stack = "stack_" + str(self._option['series_id'])
        else:
            is_stack = ""
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "line",
            "name": name,
            "symbol": chart['symbol'],
            "symbolSize": symbol_size,
            "smooth": is_smooth,
            "step": is_step,
            "stack": is_stack,
            "showSymbol": is_symbol_show,
            "data": y_axis,
            "label": chart['label'],
            "lineStyle": chart['line_style'],
            "areaStyle": chart['area_style'],
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 27
0
    def __add(self, name, data,
              grid3D_opacity=1,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param data:
            data of line3D
        :param grid3D_opacity:
            opacity of gird3D item
        :param kwargs:
        :return:
        """
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)
        self._option.update(
            xAxis3D={
                "type": 'value',
            },
            yAxis3D={
                "type": "value",
            },
            zAxis3D={"type": "value"},
            grid3D=chart['grid3D']
        )
        self._option.get('series').append({
            "type": "line3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "itemStyle": {"opacity": grid3D_opacity}
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 28
0
    def __add(self, name, attr, value, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param attr:
            属性名称。
        :param value:
            属性所对应的值。
        :param kwargs:
        """
        assert len(attr) == len(value)
        chart = get_all_options(**kwargs)

        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})
        for a in attr:
            self._option.get('legend')[0].get('data').append(a)
        _dset = set(self._option.get('legend')[0].get('data'))
        self._option.get('legend')[0].update(data=list(_dset))

        self._option.get('series').append({
            "type": "funnel",
            "name": name,
            "data": _data,
            "label": chart['label']
        })
        self._config_components(**kwargs)
Esempio n. 29
0
    def __add(self, name, x_axis, y_axis, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。数据中,每一行是一个『数据项』,每一列属于一个『维度』。
            数据项具体为 [open, close, lowest, highest] (即:[开盘值, 收盘值,
             最低值, 最高值])。
        :param kwargs:
        """
        kwargs.update(type="candlestick", x_axis=x_axis)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('xAxis')[0].update(scale=True)
        self._option.get('yAxis')[0].update(
            scale=True, splitArea={"show": True})

        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "candlestick",
            "name": name,
            "data": y_axis,
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 30
0
    def __add(self, name, value, item_color=None, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updating data and configuration with setOption.
        :param value:
            data array of series, it is represented by a two-dimension array -> [[],[]]
        :param item_color:
            Specify a single legend color
        :param kwargs:
        """
        kwargs.update(flag=True, type='radar')
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "radar",
            "name": name,
            "data": value,
            "symbol": chart['symbol'],
            "label": chart['label'],
            "itemStyle": {
                "normal": {
                    "color": item_color
                }
            },
            "lineStyle": chart['line_style'],
            "areaStyle": {
                "normal": chart['area_style']
            },
        })
        self._config_components(**kwargs)
Esempio n. 31
0
    def __add(self, name, data, grid3d_opacity=1, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选
        :param data:
            数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』
        :param grid3d_opacity:
            3D 笛卡尔坐标系组的透明度(点的透明度),默认为 1,完全不透明。
        :param kwargs:
        """
        kwargs.update(xaxis3d_type='value',
                      yaxis3d_type='value',
                      zaxis3d_type='value')
        chart = get_all_options(**kwargs)

        self._option.get('legend')[0].get('data').append(name)
        self._option.update(xAxis3D=chart['xaxis3D'],
                            yAxis3D=chart['yaxis3D'],
                            zAxis3D=chart['zaxis3D'],
                            grid3D=chart['grid3D'])

        self._option.get('series').append({
            "type": "scatter3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "itemStyle": {
                "opacity": grid3d_opacity
            }
        })
        self._config_components(**kwargs)
Esempio n. 32
0
    def __add(self, *args, **kwargs):
        """

        :param args:
            if kwargs has is_calendar_heatmap property:
                :param name:
                    Series name used for displaying in tooltip and filtering with legend,
                    or updating data and configuration with setOption.
                :param data:
                    data array of series, it is represented by a two-dimension array -> [[],[]]
            else:
                :param name:
                    Series name used for displaying in tooltip and filtering with legend,
                    or updating data and configuration with setOption.
                :param x_axis:
                    data of xAxis, it must be catagory axis.
                :param y_axis:
                    data of yAxis, it must be catagory axis.
                :param data:
                    data array of series, it is represented by a two-dimension array -> [[],[]]
        :param kwargs:
        :return:
        """
        _is_calendar = kwargs.get('is_calendar_heatmap', None) is True
        if _is_calendar:
            name, data = args
        else:
            name, x_axis, y_axis, data = args

        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type":
            "heatmap",
            "name":
            name,
            "data":
            data,
            "label":
            chart['label'],
            "seriesId":
            self._option.get('series_id'),
        })

        if _is_calendar:
            self._option.get('toolbox')['show'] = False
            self._option.get('series')[0].update(coordinateSystem='calendar')
            self._option.update(calendar=chart['calendar'])
        else:
            xaxis, yaxis = chart['xy_axis']
            self._option.update(xAxis=xaxis, yAxis=yaxis)
            self._option.get('xAxis')[0].update(type='category',
                                                data=x_axis,
                                                splitArea={"show": True})
            self._option.get('yAxis')[0].update(type='category',
                                                data=y_axis,
                                                splitArea={"show": True})

        self._config_components(**kwargs)
Esempio n. 33
0
    def __add(self, name, x_value, y_value,
              symbol_size=10,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            data of xAxis
        :param y_axis:
            data of yAxis
        :param symbol_size:
            symbol size
        :param kwargs:
        """
        assert len(x_value) == len(y_value)
        kwargs.update(type="scatter")
        chart = get_all_options(**kwargs)
        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "effectScatter",
            "name": name,
            "showEffectOn":"render",
            "rippleEffect": chart['effect'],
            "symbol": chart['symbol'],
            "symbolSize": symbol_size,
            "data": [list(z) for z in zip(x_value, y_value)],
            "label": chart['label'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 34
0
    def __add(self, name, value, item_color=None, **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选
        :param value:
            数据项。数据中,每一行是一个『数据项』,每一列属于一个『维度』
        :param item_color:
            指定单图例颜色
        :param kwargs:
        """
        kwargs.update(flag=True, type='radar')
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "radar",
            "name": name,
            "data": value,
            "symbol": chart['symbol'],
            "label": chart['label'],
            "itemStyle": {
                "normal": {
                    "color": item_color
                }},
            "lineStyle": chart['line_style'],
            "areaStyle": {
                "normal": chart['area_style']
            },
        })
        self._config_components(**kwargs)
Esempio n. 35
0
    def __add(self, name, x_axis, y_axis,
              is_symbol_show=True,
              is_smooth=False,
              is_stack=False,
              is_step=False,
              is_fill=False,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。
        :param is_symbol_show:
            是否显示标记图形,默认为 True。
        :param is_smooth:
            是否平滑曲线显示,默认为 False。
        :param is_stack:
            数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置。默认为 False。
        :param is_step:
            是否是阶梯线图。可以设置为 True 显示成阶梯线图。默认为 False。
            也支持设置成'start', 'middle', 'end'分别配置在当前点,当前点与下个
            点的中间下个点拐弯。
        :param is_fill:
            是否填充曲线所绘制面积,默认为 False。
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(x_axis=x_axis, type="line")
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        if is_stack:
            is_stack = "stack_" + str(self._option['series_id'])
        else:
            is_stack = ""
        _area_style = {"normal": chart['area_style']} if is_fill else {}
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "line",
            "name": name,
            "symbol": chart['symbol'],
            "smooth": is_smooth,
            "step": is_step,
            "stack": is_stack,
            "showSymbol": is_symbol_show,
            "data": y_axis,
            "label": chart['label'],
            "lineStyle": chart['line_style'],
            "areaStyle": _area_style,
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 36
0
    def __add(self,
              name,
              attr,
              value,
              maptype="china",
              is_roam=True,
              is_map_symbol_show=True,
              name_map=None,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param attr:
            属性名称。
        :param value:
            属性所对应的值。
        :param maptype:
            地图类型。 支持 china、world、安徽、澳门、北京、重庆、福建、福建、甘肃、广东,
            广西、广州、海南、河北、黑龙江、河南、湖北、湖南、江苏、江西、吉林、辽宁、
            内蒙古、宁夏、青海、山东、上海、陕西、山西、四川、台湾、天津、香港、新疆、
            西藏、云南、浙江,以及 [363个二线城市地图](https://github.com/chfw/echarts-
            china-cities-js#featuring-citiesor-for-single-download)。
            提醒:
                在画市级地图的时候,城市名字后面的‘市’要省去了,比如,石家庄市的‘市’不要提,
                即‘石家庄’就可以了。地图提供了自定义模式 [用户如何自定义地图](https://github.com/
                chenjiandongx/pyecharts/blob/master/docs/zh-cn/user-customize-map.md)
        :param is_roam:
            是否开启鼠标缩放和平移漫游。默认为 True
            如果只想要开启缩放或者平移,可以设置成'scale'或者'move'。设置成 True 为都开启。
        :param is_map_symbol_show:
            是否显示地图标记红点,默认为 True。
        :param name_map:
            用自定义的地图名称。默认为 None,也就是用地图自带地名。
        :param kwargs:
        """
        assert len(attr) == len(value)
        chart = get_all_options(**kwargs)
        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})
        self._option.get('legend')[0].get('data').append(name)

        __option__ = {
            "type": "map",
            "name": name,
            "symbol": chart['symbol'],
            "label": chart['label'],
            "mapType": maptype,
            "data": _data,
            "roam": is_roam,
            "showLegendSymbol": is_map_symbol_show
        }
        if name_map:
            __option__['nameMap'] = name_map
        self._option.get('series').append(__option__)
        self._add_chinese_map(maptype)
        self._config_components(**kwargs)
Esempio n. 37
0
    def __add(self, x_axis, **kwargs):
        kwargs.update(x_axis=x_axis)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)

        self._config_components(**kwargs)
Esempio n. 38
0
    def __add(self, *args, **kwargs):
        """

        :param args:
            如果指定;额 is_has_calendar_heatmap 属性为 True,则定义如下
                :param name:
                    系列名称,用于 tooltip 的显示,legend 的图例筛选。
                :param data:
                    数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
            不指定,默认情况定义如下:
                :param name:
                    系列名称,用于 tooltip 的显示,legend 的图例筛选。
                :param x_axis:
                    x 坐标轴数据。需为类目轴,也就是不能是数值。
                :param y_axis:
                    y 坐标轴数据。需为类目轴,也就是不能是数值。
                :param data:
                    数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
        :param kwargs:
        """
        _is_calendar = kwargs.get('is_calendar_heatmap', None) is True
        if _is_calendar:
            name, data = args
        else:
            name, x_axis, y_axis, data = args

        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type":
            "heatmap",
            "name":
            name,
            "data":
            data,
            "label":
            chart['label'],
            "seriesId":
            self._option.get('series_id'),
        })

        if _is_calendar:
            self._option.get('toolbox')['show'] = False
            self._option.get('series')[0].update(coordinateSystem='calendar')
            self._option.update(calendar=chart['calendar'])
        else:
            xaxis, yaxis = chart['xy_axis']
            self._option.update(xAxis=xaxis, yAxis=yaxis)
            self._option.get('xAxis')[0].update(type='category',
                                                data=x_axis,
                                                splitArea={"show": True})
            self._option.get('yAxis')[0].update(type='category',
                                                data=y_axis,
                                                splitArea={"show": True})

        self._config_components(**kwargs)
Esempio n. 39
0
    def __add(self,
              name,
              x_axis,
              y_axis,
              data,
              grid3d_opacity=1,
              grid3d_shading='color',
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。需为类目轴,也就是不能是数值。
        :param y_axis:
            y 坐标轴数据。需为类目轴,也就是不能是数值。
        :param data:
            数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
        :param grid3d_opacity:
            3D 笛卡尔坐标系组的透明度(柱状的透明度),默认为 1,完全不透明。
        :param grid3d_shading:
            三维柱状图中三维图形的着色效果。
            color:
                只显示颜色,不受光照等其它因素的影响。
            lambert:
                通过经典的 lambert 着色表现光照带来的明暗。
            realistic:
                真实感渲染,配合 light.ambientCubemap 和 postEffect 使用可以让
                展示的画面效果和质感有质的提升。ECharts GL 中使用了基于物理的渲
                染(PBR)来表现真实感材质。
        :param kwargs:
        """
        kwargs.update(xaxis3d_type='category',
                      yaxis3d_type='category',
                      zaxis3d_type='value')
        chart = get_all_options(**kwargs)

        self._option.get('legend')[0].get('data').append(name)
        self._option.update(xAxis3D=chart['xaxis3D'],
                            yAxis3D=chart['yaxis3D'],
                            zAxis3D=chart['zaxis3D'],
                            grid3D=chart['grid3D'])
        self._option.get('xAxis3D').update(data=x_axis)
        self._option.get('yAxis3D').update(data=y_axis)

        self._option.get('series').append({
            "type": "bar3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "shading": grid3d_shading,
            "itemStyle": {
                "opacity": grid3d_opacity
            }
        })
        self._config_components(**kwargs)
Esempio n. 40
0
    def __add(self,
              name,
              x_axis,
              y_axis,
              extra_data=None,
              symbol_size=10,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。
        :param extra_data:
            第三维度数据,x 轴为第一个维度,y 轴为第二个维度。(可在 visualmap 中
            将视图元素映射到第三维度)。
        :param symbol_size:
            标记图形大小,默认为 10。
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(type="scatter", x_axis=x_axis)
        chart = get_all_options(**kwargs)

        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        if extra_data:
            _data = [list(z) for z in zip(x_axis, y_axis, extra_data)]
        else:
            _data = [list(z) for z in zip(x_axis, y_axis)]

        self._option.get('series').append({
            "type":
            "scatter",
            "name":
            name,
            "symbol":
            chart['symbol'],
            "symbolSize":
            symbol_size,
            "data":
            _data,
            "label":
            chart['label'],
            "markPoint":
            chart['mark_point'],
            "markLine":
            chart['mark_line'],
            "seriesId":
            self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 41
0
    def _config_components(self, is_visualmap=False,
                           is_more_utils=False,
                           is_toolbox_show=True,
                           **kwargs):
        """ 图形组件配置项

        :param is_visualmap:
            指定是否使用 visualMap 组件
        :param is_datazoom_show:
            指定是否使用 dataZoom 组件
        :param is_more_utils:
            指定是否提供更多的实用小工具
        :param is_toolbox_show:
            指定是否显示工具箱
        :param kwargs:
        """
        kwargs.update(colorlst=self._colorlst)
        chart = get_all_options(**kwargs)
        self._option.update(color=chart['color'])

        # legend
        self._option.get('legend')[0].update(chart['legend'])

        # tooltip
        self._option.update(tooltip=chart['tooltip'])

        # dataZoom,勿改动
        if kwargs.get('is_datazoom_show', None) is True:
            self._option.update(dataZoom=chart['datazoom'])

        # visualMap
        if is_visualmap:
            self._option.update(visualMap=chart['visual_map'])

        # toolbox
        if is_more_utils:
            self._option.get('toolbox').get('feature').update(
                magicType={
                    "show": True,
                    "type": ['line', 'bar', 'stack', 'tiled'],
                    "title": {
                        "line": "折线图",
                        "bar": "柱状图",
                        "stack": "堆叠",
                        "tiled": "平铺"
                    }},
                dataZoom={
                    "show": True,
                    "title": {
                        "zoom": "区域缩放",
                        "back": "缩放还原"
                    }}
            )

        if not is_toolbox_show:
            self._option.pop("toolbox", None)
Esempio n. 42
0
    def __add(self, name, x_axis, y_axis,
              is_symbol_show=True,
              is_smooth=False,
              is_stack=False,
              is_step=False,
              is_fill=False,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            data of xAxis
        :param y_axis:
            data of yAxis
        :param is_symbol_show:
            It specifies whether to show the symbol.
        :param is_smooth:
            Whether to show as smooth curve.
        :param is_stack:
            It specifies whether to stack category axis.
        :param is_step:
            Whether to show as a step line. It can be true, false. Or 'start', 'middle', 'end'.
            Which will configure the turn point of step line.
        :param is_fill:
            Whether to fill area.
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(x_axis=x_axis, type="line")
        chart = get_all_options(**kwargs)
        xaxis, yaxis = chart['xy_axis']
        is_stack = "stack" if is_stack else ""
        _area_style = {"normal": chart['area_style']} if is_fill else {}
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "line",
            "name": name,
            "symbol": chart['symbol'],
            "smooth": is_smooth,
            "step": is_step,
            "stack": is_stack,
            "showSymbol": is_symbol_show,
            "data": y_axis,
            "label": chart['label'],
            "lineStyle": chart['line_style'],
            "areaStyle": _area_style,
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 43
0
    def __add(self, name, x_axis, y_axis, data,
              grid3d_opacity=1,
              grid3d_shading='color',
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。需为类目轴,也就是不能是数值。
        :param y_axis:
            y 坐标轴数据。需为类目轴,也就是不能是数值。
        :param data:
            数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
        :param grid3d_opacity:
            3D 笛卡尔坐标系组的透明度(柱状的透明度),默认为 1,完全不透明。
        :param grid3d_shading:
            三维柱状图中三维图形的着色效果。
            color:
                只显示颜色,不受光照等其它因素的影响。
            lambert:
                通过经典的 lambert 着色表现光照带来的明暗。
            realistic:
                真实感渲染,配合 light.ambientCubemap 和 postEffect 使用可以让
                展示的画面效果和质感有质的提升。ECharts GL 中使用了基于物理的渲
                染(PBR)来表现真实感材质。
        :param kwargs:
        """
        kwargs.update(xaxis3d_type='category',
                      yaxis3d_type='category',
                      zaxis3d_type='value')
        chart = get_all_options(**kwargs)

        self._option.get('legend')[0].get('data').append(name)
        self._option.update(
            xAxis3D=chart['xaxis3D'],
            yAxis3D=chart['yaxis3D'],
            zAxis3D=chart['zaxis3D'],
            grid3D=chart['grid3D']
        )
        self._option.get('xAxis3D').update(data=x_axis)
        self._option.get('yAxis3D').update(data=y_axis)

        self._option.get('series').append({
            "type": "bar3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "shading": grid3d_shading,
            "itemStyle": {"opacity": grid3d_opacity}
        })
        self._config_components(**kwargs)
Esempio n. 44
0
    def __add(self, *args, **kwargs):
        """

        :param args:
            如果指定;额 is_has_calendar_heatmap 属性为 True,则定义如下
                :param name:
                    系列名称,用于 tooltip 的显示,legend 的图例筛选。
                :param data:
                    数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
            不指定,默认情况定义如下:
                :param name:
                    系列名称,用于 tooltip 的显示,legend 的图例筛选。
                :param x_axis:
                    x 坐标轴数据。需为类目轴,也就是不能是数值。
                :param y_axis:
                    y 坐标轴数据。需为类目轴,也就是不能是数值。
                :param data:
                    数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。
        :param kwargs:
        """
        _is_calendar = kwargs.get('is_calendar_heatmap', None) is True
        if _is_calendar:
            name, data = args
        else:
            name, x_axis, y_axis, data = args

        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "heatmap",
            "name": name,
            "data": data,
            "label": chart['label'],
            "seriesId": self._option.get('series_id'),
        })

        if _is_calendar:
            self._option.get('toolbox').update(
                left="98%", top="26%")
            self._option.get('series')[0].update(coordinateSystem='calendar')
            self._option.update(calendar=chart['calendar'])
        else:
            xaxis, yaxis = chart['xy_axis']
            self._option.update(xAxis=xaxis, yAxis=yaxis)
            self._option.get('xAxis')[0].update(
                type='category', data=x_axis, splitArea={"show": True})
            self._option.get('yAxis')[0].update(
                type='category', data=y_axis, splitArea={"show": True})

        self._config_components(**kwargs)
Esempio n. 45
0
    def __add(self, name, attr, value,
              maptype="china",
              is_roam=True,
              is_map_symbol_show=True,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param attr:
            属性名称。
        :param value:
            属性所对应的值。
        :param maptype:
            地图类型。 支持 china、world、安徽、澳门、北京、重庆、福建、福建、甘肃、广东,
            广西、广州、海南、河北、黑龙江、河南、湖北、湖南、江苏、江西、吉林、辽宁、
            内蒙古、宁夏、青海、山东、上海、陕西、山西、四川、台湾、天津、香港、新疆、
            西藏、云南、浙江,以及 [363个二线城市地图](https://github.com/chfw/echarts-
            china-cities-js#featuring-citiesor-for-single-download)。
            提醒:
                在画市级地图的时候,城市名字后面的‘市’要省去了,比如,石家庄市的‘市’不要提,
                即‘石家庄’就可以了。地图提供了自定义模式 [用户如何自定义地图](https://github.com/
                chenjiandongx/pyecharts/blob/master/docs/zh-cn/user-customize-map.md)
        :param is_roam:
            是否开启鼠标缩放和平移漫游。默认为 True
            如果只想要开启缩放或者平移,可以设置成'scale'或者'move'。设置成 True 为都开启。
        :param is_map_symbol_show:
            是否显示地图标记红点,默认为 True。
        :param kwargs:
        """
        assert len(attr) == len(value)
        chart = get_all_options(**kwargs)
        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "map",
            "name": name,
            "symbol": chart['symbol'],
            "label": chart['label'],
            "mapType": maptype,
            "data": _data,
            "roam": is_roam,
            "showLegendSymbol": is_map_symbol_show
        })
        self._add_chinese_map(maptype)
        self._config_components(**kwargs)
Esempio n. 46
0
    def __add(self, name, x_axis, y_axis, data,
              grid3D_opacity=1,
              grid3D_shading='color',
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            xAxis data
        :param y_axis:
            yAxis data
        :param data:
            zAxis data
        :param grid3D_opacity:
            opacity of gird3D item
        :param grid3D_shading:
            3D graphics coloring effect
            'color': Only show color, not affected by lighting and other factors.
            'lambert': Through the classic lambert coloring to show the light and shade.
            'realistic': Realistic rendering.
        :param kwargs:
        :return:
        """
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)
        self._option.update(
            xAxis3D={
                "type": 'category',
                "data": x_axis
            },
            yAxis3D={
                "type": "category",
                "data": y_axis
            },
            zAxis3D={"type": "value"},
            grid3D=chart['grid3D']
        )
        self._option.get('series').append({
            "type": "bar3D",
            "name": name,
            "data": data,
            "label": chart['label'],
            "shading": grid3D_shading,
            "itemStyle": {"opacity": grid3D_opacity}
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 47
0
    def _legend_visualmap_colorlst(self, is_visualmap=False, **kwargs):
        """ config legend,visualmap and colorlst component.

        :param is_visualmap:
            It specifies whether to use the viusalmap component.
        :param kwargs:
        """
        kwargs.update(colorlst=self._colorlst)
        chart = get_all_options(**kwargs)
        if is_visualmap:
            self._option.update(visualMap=chart['visual_map'])
        self._option.get('legend')[0].update(chart['legend'])
        if chart['grid']:
            self._option.get('grid').append(chart['grid'])
        self._option.update(color=chart['color'])
        if kwargs.get('is_datazoom_show', None) is True:
            self._option.update(dataZoom=chart['datazoom'])
Esempio n. 48
0
    def config(self, schema=None,
               c_schema=None,
               shape="",
               radar_text_color="#333",
               radar_text_size=12,
               **kwargs):
        """ config rader component options

        :param schema:
            默认雷达图的指示器,用来指定雷达图中的多个维度,会对数据处理成。
            {name:xx, value:xx} 的字典
        :param c_schema:
            用户自定义雷达图的指示器,用来指定雷达图中的多个维度
                name: 指示器名称
                min: 指示器最小值
                max: 指示器最大值
        :param shape:
            雷达图绘制类型,有'polygon'(多边形)和'circle'可选。
        :param radar_text_color:
            雷达图数据项字体颜色,默认为'#000'。
        :param radar_text_size:
            雷达图m数据项字体大小,默认为 12。
        :param kwargs:
        """
        chart = get_all_options(**kwargs)
        indicator = []
        if schema:
            for s in schema:
                _name, _max = s
                indicator.append({"name": _name, "max": _max})
        if c_schema:
            indicator = c_schema
        self._option.update(
            radar={
                "indicator": indicator,
                "shape": shape,
                "name": {
                    "textStyle": {
                        "color": radar_text_color,
                        "fontSize": radar_text_size,
                    }},
                "splitLine": chart['split_line'],
                "splitArea": chart['split_area'],
                "axisLine": chart['axis_line']}
        )
Esempio n. 49
0
    def __add(self, name, x_axis, y_axis,
              is_stack=False,
              bar_category_gap="20%",
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param x_axis:
            x 坐标轴数据。
        :param y_axis:
            y 坐标轴数据。
        :param is_stack:
            数据堆叠,同个类目轴上系列配置相同的 stack 值可以堆叠放置。默认为 False。
        :param kwargs:
        """
        assert len(x_axis) == len(y_axis)
        kwargs.update(x_axis=x_axis)
        chart = get_all_options(**kwargs)

        if is_stack:
            is_stack = "stack_" + str(self._option['series_id'])
        else:
            is_stack = ""
        xaxis, yaxis = chart['xy_axis']
        self._option.update(xAxis=xaxis, yAxis=yaxis)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "bar",
            "name": name,
            "data": y_axis,
            "stack": is_stack,
            "barCategoryGap": bar_category_gap,
            "label": chart['label'],
            "markPoint": chart['mark_point'],
            "markLine": chart['mark_line'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 50
0
    def __add(self, name, attr, value,
              is_roam=True,
              maptype='china',
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param attr:
            name of attribute
        :param value:
            value of attribute
        :param is_roam:
            Whether to enable mouse zooming and translating. false by default.
            If either zooming or translating is wanted,
            it can be set to 'scale' or 'move'. Otherwise, set it to be true to enable both.
        :param maptype:
            type of map, it supports
            china、world、安徽、澳门、北京、重庆、福建、福建、甘肃、广东,广西、广州、海南、河北、黑龙江、河南、湖北、湖南、
            江苏、江西、吉林、辽宁、内蒙古、宁夏、青海、山东、上海、陕西、四川、台湾、天津、香港、新疆、西藏、云南、浙江
        :param kwargs:
        """
        chart = get_all_options(**kwargs)
        assert len(attr) == len(value)
        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "map",
            "name": name,
            "symbol": chart['symbol'],
            "mapType": maptype,
            "data": _data,
            "roam": is_roam
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 51
0
    def __add(self, name, nodes, links,
              sankey_node_width=20,
              sankey_node_gap=8,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param nodes:
            桑基图结点,必须包含的数据项有:
                name:数据项名称
                value:数据项数值
        :param links:
            桑基图结点关系
                source:边的源节点名称(必须有!)
                target:边的目标节点名称(必须有!)
                value:边的数值,决定边的宽度。
        :param sankey_node_width:
            图中每个矩形节点的宽度。默认为 20。
        :param sankey_node_gap:
            图中每一列任意两个矩形节点之间的间隔。默认为 8。
        :param kwargs:
        """
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)

        self._option.get('series').append({
            "type": "sankey",
            "name": name,
            "layout": None,
            "data": nodes,
            "links": links,
            "nodeWidth": sankey_node_width,
            "nodeGap": sankey_node_gap,
            "label": chart['label'],
            "lineStyle": chart['line_style'],
        })
        self._config_components(**kwargs)
Esempio n. 52
0
    def config(self, schema=None,
               c_schema=None,
               shape="",
               rader_text_color="#000",
               **kwargs):
        """ config rader component options

        :param schema:
            The default radar map indicator, used to specify multiple dimensions in the radar map,
            will process the data into a dictionary of {name: xx, value: xx}
        :param c_schema:
            Indicator of radar chart, which is used to assign multiple variables(dimensions) in radar chart.
            name: Indicator's name.
            min: The maximum value of indicator. It is an optional configuration, but we recommend to set it manually.
            max: The maximum value of indicator. It is an optional configuration, but we recommend to set it manually.
        :param shape:
            Radar render type, in which 'polygon' and 'circle' are supported.
        :param rader_text_color:
            Radar chart data item font color
        :param kwargs:
        """
        chart = get_all_options(**kwargs)
        indicator = []
        if schema:
            for s in schema:
                _name, _max = s
                indicator.append({"name": _name, "max": _max})
        if c_schema:
            indicator = c_schema
        self._option.update(
            radar={
                "indicator": indicator,
                "shape": shape,
                "name": {"textStyle": {"color": rader_text_color}},
                "splitLine": chart['split_line'],
                "splitArea": chart['split_area'],
                "axisLine": chart['axis_line']}
        )
Esempio n. 53
0
    def __add(self, name, x_axis, y_axis, data, **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param x_axis:
            data of xAxis, it must be catagory axis.
        :param y_axis:
            data of yAxis, it must be catagory axis.
        :param data:
            data array of series, it is represented by a two-dimension array -> [[],[]]
        :param kwargs:
        :return:
        """
        chart = get_all_options(**kwargs)
        self._option.get('legend')[0].get('data').append(name)
        self._option.update(
            xAxis=[{
                "type": "category",
                "data": x_axis,
                "splitArea": {"show": True},
            }],
            yAxis=[{
                "type": "category",
                "data": y_axis,
                "splitArea": {"show": True}
            }])
        self._option.get('series').append({
            "type": "heatmap",
            "name": name,
            "data": data,
            "label": chart['label'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 54
0
    def __add(self, name, attr, value,
              type="scatter",
              maptype='china',
              symbol_size=12,
              border_color="#111",
              geo_normal_color="#323c48",
              geo_emphasis_color="#2a333d",
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param attr:
            name of attribute
        :param value:
            value of attribute
        :param type:
            chart type, it can be 'scatter', 'effectscatter', 'heatmap'
        :param maptype:
            type of map, it only supports 'china' temporarily.
        :param symbol_size:
            symbol size
        :param border_color:
            color of map border
        :param geo_normal_color:
            The color of the map area in normal state
        :param geo_emphasis_color:
            The color of the map area in emphasis state
        :param kwargs:
        """
        if isinstance(attr, list) and isinstance(value, list):
            assert len(attr) == len(value)
            chart = get_all_options(**kwargs)
            _data = []
            for data in zip(attr, value):
                _name, _value = data
                if _name in self._geo_cities:
                    _v = self._geo_cities.get(_name)
                    _v.append(_value)
                    _value = list(_v)
                _data.append({"name": _name, "value": _value})
            self._option.update(
                geo={
                    "map": maptype,
                    "label": {},
                    "itemStyle": {"normal": {
                        "areaColor": geo_normal_color,
                        "borderColor": border_color},
                        "emphasis":{"areaColor": geo_emphasis_color}}
                })
            self._option.get('legend')[0].get('data').append(name)
            if type == "scatter":
                self._option.get('series').append({
                    "type": type,
                    "name": name,
                    "coordinateSystem": 'geo',
                    "symbol": chart['symbol'],
                    "symbolSize": symbol_size,
                    "data": _data,
                    "label": chart['label'],
                })
            elif type == "effectScatter":
                self._option.get('series').append({
                    "type": type,
                    "name": name,
                    "coordinateSystem": 'geo',
                    "showEffectOn": "render",
                    "rippleEffect": chart['effect'],
                    "symbol": chart['symbol'],
                    "symbolSize": symbol_size,
                    "data": _data,
                    "label": chart['label'],
                })
            elif type == "heatmap":
                self._option.get('series').append({
                    "type": type,
                    "name": name,
                    "coordinateSystem": 'geo',
                    "data": _data,
                })
            self._legend_visualmap_colorlst(**kwargs)
        else:
            raise TypeError("attr and value must be list")
Esempio n. 55
0
    def __add(self, name, attr, value,
              radius=None,
              center=None,
              rosetype=None,
              **kwargs):
        """

        :param name:
            Series name used for displaying in tooltip and filtering with legend,
            or updaing data and configuration with setOption.
        :param attr:
            name of attribute
        :param value:
            value of attribute
        :param radius:
            Radius of Pie chart, the first of which is inner radius, and the second is outer radius.
            Percentage is supported. When set in percentage,
            it's relative to the smaller size between height and width of the container.
        :param center:
            Center position of Pie chart, the first of which is the horizontal position,
            and the second is the vertical position.
            Percentage is supported. When set in percentage, the item is relative to the container width,
            and the second item to the height.
        :param rosetype:
            Whether to show as Nightingale chart, which distinguishs data through radius. There are 2 optional modes:
            'radius' Use central angle to show the percentage of data, radius to show data size.
            'area' All the sectors will share the same central angle, the data size is shown only through radiuses.
        :param kwargs:
        """
        kwargs.update(type="pie")
        chart = get_all_options(**kwargs)
        assert len(attr) == len(value)
        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})

        _rmin, _rmax = "0%", "75%"
        if radius:
            if len(radius) == 2:
                _rmin, _rmax = ["{}%".format(r) for r in radius]

        _cmin, _cmax = "50%", "50%"
        if center:
            if len(center) == 2:
                _cmin, _cmax = ["{}%".format(c) for c in center]

        if rosetype:
            if rosetype not in ("radius", "area"):
                rosetype = "radius"
        for a in attr:
            self._option.get('legend')[0].get('data').append(a)
        _dlst = self._option.get('legend')[0].get('data')
        _dset = list(set(_dlst))
        _dset.sort(key=_dlst.index)
        self._option.get('legend')[0].update(data=list(_dset))
        self._option.get('series').append({
            "type": "pie",
            "name": name,
            "data": _data,
            "radius": [_rmin, _rmax],
            "center": [_cmin, _cmax],
            "roseType": rosetype,
            "label": chart['label'],
            "indexflag": self._option.get('_index_flag')
        })
        self._legend_visualmap_colorlst(**kwargs)
Esempio n. 56
0
    def __add(self, name, data,
              maptype='china',
              symbol=None,
              symbol_size=12,
              border_color="#111",
              geo_normal_color="#323c48",
              geo_emphasis_color="#2a333d",
              geo_cities_coords=None,
              geo_effect_period=6,
              geo_effect_traillength=0,
              geo_effect_color='#fff',
              geo_effect_symbol='circle',
              geo_effect_symbolsize=5,
              is_geo_effect_show=True,
              is_roam=True,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param data:
            数据项,数据中,每一行是一个『数据项』,每一列属于一个『维度』。每一行包含两个数据,
            如 ["广州", "北京"],则指定从广州到北京。
        :param maptype:
            地图类型。 支持 china、world、安徽、澳门、北京、重庆、福建、福建、甘肃、
            广东,广西、广州、海南、河北、黑龙江、河南、湖北、湖南、江苏、江西、吉林、
            辽宁、内蒙古、宁夏、青海、山东、上海、陕西、山西、四川、台湾、天津、香港、
            新疆、西藏、云南、浙江,以及 [363个二线城市](https://github.com/chfw/
            echarts-china-cities-js#featuring-citiesor-for-single-download]地图。
            提醒:
                在画市级地图的时候,城市名字后面的‘市’要省去了,比如,石家庄市的
                ‘市’不要提,即‘石家庄’就可以了。
        :param symbol:
            线两端的标记类型,可以是一个数组分别指定两端,也可以是单个统一指定。
        :param symbol_size:
            线两端的标记大小,可以是一个数组分别指定两端,也可以是单个统一指定。
        :param border_color:
            地图边界颜色。
        :param geo_normal_color:
            正常状态下地图区域的颜色。
        :param geo_emphasis_color:
            高亮状态下地图区域的颜色。
        :param geo_cities_coords:
            用户自定义地区经纬度,类似如 {'阿城': [126.58, 45.32],} 这样的字典,当用
            于提供了该参数时,将会覆盖原有预存的区域坐标信息。
        :param geo_effect_period:
            特效动画的时间,单位为 s。
        :param geo_effect_traillength:
            特效尾迹的长度。取从 0 到 1 的值,数值越大尾迹越长。
        :param geo_effect_color:
            特效标记的颜色。
        :param geo_effect_symbol:
            特效图形的标记。有 'circle', 'rect', 'roundRect', 'triangle', 'diamond',
            'pin', 'arrow', 'plane' 可选。
        :param geo_effect_symbolsize:
            特效标记的大小,可以设置成诸如 10 这样单一的数字,也可以用数组分开表示高和宽,
            例如 [20, 10] 表示标记宽为20,高为 10。
        :param is_geo_effect_show:
            是否显示特效。
        :param is_roam:
            是否开启鼠标缩放和平移漫游。默认为 True。
            如果只想要开启缩放或者平移,可以设置成'scale'或者'move'。设置成 True 为都开启。
        :param kwargs:
        """

        chart = get_all_options(**kwargs)
        self._zlevel += 1
        if geo_cities_coords:
            _geo_cities_coords = geo_cities_coords
        else:
            _geo_cities_coords = CITY_GEO_COORDS

        if geo_effect_symbol == "plane":
            geo_effect_symbol = SYMBOL['plane']

        _data_lines, _data_scatter = [], []
        for d in data:
            _from_name, _to_name = d
            _data_lines.append({
                "fromName": _from_name,
                "toName": _to_name,
                "coords": [
                    _geo_cities_coords.get(_from_name, []),
                    _geo_cities_coords.get(_to_name, [])
                ]
            })
            _from_v = _geo_cities_coords.get(_from_name, [])
            _data_scatter.append({
                "name": _from_name,
                "value": _from_v + [0]
            })
            _to_v = _geo_cities_coords.get(_to_name, [])
            _data_scatter.append({
                "name": _to_name,
                "value": _to_v + [0]
            })

        self._option.update(
            geo={
                "map": maptype,
                "roam": is_roam,
                "label": {
                    "emphasis": {
                        "show": True,
                        "textStyle": {
                            "color": "#eee"
                        }
                    }},
                "itemStyle": {
                    "normal": {
                        "areaColor": geo_normal_color,
                        "borderColor": border_color
                    },
                    "emphasis": {
                        "areaColor": geo_emphasis_color
                    }}
            })
        self._option.get('legend')[0].get('data').append(name)
        self._option.get('series').append({
            "type": "lines",
            "name": name,
            "zlevel": self._zlevel,
            "effect": {
                "show": is_geo_effect_show,
                "period": geo_effect_period,
                "trailLength": geo_effect_traillength,
                "color": geo_effect_color,
                "symbol": geo_effect_symbol,
                "symbolSize": geo_effect_symbolsize
            },
            "symbol": symbol or ["none", "arrow"],
            "symbolSize": symbol_size,
            "data": _data_lines,
            "lineStyle": chart['line_style']
        })
        self._option.get('series').append({
            "type": "scatter",
            "name": name,
            "zlevel": self._zlevel,
            "coordinateSystem": 'geo',
            "symbolSize": 10,
            "data": _data_scatter,
            "label": chart['label'],
        })

        self._add_chinese_map(maptype)
        self._config_components(**kwargs)
Esempio n. 57
0
    def __add(self, name, attr, value,
              radius=None,
              center=None,
              rosetype=None,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param attr:
            属性名称。
        :param value:
            属性所对应的值。
        :param radius:
            饼图的半径,数组的第一项是内半径,第二项是外半径,默认为 [0, 75]
            默认设置成百分比,相对于容器高宽中较小的一项的一半。
        :param center:
            饼图的中心(圆心)坐标,数组的第一项是横坐标,第二项是纵坐标,默认为 [50, 50]
            默认设置成百分比,设置成百分比时第一项是相对于容器宽度,第二项是相对于容器高度。
        :param rosetype:
           是否展示成南丁格尔图,通过半径区分数据大小,有'radius'和'area'两种模式。
           默认为'radius'
                radius:扇区圆心角展现数据的百分比,半径展现数据的大小。
                area:所有扇区圆心角相同,仅通过半径展现数据大小。
        :param kwargs:
        """
        kwargs.update(type="pie")
        chart = get_all_options(**kwargs)
        assert len(attr) == len(value)
        _data = []
        for data in zip(attr, value):
            _name, _value = data
            _data.append({"name": _name, "value": _value})

        _rmin, _rmax = "0%", "75%"
        if radius:
            if len(radius) == 2:
                _rmin, _rmax = ["{}%".format(r) for r in radius]

        _cmin, _cmax = "50%", "50%"
        if center:
            if len(center) == 2:
                _cmin, _cmax = ["{}%".format(c) for c in center]

        if rosetype:
            if rosetype not in ("radius", "area"):
                rosetype = "radius"

        for a in attr:
            self._option.get('legend')[0].get('data').append(a)

        _dlst = self._option.get('legend')[0].get('data')
        _dset = list(set(_dlst))
        _dset.sort(key=_dlst.index)
        self._option.get('legend')[0].update(data=list(_dset))

        self._option.get('series').append({
            "type": "pie",
            "name": name,
            "data": _data,
            "radius": [_rmin, _rmax],
            "center": [_cmin, _cmax],
            "roseType": rosetype,
            "label": chart['label'],
            "seriesId": self._option.get('series_id'),
        })
        self._config_components(**kwargs)
Esempio n. 58
0
    def __add(self, name, attr, value,
              type="scatter",
              maptype='china',
              symbol_size=12,
              border_color="#111",
              geo_normal_color="#323c48",
              geo_emphasis_color="#2a333d",
              geo_cities_coords=None,
              is_roam=True,
              **kwargs):
        """

        :param name:
            系列名称,用于 tooltip 的显示,legend 的图例筛选。
        :param attr:
            属性名称。
        :param value:
            属性所对应的值。
        :param type:
            图例类型,有'scatter', 'effectscatter', 'heatmap'可选。
        :param maptype:
            地图类型。 支持 china、world、安徽、澳门、北京、重庆、福建、福建、甘肃、
            广东,广西、广州、海南、河北、黑龙江、河南、湖北、湖南、江苏、江西、吉林、
            辽宁、内蒙古、宁夏、青海、山东、上海、陕西、山西、四川、台湾、天津、香港、
            新疆、西藏、云南、浙江,以及 [363个二线城市](https://github.com/chfw/
            echarts-china-cities-js#featuring-citiesor-for-single-download]地图。
            提醒:
                在画市级地图的时候,城市名字后面的‘市’要省去了,比如,石家庄市的
                ‘市’不要提,即‘石家庄’就可以了。
        :param symbol_size:
            标记图形大小。
        :param border_color:
            地图边界颜色。
        :param geo_normal_color:
            正常状态下地图区域的颜色。
        :param geo_emphasis_color:
            高亮状态下地图区域的颜色。
        :param geo_cities_coords:
            用户自定义地区经纬度,类似如 {'阿城': [126.58, 45.32],} 这样的字典,当用
            于提供了该参数时,将会覆盖原有预存的区域坐标信息。
        :param is_roam:
            是否开启鼠标缩放和平移漫游。默认为 True。
            如果只想要开启缩放或者平移,可以设置成'scale'或者'move'。设置成 True 为都开启。
        :param kwargs:
        """
        assert len(attr) == len(value)
        kwargs.update(type="geo")
        chart = get_all_options(**kwargs)

        if geo_cities_coords:
            _geo_cities_coords = geo_cities_coords
        else:
            _geo_cities_coords = CITY_GEO_COORDS

        _data = []
        for _name, _value in zip(attr, value):
            if _name in _geo_cities_coords:
                city_coordinate = _geo_cities_coords.get(_name)
                city_coordinate.append(_value)
                _data.append({"name": _name, "value": city_coordinate})
            else:
                print("%s coordinates is not found" % _name)
        self._option.update(
            geo={
                "map": maptype,
                "roam": is_roam,
                "label": {
                    "emphasis": {
                        "show": True,
                        "textStyle": {
                            "color": "#eee"
                        }
                    }},
                "itemStyle": {
                    "normal": {
                        "areaColor": geo_normal_color,
                        "borderColor": border_color
                    },
                    "emphasis": {
                        "areaColor": geo_emphasis_color
                    }}
            })
        self._option.get('legend')[0].get('data').append(name)

        if type == "scatter":
            self._option.get('series').append({
                "type": type,
                "name": name,
                "coordinateSystem": 'geo',
                "symbol": chart['symbol'],
                "symbolSize": symbol_size,
                "data": _data,
                "label": chart['label'],
            })

        elif type == "effectScatter":
            self._option.get('series').append({
                "type": type,
                "name": name,
                "coordinateSystem": 'geo',
                "showEffectOn": "render",
                "rippleEffect": chart['effect'],
                "symbol": chart['symbol'],
                "symbolSize": symbol_size,
                "data": _data,
                "label": chart['label'],
            })

        elif type == "heatmap":
            self._option.get('series').append({
                "type": type,
                "name": name,
                "coordinateSystem": 'geo',
                "data": _data,
            })

        self._add_chinese_map(maptype)
        self._config_components(**kwargs)