def add(self, chart, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ :param chart: chart instance :param grid_width: Width of grid component. Adaptive by default. :param grid_height: Height of grid component. Adaptive by default. :param grid_top: Distance between grid component and the top side of the container. :param grid_bottom: Distance between grid component and the bottom side of the container. :param grid_left: Distance between grid component and the left side of the container. :param grid_right: Distance between grid component and the right side of the container. :return: """ if self._chart is None: self._chart = chart self._chart._option.update(grid=[]) _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) if _grid: for _ in range(len(self._chart._option.get('series'))): self._chart._option.get('grid').append(_grid) else: _index, _index_once, _xaxis, _yaxis, _legned, _title = self.__custom(self.__get_series(chart)) self._chart._option.get('legend').append(_legned) self._chart._option.get('title').append(_title) if _xaxis and _yaxis is not None: try: _xaxis[0].update(gridIndex=_index - 1) _yaxis[0].update(gridIndex=_index - 1) self._chart._option.get('xAxis').append(_xaxis[0]) self._chart._option.get('yAxis').append(_yaxis[0]) except: pass # indexflag is only identify for every series _flag = self._chart._option.get('series')[0].get('indexflag') _series_index = 0 for s in self._chart._option.get('series'): if _flag == s.get('indexflag'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('indexflag') _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._chart._option.get('grid').append(_grid)
def grid(self, series, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ 并行显示图表 :param series: 追加图表类型的 series 数据 :param grid_width: grid 组件的宽度。默认自适应。 :param grid_height: grid 组件的高度。默认自适应。 :param grid_top: grid 组件离容器顶部的距离。 :param grid_bottom: grid 组件离容器底部的距离。 :param grid_left: grid 组件离容器左侧的距离。 :param grid_right: grid 组件离容器右侧的距离。 :return: """ from pyecharts.option import grid _index, _index_once, _xaxis, _yaxis, _legned, _title = self.__custom_for_grid(series) self._option.get('legend').append(_legned) self._option.get('title').append(_title) if _xaxis and _yaxis is not None: try: _xaxis[0].update(gridIndex=_index - 1) _yaxis[0].update(gridIndex=_index - 1) self._option.get('xAxis').append(_xaxis[0]) self._option.get('yAxis').append(_yaxis[0]) except: pass # indexflag 为每个图例唯一标识 _flag = self._option.get('series')[0].get('indexflag') _series_index = 0 for s in self._option.get('series'): if _flag == s.get('indexflag'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('indexflag') _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._option.get('grid').append(_grid)
def grid(self, series, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ Concurrently show charts :param series: append other chart series data :param grid_width: Width of grid component. Adaptive by default. :param grid_height: Height of grid component. Adaptive by default. :param grid_top: Distance between grid component and the top side of the container. grid_top value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'; and it can also be 'top', 'middle', or 'bottom'. If the grid_top value is set to be 'top', 'middle', or 'bottom', then the component will be aligned automatically based on position. :param grid_bottom: Distance between grid component and the bottom side of the container. grid_bottom value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'. :param grid_left: Distance between grid component and the left side of the container. grid_left value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'; and it can also be 'left', 'center', or 'right'. If the grid_left value is set to be 'left', 'center', or 'right', then the component will be aligned automatically based on position. :param grid_right: Distance between grid component and the right side of the container. grid_right value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'. :return: """ from pyecharts.option import grid _index, _index_once, _xaxis, _yaxis, _legned, _title = self.__custom_for_grid( series) self._option.get('legend').append(_legned) self._option.get('title').append(_title) if _xaxis and _yaxis is not None: try: _xaxis[0].update(gridIndex=_index - 1) _yaxis[0].update(gridIndex=_index - 1) self._option.get('xAxis').append(_xaxis[0]) self._option.get('yAxis').append(_yaxis[0]) except: pass # indexflag is only identify for every series _flag = self._option.get('series')[0].get('indexflag') _series_index = 0 for s in self._option.get('series'): if _flag == s.get('indexflag'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('indexflag') _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._option.get('grid').append(_grid)
def grid(self, series, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ Concurrently show charts :param series: append other chart series data :param grid_width: Width of grid component. Adaptive by default. :param grid_height: Height of grid component. Adaptive by default. :param grid_top: Distance between grid component and the top side of the container. grid_top value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'; and it can also be 'top', 'middle', or 'bottom'. If the grid_top value is set to be 'top', 'middle', or 'bottom', then the component will be aligned automatically based on position. :param grid_bottom: Distance between grid component and the bottom side of the container. grid_bottom value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'. :param grid_left: Distance between grid component and the left side of the container. grid_left value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'; and it can also be 'left', 'center', or 'right'. If the grid_left value is set to be 'left', 'center', or 'right', then the component will be aligned automatically based on position. :param grid_right: Distance between grid component and the right side of the container. grid_right value can be instant pixel value like 20; it can also be percentage value relative to container width like '20%'. :return: """ from pyecharts.option import grid _index, _index_once, _xaxis, _yaxis, _legned, _title = self.__custom_for_grid(series) self._option.get('legend').append(_legned) self._option.get('title').append(_title) if _xaxis and _yaxis is not None: try: _xaxis[0].update(gridIndex=_index - 1) _yaxis[0].update(gridIndex=_index - 1) self._option.get('xAxis').append(_xaxis[0]) self._option.get('yAxis').append(_yaxis[0]) except: pass # indexflag is only identify for every series _flag = self._option.get('series')[0].get('indexflag') _series_index = 0 for s in self._option.get('series'): if _flag == s.get('indexflag'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('indexflag') _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._option.get('grid').append(_grid)
def add(self, chart, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ :param chart: 图形实例 :param grid_width: grid 组件的宽度。默认自适应。 :param grid_height: grid 组件的高度。默认自适应。 :param grid_top: grid 组件离容器顶部的距离。默认为 None, 有'top', 'center', 'middle'可选,也可以为百分数或者整数 :param grid_bottom: grid 组件离容器底部的距离。默认为 None, 有'top', 'center', 'middle'可选,也可以为百分数或者整数 :param grid_left: grid 组件离容器左侧的距离。默认为 None, 有'left', 'center', 'right'可选,也可以为百分数或者整数 :param grid_right: grid 组件离容器右侧的距离。默认为 None, 有'left', 'center', 'right'可选,也可以为百分数或者整数 """ if not self._option: self._option = copy.deepcopy(chart.options) self._option.update(grid=[]) self._js_dependencies = chart.js_dependencies _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) if _grid: for _ in range(len(self._option.get('series'))): self._option.get('grid').append(_grid) else: _series = (chart.options.get('series'), chart.options.get('xAxis', None), chart.options.get('yAxis', None), chart.options.get('legend')[0], chart.options.get('title')[0]) (_index, _index_once, _xaxis, _yaxis, _legend, _title) = self.__custom(_series) self._option.get('legend').append(_legend) self._option.get('title').append(_title) if _xaxis and _yaxis is not None: for _x in _xaxis: _x.update(gridIndex=_index - 1) self._option.get('xAxis').append(_x) for _y in _yaxis: _y.update(gridIndex=_index - 1) self._option.get('yAxis').append(_y) # series id 是每个图实例的唯一标识 _flag = self._option.get('series')[0].get('seriesId') _series_index = 0 for s in self._option.get('series'): if _flag == s.get('seriesId'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('seriesId') _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._option.get('grid').append(_grid) self._js_dependencies = self._js_dependencies.union( chart.js_dependencies)
def add(self, chart, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ :param chart: chart instance :param grid_width: Width of grid component. Adaptive by default. :param grid_height: Height of grid component. Adaptive by default. :param grid_top: Distance between grid component and the top side of the container. :param grid_bottom: Distance between grid component and the bottom side of the container. :param grid_left: Distance between grid component and the left side of the container. :param grid_right: Distance between grid component and the right side of the container. :return: """ if self._chart is None: self._chart = chart self._chart._option.update(grid=[]) self._js_dependencies = chart._js_dependencies _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) if _grid: for _ in range(len(self._chart._option.get('series'))): self._chart._option.get('grid').append(_grid) else: _series = (chart._option.get('series'), chart._option.get('xAxis', None), chart._option.get('yAxis', None), chart._option.get('legend')[0], chart._option.get('title')[0]) _index, _index_once, _xaxis, _yaxis, _legend, _title = self.__custom( _series) self._chart._option.get('legend').append(_legend) self._chart._option.get('title').append(_title) if _xaxis and _yaxis is not None: for _x in _xaxis: _x.update(gridIndex=_index - 1) self._chart._option.get('xAxis').append(_x) for _y in _yaxis: _y.update(gridIndex=_index - 1) self._chart._option.get('yAxis').append(_y) # series id is the only identify for every series _flag = self._chart._option.get('series')[0].get('seriesId') _series_index = 0 for s in self._chart._option.get('series'): if _flag == s.get('seriesId'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('seriesId') _grid = grid(grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._chart._option.get('grid').append(_grid) self._js_dependencies = self._js_dependencies.union( chart._js_dependencies)
def add(self, chart, grid_width=None, grid_height=None, grid_top=None, grid_bottom=None, grid_left=None, grid_right=None): """ :param chart: 图形实例 :param grid_width: grid 组件的宽度。默认自适应。 :param grid_height: grid 组件的高度。默认自适应。 :param grid_top: grid 组件离容器顶部的距离。默认为 None, 有'top', 'center', 'middle'可选,也可以为百分数或者整数 :param grid_bottom: grid 组件离容器底部的距离。默认为 None, 有'top', 'center', 'middle'可选,也可以为百分数或者整数 :param grid_left: grid 组件离容器左侧的距离。默认为 None, 有'left', 'center', 'right'可选,也可以为百分数或者整数 :param grid_right: grid 组件离容器右侧的距离。默认为 None, 有'left', 'center', 'right'可选,也可以为百分数或者整数 """ if not self._option: self._option = copy.deepcopy(chart.options) self._option.update(grid=[]) self._js_dependencies = chart.js_dependencies _grid = grid( grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) if _grid: for _ in range(len(self._option.get('series'))): self._option.get('grid').append(_grid) else: _series = ( chart.options.get('series'), chart.options.get('xAxis', None), chart.options.get('yAxis', None), chart.options.get('legend')[0], chart.options.get('title')[0] ) (_index, _index_once, _xaxis, _yaxis, _legend, _title) = self.__custom(_series) self._option.get('legend').append(_legend) self._option.get('title').append(_title) if _xaxis and _yaxis is not None: for _x in _xaxis: _x.update(gridIndex=_index - 1) self._option.get('xAxis').append(_x) for _y in _yaxis: _y.update(gridIndex=_index - 1) self._option.get('yAxis').append(_y) # series id 是每个图实例的唯一标识 _flag = self._option.get('series')[0].get('seriesId') _series_index = 0 for s in self._option.get('series'): if _flag == s.get('seriesId'): s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) else: _series_index += 1 s.update(xAxisIndex=_series_index, yAxisIndex=_series_index) _flag = s.get('seriesId') _grid = grid( grid_width, grid_height, grid_top, grid_bottom, grid_left, grid_right) for _ in range(_index_once): self._option.get('grid').append(_grid) self._js_dependencies = self._js_dependencies.union( chart.js_dependencies)