diff --git a/pyecharts/charts/__init__.py b/pyecharts/charts/__init__.py index 36426a85..42d20cfe 100644 --- a/pyecharts/charts/__init__.py +++ b/pyecharts/charts/__init__.py @@ -4,6 +4,7 @@ from ..charts.basic_charts.bar import Bar from ..charts.basic_charts.bmap import BMap from ..charts.basic_charts.boxplot import Boxplot from ..charts.basic_charts.calendar import Calendar +from ..charts.basic_charts.chord import Chord from ..charts.basic_charts.custom import Custom from ..charts.basic_charts.effectscatter import EffectScatter from ..charts.basic_charts.funnel import Funnel diff --git a/pyecharts/charts/basic_charts/bar.py b/pyecharts/charts/basic_charts/bar.py index 8ceb44b4..370be480 100644 --- a/pyecharts/charts/basic_charts/bar.py +++ b/pyecharts/charts/basic_charts/bar.py @@ -17,6 +17,9 @@ class Bar(RectChart): series_name: str, y_axis: types.Sequence[types.Union[types.Numeric, opts.BarItem, dict]], *, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, xaxis_index: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, polar_index: types.Optional[types.Numeric] = None, @@ -29,6 +32,7 @@ class Bar(RectChart): background_style: types.Union[types.BarBackground, dict, None] = None, stack: types.Optional[str] = None, stack_strategy: types.Optional[str] = "samesign", + stack_order: types.Optional[str] = None, sampling: types.Optional[str] = None, cursor: types.Optional[str] = "pointer", bar_width: types.Union[types.Numeric, str] = None, @@ -69,6 +73,9 @@ class Bar(RectChart): { "type": ChartType.BAR, "name": series_name, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "xAxisIndex": xaxis_index, "yAxisIndex": yaxis_index, "polarIndex": polar_index, @@ -81,6 +88,7 @@ class Bar(RectChart): "backgroundStyle": background_style, "stack": stack, "stackStrategy": stack_strategy, + "stackOrder": stack_order, "sampling": sampling, "cursor": cursor, "barWidth": bar_width, diff --git a/pyecharts/charts/basic_charts/boxplot.py b/pyecharts/charts/basic_charts/boxplot.py index f199ed74..5d52e181 100644 --- a/pyecharts/charts/basic_charts/boxplot.py +++ b/pyecharts/charts/basic_charts/boxplot.py @@ -21,8 +21,13 @@ class Boxplot(RectChart): ] = None, *, chart_type: str = ChartType.BOXPLOT, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, dataset_index: types.Optional[types.Numeric] = None, color_by: types.Optional[str] = None, is_legend_hover_link: bool = True, @@ -52,8 +57,13 @@ class Boxplot(RectChart): { "type": chart_type, "name": series_name, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, "datasetIndex": dataset_index, "colorBy": color_by, "legendHoverLink": is_legend_hover_link, diff --git a/pyecharts/charts/basic_charts/chord.py b/pyecharts/charts/basic_charts/chord.py new file mode 100644 index 00000000..bd45997d --- /dev/null +++ b/pyecharts/charts/basic_charts/chord.py @@ -0,0 +1,74 @@ +from ... import types +from ...charts.chart import Chart +from ...globals import ChartType + + +class Chord(Chart): + """ + <<< Chord >>> + + The chord diagram visually presents the flow and weights + within complex relationship networks, making it particularly + suitable for multidimensional relationship analysis in scenarios + such as financial transactions and social networks. + """ + + def add( + self, + series_name: str, + data: types.Sequence[types.ChordData], + links: types.Sequence[types.ChordLink], + *, + is_clockwise: bool = False, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + color_by: types.Optional[str] = None, + pos_left: types.Optional[str] = None, + pos_top: types.Optional[str] = None, + pos_right: types.Optional[str] = None, + pos_bottom: types.Optional[str] = None, + width: types.Optional[str] = None, + height: types.Optional[str] = None, + center: types.Optional[types.Sequence] = None, + radius: types.Optional[types.Union[types.Sequence, str]] = None, + start_angle: types.Numeric = 90, + end_angle: types.Optional[types.Numeric] = None, + min_angle: types.Optional[types.Numeric] = None, + pad_angle: types.Optional[types.Numeric] = None, + tooltip_opts: types.Tooltip = None, + label_opts: types.Label = None, + linestyle_opts: types.LineStyle = None, + itemstyle_opts: types.ItemStyle = None, + emphasis_opts: types.Emphasis = None, + ): + self.options.get("series").append({ + "type": ChartType.CHORD, + "name": series_name, + "data": data, + "links": links, + "clockwise": is_clockwise, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "colorBy": color_by, + "left": pos_left, + "top": pos_top, + "right": pos_right, + "bottom": pos_bottom, + "width": width, + "height": height, + "center": center, + "radius": radius, + "startAngle": start_angle, + "endAngle": end_angle, + "minAngle": min_angle, + "padAngle": pad_angle, + "tooltip": tooltip_opts, + "label": label_opts, + "lineStyle": linestyle_opts, + "itemStyle": itemstyle_opts, + "emphasis": emphasis_opts, + }) + + return self diff --git a/pyecharts/charts/basic_charts/custom.py b/pyecharts/charts/basic_charts/custom.py index d23fa7d7..6978a41f 100644 --- a/pyecharts/charts/basic_charts/custom.py +++ b/pyecharts/charts/basic_charts/custom.py @@ -12,19 +12,73 @@ class Custom(Chart): in the series. This enables the extension of different charts. """ + def register_echarts_x(self, chart_type: str): + if chart_type not in [ + ChartType.VIOLIN, + ChartType.STAGE, + ChartType.DOUGHNUT, + ChartType.CONTOUR, + ChartType.BAR_RANGE, + ChartType.LINE_RANGE, + ]: + raise ValueError(f"Not support register this chart type: {chart_type}") + + if chart_type == ChartType.VIOLIN: + self.js_dependencies.add("echarts-x-violin") + self.options.update(xAxis=[{}], yAxis=[{}]) + + if chart_type == ChartType.STAGE: + self.js_dependencies.add("echarts-x-stage") + self.options.update(xAxis=[{}], yAxis=[{}]) + + if chart_type == ChartType.DOUGHNUT: + self.js_dependencies.add("echarts-x-segmented-doughnut") + + if chart_type == ChartType.LINE_RANGE: + self.js_dependencies.add("echarts-x-line-range") + self.options.update(xAxis=[{}], yAxis=[{}]) + + if chart_type == ChartType.CONTOUR: + self.js_dependencies.add("echarts-x-contour-d3") + self.js_dependencies.add("echarts-x-contour") + self.options.update(xAxis=[{}], yAxis=[{}]) + + if chart_type == ChartType.BAR_RANGE: + self.js_dependencies.add("echarts-x-bar-range") + self.options.update(xAxis=[{}], yAxis=[{}]) + + return self + + def add_xaxis(self, xaxis_data: types.Sequence): + self.options["xAxis"][0].update(data=xaxis_data) + self._xaxis_data = xaxis_data + return self + def add( self, series_name: str, render_item: types.JSFunc, *, + type_: str = ChartType.CUSTOM, color_by: str = "series", is_legend_hover_link: bool = True, coordinate_system: str = "cartesian2d", + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, x_axis_index: types.Numeric = 0, + xaxis_id: types.Optional[types.Numeric] = None, y_axis_index: types.Numeric = 0, + yaxis_id: types.Optional[types.Numeric] = None, polar_index: types.Numeric = 0, + polar_id: types.Optional[types.Numeric] = None, + single_axis_index: types.Optional[types.Numeric] = None, + single_axis_id: types.Optional[types.Numeric] = None, geo_index: types.Numeric = 0, + geo_id: types.Optional[types.Numeric] = None, calendar_index: types.Numeric = 0, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, dataset_index: types.Numeric = 0, series_layout_by: str = "column", selected_mode: types.Union[bool, str] = False, @@ -36,23 +90,36 @@ class Custom(Chart): z: types.Numeric = 2, itemstyle_opts: types.ItemStyle = None, tooltip_opts: types.Tooltip = None, + label_opts: types.Label = None, emphasis_opts: types.Emphasis = None, + item_payload_opts: types.CustomItemPayload = None, ): self._append_legend(series_name) self.options.get("series").append( { - "type": ChartType.CUSTOM, + "type": type_, "name": series_name, "renderItem": render_item, "colorBy": color_by, "legendHoverLink": is_legend_hover_link, "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "xAxisIndex": x_axis_index, + "xAxisId": xaxis_id, "yAxisIndex": y_axis_index, + "yAxisId": yaxis_id, "polarIndex": polar_index, + "polarId": polar_id, + "singleAxisIndex": single_axis_index, + "singleAxisId": single_axis_id, "geoIndex": geo_index, + "geoId": geo_id, "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "datasetIndex": dataset_index, "seriesLayoutBy": series_layout_by, "itemStyle": itemstyle_opts, @@ -64,7 +131,9 @@ class Custom(Chart): "zlevel": z_level, "z": z, "tooltip": tooltip_opts, + "label": label_opts, "emphasis": emphasis_opts, + "itemPayload": item_payload_opts, } ) return self diff --git a/pyecharts/charts/basic_charts/effectscatter.py b/pyecharts/charts/basic_charts/effectscatter.py index 3ce1015a..5b57901a 100644 --- a/pyecharts/charts/basic_charts/effectscatter.py +++ b/pyecharts/charts/basic_charts/effectscatter.py @@ -17,16 +17,25 @@ class EffectScatter(RectChart): y_axis: types.Sequence[types.Union[opts.EffectScatterItem, dict]], *, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, polar_index: types.Optional[types.Numeric] = None, + polar_id: types.Optional[types.Numeric] = None, geo_index: types.Optional[types.Numeric] = None, + geo_id: types.Optional[types.Numeric] = None, calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, dataset_index: types.Optional[types.Numeric] = None, color: types.Optional[str] = None, color_by: types.Optional[str] = None, is_legend_hover_link: bool = True, show_effect_on: str = "render", coordinate_system: str = "cartesian2d", + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, symbol: types.Optional[str] = None, symbol_size: types.Numeric = 10, symbol_rotate: types.Optional[types.Numeric] = None, @@ -56,15 +65,24 @@ class EffectScatter(RectChart): "type": ChartType.EFFECT_SCATTER, "name": series_name, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, "polarIndex": polar_index, + "polarId": polar_id, "geoIndex": geo_index, + "geoId": geo_id, "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "colorBy": color_by, "legendHoverLink": is_legend_hover_link, "showEffectOn": show_effect_on, "rippleEffect": effect_opts, "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "datasetIndex": dataset_index, "symbol": symbol, "symbolSize": symbol_size, diff --git a/pyecharts/charts/basic_charts/funnel.py b/pyecharts/charts/basic_charts/funnel.py index 7dbf81cb..454cc225 100644 --- a/pyecharts/charts/basic_charts/funnel.py +++ b/pyecharts/charts/basic_charts/funnel.py @@ -22,6 +22,13 @@ class Funnel(Chart): *, color: types.Optional[str] = None, color_by: types.Optional[str] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, min_: types.Numeric = 0, max_: types.Numeric = 100, min_size: types.Union[str, types.Numeric] = "0%", @@ -69,6 +76,13 @@ class Funnel(Chart): "name": series_name, "data": data, "colorBy": color_by, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "min": min_, "max": max_, "minSize": min_size, diff --git a/pyecharts/charts/basic_charts/gauge.py b/pyecharts/charts/basic_charts/gauge.py index 40c3651a..581aa114 100644 --- a/pyecharts/charts/basic_charts/gauge.py +++ b/pyecharts/charts/basic_charts/gauge.py @@ -21,6 +21,13 @@ class Gauge(Chart): split_number: types.Numeric = 10, center: types.Sequence = None, radius: types.Union[types.Numeric, str] = "75%", + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, start_angle: types.Numeric = 225, end_angle: types.Numeric = -45, is_clock_wise: bool = True, @@ -56,6 +63,13 @@ class Gauge(Chart): "splitNumber": split_number, "center": center, "radius": radius, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "startAngle": start_angle, "endAngle": end_angle, "clockwise": is_clock_wise, diff --git a/pyecharts/charts/basic_charts/geo.py b/pyecharts/charts/basic_charts/geo.py index 8e3199b2..2f84e92a 100644 --- a/pyecharts/charts/basic_charts/geo.py +++ b/pyecharts/charts/basic_charts/geo.py @@ -268,7 +268,9 @@ class Geo(GeoChartBase): def add_schema( self, maptype: str = "china", + animation: types.Union[bool, str] = None, is_roam: bool = True, + roam_trigger: types.Optional[str] = None, zoom: types.Optional[types.Numeric] = None, center: types.Optional[types.Sequence] = None, aspect_scale: types.Numeric = 0.75, @@ -286,6 +288,21 @@ class Geo(GeoChartBase): regions_opts: types.Union[ types.Sequence[types.GeoRegions], types.Sequence[dict] ] = None, + is_preserve_aspect: bool = False, + preserve_aspect_align: types.Optional[str] = None, + preserve_aspect_vertical_align: types.Optional[str] = None, + is_clip: bool = False, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Optional[types.Union[ + types.Sequence, types.Numeric, str] + ] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, + tooltip_opts: types.Tooltip = None, + select_opts: types.Select = None, ): self.js_dependencies.add(maptype) self._geo_json_name = maptype @@ -302,9 +319,11 @@ class Geo(GeoChartBase): self.options.update( geo={ "map": maptype, + "animation": animation, "zoom": zoom, "center": center, "roam": is_roam, + "roamTrigger": roam_trigger, "aspectScale": aspect_scale, "boundingCoords": bounding_coords, "scaleLimit": scale_limit, @@ -319,6 +338,19 @@ class Geo(GeoChartBase): "label": emphasis_label_opts, }, "regions": regions_opts, + "preserveAspect": is_preserve_aspect, + "preserveAspectAlign": preserve_aspect_align, + "preserveAspectVerticalAlign": preserve_aspect_vertical_align, + "clip": is_clip, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, + "tooltip": tooltip_opts, + "select": select_opts, } ) return self diff --git a/pyecharts/charts/basic_charts/graph.py b/pyecharts/charts/basic_charts/graph.py index bb8b5397..03bf375f 100644 --- a/pyecharts/charts/basic_charts/graph.py +++ b/pyecharts/charts/basic_charts/graph.py @@ -18,8 +18,27 @@ class Graph(Chart): links: types.Sequence[types.GraphLink], categories: types.Union[types.Sequence[types.GraphCategory], None] = None, *, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, + yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, + polar_index: types.Optional[types.Numeric] = None, + polar_id: types.Optional[types.Numeric] = None, + single_axis_index: types.Optional[types.Numeric] = None, + single_axis_id: types.Optional[types.Numeric] = None, + geo_index: types.Optional[types.Numeric] = None, + geo_id: types.Optional[types.Numeric] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, is_focusnode: bool = True, is_roam: bool = True, + roam_trigger: types.Optional[str] = None, + node_scale_ratio: types.Numeric = 0.6, is_draggable: bool = False, is_rotate_label: bool = False, layout: str = "force", @@ -38,6 +57,9 @@ class Graph(Chart): tooltip_opts: types.Tooltip = None, itemstyle_opts: types.ItemStyle = None, emphasis_opts: types.Emphasis = None, + is_preserve_aspect: bool = False, + preserve_aspect_align: types.Optional[str] = None, + preserve_aspect_vertical_align: types.Optional[str] = None, ): _nodes = [] for n in nodes: @@ -67,6 +89,23 @@ class Graph(Chart): { "type": ChartType.GRAPH, "name": series_name, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "xaxisIndex": xaxis_index, + "xaxisId": xaxis_id, + "yaxisIndex": yaxis_index, + "yaxisId": yaxis_id, + "polarIndex": polar_index, + "polarId": polar_id, + "singleAxisIndex": single_axis_index, + "singleAxisId": single_axis_id, + "geoIndex": geo_index, + "geoId": geo_id, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "layout": layout, "symbol": symbol, "symbolSize": symbol_size, @@ -81,6 +120,8 @@ class Graph(Chart): "label": label_opts, "lineStyle": linestyle_opts, "roam": is_roam, + "roamTrigger": roam_trigger, + "nodeScaleRatio": node_scale_ratio, "draggable": is_draggable, "focusNodeAdjacency": is_focusnode, "data": _nodes, @@ -92,6 +133,9 @@ class Graph(Chart): "tooltip": tooltip_opts, "itemStyle": itemstyle_opts, "emphasis": emphasis_opts, + "preserveAspect": is_preserve_aspect, + "preserveAspectAlign": preserve_aspect_align, + "preserveAspectVerticalAlign": preserve_aspect_vertical_align, } ) return self diff --git a/pyecharts/charts/basic_charts/heatmap.py b/pyecharts/charts/basic_charts/heatmap.py index ec68c19e..2b47fb42 100644 --- a/pyecharts/charts/basic_charts/heatmap.py +++ b/pyecharts/charts/basic_charts/heatmap.py @@ -28,10 +28,18 @@ class HeatMap(RectChart): value: types.Sequence[types.Union[dict]], *, coordinate_system: str = "cartesian2d", + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, geo_index: types.Optional[types.Numeric] = None, + geo_id: types.Optional[types.Numeric] = None, calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, dataset_index: types.Optional[types.Numeric] = None, point_size: types.Optional[types.Numeric] = None, blur_size: types.Optional[types.Numeric] = None, @@ -56,10 +64,18 @@ class HeatMap(RectChart): "type": ChartType.HEATMAP, "name": series_name, "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, "geoIndex": geo_index, + "geoId": geo_id, "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "datasetIndex": dataset_index, "pointSize": point_size, "blurSize": blur_size, diff --git a/pyecharts/charts/basic_charts/kline.py b/pyecharts/charts/basic_charts/kline.py index 0750f3e4..d89dd614 100644 --- a/pyecharts/charts/basic_charts/kline.py +++ b/pyecharts/charts/basic_charts/kline.py @@ -31,13 +31,17 @@ class Kline(RectChart): y_axis: types.Sequence[types.Union[opts.CandleStickItem, dict]], *, coordinate_system: str = "cartesian2d", + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, color_by: types.Optional[str] = "series", bar_width: types.Optional[types.Numeric] = None, bar_min_width: types.Optional[types.Numeric] = None, bar_max_width: types.Optional[types.Numeric] = None, layout: types.Optional[str] = None, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, is_legend_hover_link: bool = True, is_hover_animation: bool = True, markline_opts: types.MarkLine = None, @@ -59,6 +63,8 @@ class Kline(RectChart): "type": ChartType.KLINE, "name": series_name, "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "colorBy": color_by, "legendHoverLink": is_legend_hover_link, "hoverAnimation": is_hover_animation, @@ -67,7 +73,9 @@ class Kline(RectChart): "barMinWidth": bar_min_width, "barMaxWidth": bar_max_width, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, "data": y_axis, "markPoint": markpoint_opts, "markLine": markline_opts, diff --git a/pyecharts/charts/basic_charts/line.py b/pyecharts/charts/basic_charts/line.py index e36abc71..2613d668 100644 --- a/pyecharts/charts/basic_charts/line.py +++ b/pyecharts/charts/basic_charts/line.py @@ -19,10 +19,15 @@ class Line(RectChart): *, is_connect_nones: bool = False, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, polar_index: types.Optional[types.Numeric] = None, + polar_id: types.Optional[types.Numeric] = None, dataset_index: types.Optional[types.Numeric] = None, coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, color_by: types.Optional[str] = None, color: types.Optional[str] = None, is_symbol_show: bool = True, @@ -30,6 +35,7 @@ class Line(RectChart): symbol_size: types.Union[types.Numeric, types.Sequence] = 4, stack: types.Optional[str] = None, stack_strategy: types.Optional[str] = "samesign", + stack_order: types.Optional[str] = None, is_smooth: bool = False, is_clip: bool = True, is_step: bool = False, @@ -78,10 +84,15 @@ class Line(RectChart): "name": series_name, "connectNulls": is_connect_nones, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, "polarIndex": polar_index, + "polarId": polar_id, "datasetIndex": dataset_index, "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "colorBy": color_by, "symbol": symbol, "symbolSize": symbol_size, @@ -91,6 +102,7 @@ class Line(RectChart): "step": is_step, "stack": stack, "stackStrategy": stack_strategy, + "stackOrder": stack_order, "data": data, "hoverAnimation": is_hover_animation, "label": label_opts, diff --git a/pyecharts/charts/basic_charts/map.py b/pyecharts/charts/basic_charts/map.py index f417dbd2..678e9ba4 100644 --- a/pyecharts/charts/basic_charts/map.py +++ b/pyecharts/charts/basic_charts/map.py @@ -37,10 +37,18 @@ class MapMixin: pos_right: types.Optional[types.Union[str, types.Numeric]] = None, pos_bottom: types.Optional[types.Union[str, types.Numeric]] = None, geo_index: types.Optional[types.Numeric] = None, + geo_id: types.Optional[types.Numeric] = None, series_layout_by: str = "column", dataset_index: types.Optional[types.Numeric] = 0, layout_center: types.Optional[types.Sequence[str]] = None, layout_size: types.Union[str, types.Numeric] = None, + is_preserve_aspect: bool = False, + preserve_aspect_align: types.Optional[str] = None, + preserve_aspect_vertical_align: types.Optional[str] = None, + is_clip: bool = False, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, label_opts: types.Label = opts.LabelOpts(), tooltip_opts: types.Tooltip = None, itemstyle_opts: types.ItemStyle = None, @@ -87,12 +95,20 @@ class MapMixin: "right": pos_right, "bottom": pos_bottom, "geoIndex": geo_index, + "geoId": geo_id, "seriesLayoutBy": series_layout_by, "datasetIndex": dataset_index, "mapValueCalculation": map_value_calculation, "showLegendSymbol": is_map_symbol_show, "layoutCenter": layout_center, "layoutSize": layout_size, + "preserveAspect": is_preserve_aspect, + "preserveAspectAlign": preserve_aspect_align, + "preserveAspectVerticalAlign": preserve_aspect_vertical_align, + "clip": is_clip, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "tooltip": tooltip_opts, "itemStyle": itemstyle_opts, "emphasis": { diff --git a/pyecharts/charts/basic_charts/parallel.py b/pyecharts/charts/basic_charts/parallel.py index 8450c8a4..3138ad10 100644 --- a/pyecharts/charts/basic_charts/parallel.py +++ b/pyecharts/charts/basic_charts/parallel.py @@ -43,7 +43,11 @@ class Parallel(Chart): series_name: str, data: types.Sequence[types.Union[opts.ParallelItem, dict]], *, + coordinate_system: types.Optional[str] = "parallel", + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, parallel_index: types.Optional[types.Numeric] = None, + parallel_id: types.Optional[types.Numeric] = None, color_by: types.Optional[str] = None, inactive_opacity: types.Optional[types.Numeric] = 0.05, active_opacity: types.Optional[types.Numeric] = 1, @@ -60,8 +64,11 @@ class Parallel(Chart): self.options.get("series").append( { "type": ChartType.PARALLEL, - "coordinateSystem": "parallel", + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "parallelIndex": parallel_index, + "parallelId": parallel_id, "colorBy": color_by, "inactiveOpacity": inactive_opacity, "activeOpacity": active_opacity, diff --git a/pyecharts/charts/basic_charts/pictorialbar.py b/pyecharts/charts/basic_charts/pictorialbar.py index d7c49349..94c221d6 100644 --- a/pyecharts/charts/basic_charts/pictorialbar.py +++ b/pyecharts/charts/basic_charts/pictorialbar.py @@ -26,8 +26,13 @@ class PictorialBar(RectChart): symbol_repeat_direction: types.Optional[str] = None, symbol_margin: types.Union[types.Numeric, str, None] = None, is_symbol_clip: bool = False, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, color: types.Optional[str] = None, category_gap: types.Union[types.Numeric, str] = "20%", gap: types.Optional[str] = None, @@ -54,8 +59,13 @@ class PictorialBar(RectChart): "symbolMargin": symbol_margin, "symbolClip": is_symbol_clip, "name": series_name, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, "data": y_axis, "barCategoryGap": category_gap, "barGap": gap, diff --git a/pyecharts/charts/basic_charts/pie.py b/pyecharts/charts/basic_charts/pie.py index f39f73ca..87dd561b 100644 --- a/pyecharts/charts/basic_charts/pie.py +++ b/pyecharts/charts/basic_charts/pie.py @@ -21,6 +21,15 @@ class Pie(Chart): color: types.Optional[str] = None, color_by: types.Optional[str] = "data", is_legend_hover_link: bool = True, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + geo_index: types.Optional[types.Numeric] = None, + geo_id: types.Optional[types.Numeric] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, selected_mode: types.Union[str, bool] = False, selected_offset: types.Numeric = 10, radius: types.Optional[types.Sequence] = None, @@ -28,6 +37,7 @@ class Pie(Chart): rosetype: types.Union[str, bool] = None, is_clockwise: bool = True, start_angle: types.Numeric = 90, + end_angle: types.Optional[types.Numeric] = None, min_angle: types.Numeric = 0, min_show_label_angle: types.Numeric = 0, is_avoid_label_overlap: bool = True, @@ -75,10 +85,20 @@ class Pie(Chart): "name": series_name, "colorBy": color_by, "legendHoverLink": is_legend_hover_link, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "geoIndex": geo_index, + "geoId": geo_id, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "selectedMode": selected_mode, "selectedOffset": selected_offset, "clockwise": is_clockwise, "startAngle": start_angle, + "endAngle": end_angle, "minAngle": min_angle, "minShowLabelAngle": min_show_label_angle, "avoidLabelOverlap": is_avoid_label_overlap, diff --git a/pyecharts/charts/basic_charts/polar.py b/pyecharts/charts/basic_charts/polar.py index 7d9c48d7..c0b34185 100644 --- a/pyecharts/charts/basic_charts/polar.py +++ b/pyecharts/charts/basic_charts/polar.py @@ -42,6 +42,15 @@ class Polar(Chart): symbol_size: types.Numeric = 4, stack: types.Optional[str] = None, center: types.Optional[types.Sequence] = None, + z_level: types.Numeric = 0, + z: types.Numeric = 2, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, label_opts: types.Label = opts.LabelOpts(is_show=False), areastyle_opts: types.AreaStyle = opts.AreaStyleOpts(), effect_opts: types.Effect = opts.EffectOpts(), @@ -50,8 +59,21 @@ class Polar(Chart): emphasis_opts: types.Emphasis = None, ): self._append_legend(series_name) - self.options.update(polar={"center": center if center else ["50%", "50%"]}) + self.options.update(polar={ + "center": center if center else ["50%", "50%"], + "zlevel": z_level, + "z": z, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, + "tooltip": tooltip_opts, + }) + # polar with other series config if type_ in (ChartType.SCATTER, ChartType.LINE, ChartType.BAR): self.options.get("series").append( { diff --git a/pyecharts/charts/basic_charts/radar.py b/pyecharts/charts/basic_charts/radar.py index a671387d..8bd3ca77 100644 --- a/pyecharts/charts/basic_charts/radar.py +++ b/pyecharts/charts/basic_charts/radar.py @@ -17,6 +17,13 @@ class Radar(Chart): shape: types.Optional[str] = None, center: types.Optional[types.Sequence] = None, radius: types.Optional[types.Union[types.Sequence, str]] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, start_angle: types.Numeric = 90, textstyle_opts: types.TextStyle = opts.TextStyleOpts(), splitline_opt: types.SplitLine = opts.SplitLineOpts(is_show=True), @@ -31,7 +38,9 @@ class Radar(Chart): polar_opts: types.Polar = None, ): self.options.update( - radiusAxis=radiusaxis_opts, angleAxis=angleaxis_opts, polar=polar_opts + radiusAxis=radiusaxis_opts, + angleAxis=angleaxis_opts, + polar=polar_opts, ) indicators = [] @@ -49,6 +58,13 @@ class Radar(Chart): "shape": shape, "center": center, "radius": radius, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "startAngle": start_angle, "name": {"textStyle": textstyle_opts}, "splitLine": splitline_opt, diff --git a/pyecharts/charts/basic_charts/sankey.py b/pyecharts/charts/basic_charts/sankey.py index cbdd6b96..e0c8f628 100644 --- a/pyecharts/charts/basic_charts/sankey.py +++ b/pyecharts/charts/basic_charts/sankey.py @@ -23,12 +23,25 @@ class Sankey(Chart): pos_top: types.Union[str, types.Numeric] = "5%", pos_right: types.Union[str, types.Numeric] = "20%", pos_bottom: types.Union[str, types.Numeric] = "5%", + width: types.Union[str, types.Numeric] = None, + height: types.Union[str, types.Numeric] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, node_width: types.Numeric = 20, node_gap: types.Numeric = 8, node_align: str = "justify", layout_iterations: types.Optional[types.Numeric] = None, orient: str = "horizontal", is_draggable: bool = True, + center: types.Optional[types.Sequence] = None, + zoom: types.Numeric = 1, + is_roam: bool = False, + roam_trigger: types.Optional[str] = None, edge_label_opt: types.Label = None, levels: types.SankeyLevel = None, label_opts: types.Label = opts.LabelOpts(), @@ -48,12 +61,25 @@ class Sankey(Chart): "top": pos_top, "right": pos_right, "bottom": pos_bottom, + "width": width, + "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "nodeWidth": node_width, "nodeGap": node_gap, "nodeAlign": node_align, "layoutIterations": layout_iterations, "orient": orient, "draggable": is_draggable, + "center": center, + "zoom": zoom, + "roam": is_roam, + "roamTrigger": roam_trigger, "edgeLabel": edge_label_opt, "levels": levels, "label": label_opts, diff --git a/pyecharts/charts/basic_charts/scatter.py b/pyecharts/charts/basic_charts/scatter.py index d4cbd321..7ac26f59 100644 --- a/pyecharts/charts/basic_charts/scatter.py +++ b/pyecharts/charts/basic_charts/scatter.py @@ -38,13 +38,30 @@ class Scatter(RectChart): series_name: str, y_axis: types.Sequence[types.Union[opts.ScatterItem, dict]], *, + color_by: types.Optional[str] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, xaxis_index: types.Optional[types.Numeric] = None, + xaxis_id: types.Optional[types.Numeric] = None, yaxis_index: types.Optional[types.Numeric] = None, + yaxis_id: types.Optional[types.Numeric] = None, + polar_index: types.Optional[types.Numeric] = None, + polar_id: types.Optional[types.Numeric] = None, + single_axis_index: types.Optional[types.Numeric] = None, + single_axis_id: types.Optional[types.Numeric] = None, + geo_index: types.Optional[types.Numeric] = None, + geo_id: types.Optional[types.Numeric] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, color: types.Optional[str] = None, symbol: types.Optional[str] = None, symbol_size: types.Union[types.Numeric, types.Sequence] = 10, symbol_rotate: types.Optional[types.Numeric] = None, label_opts: types.Label = opts.LabelOpts(position="right"), + is_silent: bool = False, markpoint_opts: types.MarkPoint = None, markline_opts: types.MarkLine = None, markarea_opts: types.MarkArea = None, @@ -62,13 +79,30 @@ class Scatter(RectChart): { "type": ChartType.SCATTER, "name": series_name, + "colorBy": color_by, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, "xAxisIndex": xaxis_index, + "xAxisId": xaxis_id, "yAxisIndex": yaxis_index, + "yAxisId": yaxis_id, + "polarIndex": polar_index, + "polarId": polar_id, + "singleAxisIndex": single_axis_index, + "singleAxisId": single_axis_id, + "geoIndex": geo_index, + "geoId": geo_id, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "symbol": symbol, "symbolSize": symbol_size, "symbolRotate": symbol_rotate, "data": data, "label": label_opts, + "silent": is_silent, "markPoint": markpoint_opts, "markLine": markline_opts, "markArea": markarea_opts, diff --git a/pyecharts/charts/basic_charts/sunburst.py b/pyecharts/charts/basic_charts/sunburst.py index afbe14d6..15ad5c5d 100644 --- a/pyecharts/charts/basic_charts/sunburst.py +++ b/pyecharts/charts/basic_charts/sunburst.py @@ -21,6 +21,13 @@ class Sunburst(Chart): *, center: types.Optional[types.Sequence] = None, radius: types.Optional[types.Sequence] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, highlight_policy: str = "descendant", node_click: str = "rootToNode", sort_: types.Optional[types.JSFunc] = "desc", @@ -47,6 +54,13 @@ class Sunburst(Chart): "data": data_pair, "center": center, "radius": radius, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "highlightPolicy": highlight_policy, "nodeClick": node_click, "sort": sort_, diff --git a/pyecharts/charts/basic_charts/themeriver.py b/pyecharts/charts/basic_charts/themeriver.py index fc34e4cf..b5ae258d 100644 --- a/pyecharts/charts/basic_charts/themeriver.py +++ b/pyecharts/charts/basic_charts/themeriver.py @@ -18,6 +18,19 @@ class ThemeRiver(Chart): series_name: types.Sequence, data: types.Sequence[types.Union[opts.ThemeRiverItem, dict]], *, + color_by: types.Optional[str] = None, + pos_left: types.Union[str, types.Numeric] = "5%", + pos_top: types.Union[str, types.Numeric] = "5%", + pos_right: types.Union[str, types.Numeric] = "5%", + pos_bottom: types.Union[str, types.Numeric] = "5%", + width: types.Union[str, types.Numeric] = None, + height: types.Union[str, types.Numeric] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + single_axis_index: types.Optional[types.Numeric] = None, + single_axis_id: types.Optional[types.Numeric] = None, + boundary_gap: types.Optional[types.Sequence] = None, label_opts: types.Label = opts.LabelOpts(), singleaxis_opts: types.SingleAxis = opts.SingleAxisOpts(), tooltip_opts: types.Tooltip = None, @@ -32,6 +45,19 @@ class ThemeRiver(Chart): "type": ChartType.THEMERIVER, "name": series_name, "data": data, + "colorBy": color_by, + "left": pos_left, + "top": pos_top, + "right": pos_right, + "bottom": pos_bottom, + "width": width, + "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "singleAxisIndex": single_axis_index, + "singleAxisId": single_axis_id, + "boundaryGap": boundary_gap, "label": label_opts, "tooltip": tooltip_opts, "itemStyle": itemstyle_opts, diff --git a/pyecharts/charts/basic_charts/tree.py b/pyecharts/charts/basic_charts/tree.py index 78754663..34c00661 100644 --- a/pyecharts/charts/basic_charts/tree.py +++ b/pyecharts/charts/basic_charts/tree.py @@ -48,11 +48,19 @@ class Tree(Chart): pos_right: types.Union[str, types.Numeric, None] = None, width: types.Union[str, types.Numeric, None] = None, height: types.Union[str, types.Numeric, None] = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, center: types.Optional[types.Sequence[types.Union[str, types.Numeric]]] = None, collapse_interval: types.Numeric = 0, edge_shape: str = "curve", edge_fork_position: str = "50%", is_roam: bool = False, + roam_trigger: types.Optional[str] = None, is_expand_and_collapse: bool = True, initial_tree_depth: types.Optional[types.Numeric] = None, label_opts: types.Label = opts.LabelOpts(), @@ -76,6 +84,13 @@ class Tree(Chart): "bottom": pos_bottom, "width": width, "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "center": center, "zoom": zoom, "symbol": symbol, @@ -83,6 +98,7 @@ class Tree(Chart): "edgeShape": edge_shape, "edgeForkPosition": edge_fork_position, "roam": is_roam, + "roamTrigger": roam_trigger, "expandAndCollapse": is_expand_and_collapse, "initialTreeDepth": initial_tree_depth, "layout": layout, diff --git a/pyecharts/charts/basic_charts/treemap.py b/pyecharts/charts/basic_charts/treemap.py index 1f1a79aa..27395d5a 100644 --- a/pyecharts/charts/basic_charts/treemap.py +++ b/pyecharts/charts/basic_charts/treemap.py @@ -24,6 +24,13 @@ class TreeMap(Chart): pos_bottom: types.Optional[str] = None, width: types.Union[str, types.Numeric] = "80%", height: types.Union[str, types.Numeric] = "80%", + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Union[types.Sequence, types.Numeric, str] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, square_ratio: types.Optional[types.JSFunc] = None, drilldown_icon: str = "▶", roam: types.Union[bool, str] = True, @@ -56,6 +63,13 @@ class TreeMap(Chart): "top": pos_top, "width": width, "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "bottom": pos_bottom, "squareRatio": square_ratio, "label": label_opts, diff --git a/pyecharts/charts/chart.py b/pyecharts/charts/chart.py index fd8cb816..f8307160 100644 --- a/pyecharts/charts/chart.py +++ b/pyecharts/charts/chart.py @@ -16,13 +16,6 @@ class Chart(Base): temp_opts.update(**init_opts) init_opts = temp_opts super().__init__(init_opts=init_opts, render_opts=render_opts) - # Change to Echarts V5 default color list - self.colors = ( - "#5470c6 #91cc75 #fac858 #ee6666 #73c0de #3ba272 #fc8452 #9a60b4 " "#ea7ccc" - ).split() - self.default_color_n = len(self.colors) - if init_opts.opts.get("theme") == ThemeType.WHITE: - self.options.update(color=self.colors) self.options.update( series=[], legend=[{"data": [], "selected": dict()}], @@ -112,12 +105,10 @@ class Chart(Base): def _append_color(self, color: Optional[str]): if color: - # 这是一个bug - # 添加轴(执行add_yaxis操作)的顺序与新添加的color值(设置color属性)未一一对应,正好颠倒 - self.colors.insert(-self.default_color_n, color) - # self.colors = [color] + self.colors - if self.theme == ThemeType.WHITE: - self.options.update(color=self.colors) + if self.options.get("color"): + self.options.get("color").append(color) + else: + self.options.update(color=[color]) def set_global_opts( self, @@ -132,11 +123,14 @@ class Chart(Base): datazoom_opts: types.DataZoom = None, graphic_opts: types.Graphic = None, axispointer_opts: types.AxisPointer = None, + matrix_opts: types.Matrix = None, + thumbnail_opts: types.Thumbnail = None, ): if tooltip_opts is None: tooltip_opts = opts.TooltipOpts( formatter=ToolTipFormatterType.get(self._chart_type, None) ) + self.options.update( title=title_opts, toolbox=toolbox_opts, @@ -145,6 +139,8 @@ class Chart(Base): dataZoom=datazoom_opts, graphic=graphic_opts, axisPointer=axispointer_opts, + matrix=matrix_opts, + thumbnail=thumbnail_opts, ) if brush_opts is not None: @@ -253,8 +249,13 @@ class RectChart(Chart): ) self.options.get("series").extend(chart.options.get("series")) # to merge colors of chart - for c in chart.colors[: len(chart.colors) - self.default_color_n]: - self.colors.insert(len(self.colors) - self.default_color_n, c) + chart_colors = chart.options.get("color") + if self.options.get("color") is None: + if chart_colors: + self.options.update(color=chart_colors) + else: + if chart_colors: + self.options.get("color").extend(chart_colors) return self diff --git a/pyecharts/charts/composite_charts/grid.py b/pyecharts/charts/composite_charts/grid.py index 9f80cc65..9a6d463c 100644 --- a/pyecharts/charts/composite_charts/grid.py +++ b/pyecharts/charts/composite_charts/grid.py @@ -4,6 +4,7 @@ from typing import Optional from ... import options as opts from ... import types from ...globals import ThemeType +from ..basic_charts.geo import GeoChartBase from ..basic_charts.radar import Radar from ..chart import Base, Chart, RectChart @@ -94,7 +95,11 @@ class Grid(Base): self.js_dependencies.add(dep) if chart.options.get("geo") is not None: - self.options.update(geo=chart.options.get("geo")) + _grid_geo_option = self.options.get("geo") + if _grid_geo_option is None or isinstance(_grid_geo_option, dict): + self.options.update(geo=[chart.options.get("geo")]) + else: + _grid_geo_option.append(chart.options.get("geo")) if isinstance(chart, RectChart): if grid_index is None: diff --git a/pyecharts/charts/composite_charts/timeline.py b/pyecharts/charts/composite_charts/timeline.py index 0434122c..648c8d4d 100644 --- a/pyecharts/charts/composite_charts/timeline.py +++ b/pyecharts/charts/composite_charts/timeline.py @@ -49,6 +49,15 @@ class Timeline(Base): progress_linestyle_opts: types.LineStyle = None, progress_itemstyle_opts: types.ItemStyle = None, progress_label_opts: types.Label = None, + coordinate_system: types.Optional[str] = None, + coordinate_system_usage: types.Optional[str] = None, + coord: types.Optional[types.Union[ + Sequence, types.Numeric, str] + ] = None, + calendar_index: types.Optional[types.Numeric] = None, + calendar_id: types.Optional[types.Numeric] = None, + matrix_index: types.Optional[types.Numeric] = None, + matrix_id: types.Optional[types.Numeric] = None, ): self.options.get("baseOption").get("timeline").update( { @@ -81,6 +90,13 @@ class Timeline(Base): "itemStyle": progress_itemstyle_opts, "label": progress_label_opts, }, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, } ) return self diff --git a/pyecharts/datasets/map_filename.json b/pyecharts/datasets/map_filename.json index 0237c888..37b63015 100644 --- a/pyecharts/datasets/map_filename.json +++ b/pyecharts/datasets/map_filename.json @@ -13,6 +13,13 @@ "echarts-liquidfill": ["echarts-liquidfill.min", "js"], "echarts-wordcloud": ["echarts-wordcloud.min", "js"], "echarts-stat": ["ecStat.min", "js"], + "echarts-x-violin": ["echarts-x/violin/index.auto.min", "js"], + "echarts-x-stage": ["echarts-x/stage/index.auto.min", "js"], + "echarts-x-contour-d3": ["echarts-x/contour/d3.min", "js"], + "echarts-x-contour": ["echarts-x/contour/index.auto.min", "js"], + "echarts-x-segmented-doughnut": ["echarts-x/segmented-doughnut/index.auto.min", "js"], + "echarts-x-line-range": ["echarts-x/line-range/index.auto.min", "js"], + "echarts-x-bar-range": ["echarts-x/bar-range/index.auto.min", "js"], "bmap": ["bmap.min", "js"], "chalk": ["themes/chalk", "js"], "essos": ["themes/essos", "js"], diff --git a/pyecharts/globals.py b/pyecharts/globals.py index 52e41aa8..1d2d18e6 100644 --- a/pyecharts/globals.py +++ b/pyecharts/globals.py @@ -34,6 +34,7 @@ class _ChartType: BAR: str = "bar" BAR3D: str = "bar3D" BOXPLOT: str = "boxplot" + CHORD: str = "chord" EFFECT_SCATTER: str = "effectScatter" FUNNEL: str = "funnel" FLOWGL: str = "flowGL" @@ -67,6 +68,13 @@ class _ChartType: TREEMAP: str = "treemap" WORDCLOUD: str = "wordCloud" CUSTOM: str = "custom" + # below chart types are Echarts 6 new custom chart + VIOLIN: str = "violin" + STAGE: str = "stage" + DOUGHNUT: str = "segmentedDoughnut" + CONTOUR: str = "contour" + BAR_RANGE: str = "barRange" + LINE_RANGE: str = "lineRange" ToolTipFormatterType = { @@ -133,7 +141,7 @@ class _NotebookType: class _OnlineHost: - DEFAULT_HOST = "https://assets.pyecharts.org/assets/v5/" + DEFAULT_HOST = "https://assets.pyecharts.org/assets/v6/" NOTEBOOK_HOST = "http://localhost:8888/nbextensions/assets/" diff --git a/pyecharts/options/__init__.py b/pyecharts/options/__init__.py index 464b7330..704104fc 100644 --- a/pyecharts/options/__init__.py +++ b/pyecharts/options/__init__.py @@ -11,7 +11,15 @@ from .charts_options import ( BMapTypeControlOpts, BoxplotItem, CandleStickItem, + ChordData, + ChordLink, ComponentTitleOpts, + CustomBarRangeItemPayloadOpts, + CustomContourItemPayloadOpts, + CustomLineRangeItemPayloadOpts, + CustomSegmentedDoughnutItemPayloadOpts, + CustomStageItemPayloadOpts, + CustomViolinItemPayloadOpts, EffectScatterItem, FunnelItem, GaugeDetailOpts, @@ -72,6 +80,9 @@ from .global_options import ( AriaLabelOpts, AriaOpts, Axis3DOpts, + AxisBreakOpts, + AxisBreakAreaOpts, + AxisBreakLabelLayoutOpts, AxisLineOpts, AxisOpts, AxisPointerOpts, @@ -88,9 +99,17 @@ from .global_options import ( Emphasis3DOpts, Grid3DOpts, GridOpts, + GridOuterOpts, InitOpts, RenderOpts, LegendOpts, + MatrixAxisOpts, + MatrixAxisDataOpts, + MatrixBackgroundStyleOpts, + MatrixBodyDataOpts, + MatrixBodyOrCornerOpts, + MatrixDividerLineStyleOpts, + MatrixOpts, ParallelAxisOpts, ParallelOpts, PolarOpts, @@ -99,6 +118,8 @@ from .global_options import ( RadiusAxisOpts, SelectOpts, SingleAxisOpts, + ThumbnailOpts, + ThumbnailWindowStyleOpts, TitleOpts, ToolBoxFeatureBrushOpts, ToolBoxFeatureDataViewOpts, diff --git a/pyecharts/options/charts_options.py b/pyecharts/options/charts_options.py index c7857441..17099cf7 100644 --- a/pyecharts/options/charts_options.py +++ b/pyecharts/options/charts_options.py @@ -18,6 +18,30 @@ from .series_options import ( # Chart Options +class ChordData(BasicOpts): + def __init__( + self, + name: Optional[str] = None, + ): + self.opts: dict = { + "name": name, + } + + +class ChordLink(BasicOpts): + def __init__( + self, + source: Union[str, int, None] = None, + target: Union[str, int, None] = None, + value: Optional[Numeric] = None, + ): + self.opts: dict = { + "source": source, + "target": target, + "value": value, + } + + class GraphNode(BasicOpts): def __init__( self, @@ -398,6 +422,7 @@ class GraphicTextStyleOpts(BaseGraphic): pos_y: Numeric = 0, font: Optional[str] = None, font_size: Optional[Numeric] = 0, + font_weight: Optional[str] = None, text_align: str = "left", text_vertical_align: Optional[str] = None, graphic_basicstyle_opts: Union[GraphicBasicStyleOpts, dict, None] = None, @@ -408,6 +433,7 @@ class GraphicTextStyleOpts(BaseGraphic): "y": pos_y, "font": font, "fontSize": font_size, + "fontWeight": font_weight, "textAlign": text_align, "textVerticalAlign": text_vertical_align, } @@ -424,7 +450,7 @@ class GraphicItem(BaseGraphic): self, id_: Optional[str] = None, action: str = "merge", - position: [Sequence, Numeric, None] = None, + position: Union[Sequence, Numeric, None] = None, rotation: Union[Numeric, JSFunc, None] = 0, scale: Union[Sequence, Numeric, None] = None, origin: Union[Numeric, Sequence, None] = None, @@ -1595,7 +1621,7 @@ class ScatterItem(BasicOpts): def __init__( self, name: Union[str, Numeric] = None, - value: Union[str, Numeric] = None, + value: Union[str, Numeric, Sequence] = None, symbol: Optional[str] = None, symbol_size: Union[Sequence[Numeric], Numeric] = None, symbol_rotate: Optional[Numeric] = None, @@ -1665,3 +1691,85 @@ class TreeItem(BasicOpts): "children": children, "label": label_opts, } + + +class CustomBarRangeItemPayloadOpts(BasicOpts): + def __init__( + self, + bar_width: Union[Numeric, str, None] = None, + border_radius: Optional[Numeric] = None, + margin: Optional[Numeric] = None, + ): + self.opts: dict = { + "barWidth": bar_width, + "borderRadius": border_radius, + "margin": margin, + } + + +class CustomContourItemPayloadOpts(BasicOpts): + def __init__( + self, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + linestyle_opts: Union[LineStyleOpts, dict, None] = None, + bandwidth: Optional[Numeric] = None, + ): + self.opts: dict = { + "itemStyle": itemstyle_opts, + "lineStyle": linestyle_opts, + "bandwidth": bandwidth, + } + + +class CustomLineRangeItemPayloadOpts(BasicOpts): + def __init__( + self, + linestyle_opts: Union[LineStyleOpts, dict, None] = None, + areastyle_opts: Union[AreaStyleOpts, dict, None] = None, + ): + self.opts: dict = { + "areaStyle": areastyle_opts, + "lineStyle": linestyle_opts, + } + + +class CustomSegmentedDoughnutItemPayloadOpts(BasicOpts): + def __init__( + self, + center: Optional[Sequence] = None, + radius: Optional[Sequence] = None, + segment_count: Optional[Numeric] = None, + label_opts: Union[LabelOpts, dict, None] = None, + ): + self.opts: dict = { + "center": center, + "radius": radius, + "segmentCount": segment_count, + "label": label_opts, + } + + +class CustomStageItemPayloadOpts(BasicOpts): + def __init__( + self, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + ): + self.opts: dict = { + "itemStyle": itemstyle_opts, + } + + +class CustomViolinItemPayloadOpts(BasicOpts): + def __init__( + self, + symbol_size: Optional[Numeric] = None, + area_opacity: Optional[Numeric] = None, + bandwidth_scale: Optional[Numeric] = None, + bin_count: Optional[Numeric] = None, + ): + self.opts: dict = { + "symbolSize": symbol_size, + "areaOpacity": area_opacity, + "bandWidthScale": bandwidth_scale, + "binCount": bin_count, + } diff --git a/pyecharts/options/global_options.py b/pyecharts/options/global_options.py index 3984cede..aa9eed2b 100644 --- a/pyecharts/options/global_options.py +++ b/pyecharts/options/global_options.py @@ -166,6 +166,60 @@ class RenderOpts(BasicOpts): } +class TooltipOpts(BasicOpts): + def __init__( + self, + is_show: bool = True, + trigger: str = "item", + trigger_on: str = "mousemove|click", + axis_pointer_type: str = "line", + is_show_content: bool = True, + is_always_show_content: bool = False, + show_delay: Numeric = 0, + hide_delay: Numeric = 100, + is_enterable: bool = False, + is_confine: bool = False, + is_append_to_body: bool = False, + transition_duration: Numeric = 0.4, + is_display_transition: bool = True, + position: Union[str, Sequence, JSFunc] = None, + formatter: Optional[JSFunc] = None, + value_formatter: Optional[JSFunc] = None, + background_color: Optional[str] = None, + border_color: Optional[str] = None, + border_width: Numeric = 0, + padding: Union[Numeric, Sequence[Numeric]] = 5, + textstyle_opts: Optional[TextStyleOpts] = TextStyleOpts(font_size=14), + extra_css_text: Optional[str] = None, + order: str = "seriesAsc", + ): + self.opts: dict = { + "show": is_show, + "trigger": trigger, + "triggerOn": trigger_on, + "axisPointer": {"type": axis_pointer_type}, + "showContent": is_show_content, + "alwaysShowContent": is_always_show_content, + "showDelay": show_delay, + "hideDelay": hide_delay, + "enterable": is_enterable, + "confine": is_confine, + "appendToBody": is_append_to_body, + "transitionDuration": transition_duration, + "displayTransition": is_display_transition, + "position": position, + "formatter": formatter, + "valueFormatter": value_formatter, + "textStyle": textstyle_opts, + "backgroundColor": background_color, + "borderColor": border_color, + "borderWidth": border_width, + "padding": padding, + "extraCssText": extra_css_text, + "order": order, + } + + class ToolBoxFeatureSaveAsImageOpts(BasicOpts): def __init__( self, @@ -371,6 +425,18 @@ class ToolboxOpts(BasicOpts): pos_top: Optional[str] = None, pos_bottom: Optional[str] = None, feature: Union[ToolBoxFeatureOpts, dict] = ToolBoxFeatureOpts(), + z_level: Optional[Numeric] = None, + z: Optional[Numeric] = None, + width: Optional[str] = None, + height: Optional[str] = None, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, + tooltip_opts: Union[TooltipOpts, dict, None] = None, ): self.opts: dict = { "show": is_show, @@ -382,6 +448,18 @@ class ToolboxOpts(BasicOpts): "top": pos_top, "bottom": pos_bottom, "feature": feature, + "zlevel": z_level, + "z": z, + "width": width, + "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, + "tooltip": tooltip_opts, } @@ -445,10 +523,17 @@ class TitleOpts(BasicOpts): subtitle: Optional[str] = None, subtitle_link: Optional[str] = None, subtitle_target: Optional[str] = "blank", - pos_left: Optional[str] = None, - pos_right: Optional[str] = None, - pos_top: Optional[str] = None, - pos_bottom: Optional[str] = None, + pos_left: Union[str, Numeric] = None, + pos_right: Union[str, Numeric] = None, + pos_top: Union[str, Numeric] = None, + pos_bottom: Union[str, Numeric] = None, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, padding: Union[Sequence, Numeric] = 5, item_gap: Numeric = 10, text_align: str = "auto", @@ -470,6 +555,13 @@ class TitleOpts(BasicOpts): "right": pos_right, "top": pos_top, "bottom": pos_bottom, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "padding": padding, "itemGap": item_gap, "textAlign": text_align, @@ -506,15 +598,24 @@ class DataZoomOpts(BasicOpts): is_zoom_lock: bool = False, throttle: Optional[int] = None, range_mode: Optional[Sequence] = None, - pos_left: Optional[str] = None, - pos_right: Optional[str] = None, - pos_top: Optional[str] = None, - pos_bottom: Optional[str] = None, + pos_left: Union[Numeric, str] = None, + pos_right: Union[Numeric, str] = None, + pos_top: Union[Numeric, str] = None, + pos_bottom: Union[Numeric, str] = None, + width: Union[Numeric, str] = None, + height: Union[Numeric, str] = None, filter_mode: str = "filter", is_zoom_on_mouse_wheel: bool = True, is_move_on_mouse_move: bool = True, is_move_on_mouse_wheel: bool = True, is_prevent_default_mouse_move: bool = True, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, ): self.opts: dict = { "show": is_show, @@ -543,6 +644,13 @@ class DataZoomOpts(BasicOpts): "top": pos_top, "bottom": pos_bottom, "filterMode": filter_mode, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, } # inside have some different configurations. @@ -555,6 +663,20 @@ class DataZoomOpts(BasicOpts): "preventDefaultMouseMove": is_prevent_default_mouse_move, }) + # slider have some different configurations. + if type_ == "slider": + self.opts.update({ + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, + "width": width, + "height": height, + }) + class LegendOpts(BasicOpts): def __init__( @@ -567,6 +689,15 @@ class LegendOpts(BasicOpts): pos_right: Union[str, Numeric, None] = None, pos_top: Union[str, Numeric, None] = None, pos_bottom: Union[str, Numeric, None] = None, + width: Union[str, Numeric, None] = None, + height: Union[str, Numeric, None] = None, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, orient: Optional[str] = None, align: Optional[str] = None, padding: int = 5, @@ -591,9 +722,11 @@ class LegendOpts(BasicOpts): is_page_animation: Optional[bool] = None, page_animation_duration_update: int = 800, selector: Union[bool, Sequence] = False, + selector_label: Union[LabelOpts, dict, None] = None, selector_position: str = "auto", selector_item_gap: int = 7, selector_button_gap: int = 10, + is_trigger_event: bool = False, ): self.opts: dict = { "type": type_, @@ -604,6 +737,15 @@ class LegendOpts(BasicOpts): "right": pos_right, "top": pos_top, "bottom": pos_bottom, + "width": width, + "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "orient": orient, "align": align, "padding": padding, @@ -628,9 +770,11 @@ class LegendOpts(BasicOpts): "animation": is_page_animation, "animationDurationUpdate": page_animation_duration_update, "selector": selector, + "selectorLabel": selector_label, "selectorPosition": selector_position, "selectorItemGap": selector_item_gap, "selectorButtonGap": selector_button_gap, + "triggerEvent": is_trigger_event, } @@ -647,10 +791,10 @@ class VisualMapOpts(BasicOpts): range_size: Optional[Sequence[int]] = None, range_opacity: Union[Numeric, Sequence[Numeric]] = None, orient: str = "vertical", - pos_left: Optional[str] = None, - pos_right: Optional[str] = None, - pos_top: Optional[str] = None, - pos_bottom: Optional[str] = None, + pos_left: Union[str, Numeric] = None, + pos_right: Union[str, Numeric] = None, + pos_top: Union[str, Numeric] = None, + pos_bottom: Union[str, Numeric] = None, padding: Union[int, Sequence[int]] = 5, split_number: int = 5, series_index: Union[Numeric, Sequence, None] = None, @@ -661,12 +805,20 @@ class VisualMapOpts(BasicOpts): is_inverse: bool = False, precision: Optional[int] = None, pieces: Optional[Sequence] = None, + categories: Optional[Sequence] = None, out_of_range: Optional[dict] = None, item_width: int = 0, item_height: int = 0, background_color: Optional[str] = None, border_color: Optional[str] = None, border_width: int = 0, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, textstyle_opts: Union[TextStyleOpts, dict, None] = None, ): _inrange_op: dict = {} @@ -680,6 +832,14 @@ class VisualMapOpts(BasicOpts): _inrange_op.update(opacity=range_opacity) _visual_typ = "piecewise" if is_piecewise else "continuous" + if type_ in ["piecewise", "continuous"] and ( + range_color or range_size or range_opacity, + ): + _inrange_op.update( + color=range_color, + symbolSize=range_size, + opacity=range_opacity, + ) if is_piecewise and item_width == 0 and item_height == 0: item_width, item_height = 20, 14 @@ -694,7 +854,7 @@ class VisualMapOpts(BasicOpts): "text": range_text, "textStyle": textstyle_opts, "range": range_, - "inRange": _inrange_op, + "inRange": _inrange_op if _inrange_op else None, "calculable": is_calculable, "inverse": is_inverse, "precision": precision, @@ -715,61 +875,16 @@ class VisualMapOpts(BasicOpts): "backgroundColor": background_color, "borderColor": border_color, "borderWidth": border_width, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, } if is_piecewise: - self.opts.update(pieces=pieces) - - -class TooltipOpts(BasicOpts): - def __init__( - self, - is_show: bool = True, - trigger: str = "item", - trigger_on: str = "mousemove|click", - axis_pointer_type: str = "line", - is_show_content: bool = True, - is_always_show_content: bool = False, - show_delay: Numeric = 0, - hide_delay: Numeric = 100, - is_enterable: bool = False, - is_confine: bool = False, - is_append_to_body: bool = False, - transition_duration: Numeric = 0.4, - position: Union[str, Sequence, JSFunc] = None, - formatter: Optional[JSFunc] = None, - value_formatter: Optional[JSFunc] = None, - background_color: Optional[str] = None, - border_color: Optional[str] = None, - border_width: Numeric = 0, - padding: Numeric = 5, - textstyle_opts: Optional[TextStyleOpts] = TextStyleOpts(font_size=14), - extra_css_text: Optional[str] = None, - order: str = "seriesAsc", - ): - self.opts: dict = { - "show": is_show, - "trigger": trigger, - "triggerOn": trigger_on, - "axisPointer": {"type": axis_pointer_type}, - "showContent": is_show_content, - "alwaysShowContent": is_always_show_content, - "showDelay": show_delay, - "hideDelay": hide_delay, - "enterable": is_enterable, - "confine": is_confine, - "appendToBody": is_append_to_body, - "transitionDuration": transition_duration, - "position": position, - "formatter": formatter, - "valueFormatter": value_formatter, - "textStyle": textstyle_opts, - "backgroundColor": background_color, - "borderColor": border_color, - "borderWidth": border_width, - "padding": padding, - "extraCssText": extra_css_text, - "order": order, - } + self.opts.update(pieces=pieces, categories=categories) class AxisLineOpts(BasicOpts): @@ -832,6 +947,54 @@ class AxisPointerOpts(BasicOpts): } +class AxisBreakOpts(BasicOpts): + def __init__( + self, + start: Union[Numeric, str] = None, + end: Union[Numeric, str] = None, + gap: Union[Numeric, str] = None, + is_expanded: Optional[bool] = None, + ): + self.opts: dict = { + "start": start, + "end": end, + "gap": gap, + "isExpanded": is_expanded, + } + + +class AxisBreakAreaOpts(BasicOpts): + def __init__( + self, + is_show: Optional[bool] = None, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + zigzag_amplitude: Optional[Numeric] = None, + zigzag_min_span: Optional[Numeric] = None, + zigzag_max_span: Optional[Numeric] = None, + zigzag_z: Optional[Numeric] = None, + is_expand_onclick: Optional[bool] = None, + ): + self.opts: dict = { + "show": is_show, + "itemStyle": itemstyle_opts, + "zigzagAmplitude": zigzag_amplitude, + "zigzagMinSpan": zigzag_min_span, + "zigzagMaxSpan": zigzag_max_span, + "zigzagZ": zigzag_z, + "expandOnClick": is_expand_onclick, + } + + +class AxisBreakLabelLayoutOpts(BasicOpts): + def __init__( + self, + is_move_overlap: Optional[bool] = None, + ): + self.opts: dict = { + "moveOverlap": is_move_overlap, + } + + class AxisOpts(BasicOpts): def __init__( self, @@ -843,16 +1006,32 @@ class AxisOpts(BasicOpts): name_location: str = "end", name_gap: Numeric = 15, name_rotate: Optional[Numeric] = None, + name_truncate_max_width: Optional[Numeric] = None, + name_truncate_ellipsis: Optional[str] = None, + is_name_move_overlap: bool = True, interval: Optional[Numeric] = None, grid_index: Optional[Numeric] = None, + grid_id: Optional[Numeric] = None, position: Optional[str] = None, offset: Numeric = 0, split_number: Numeric = 5, boundary_gap: Union[str, bool, None] = None, - min_: Union[Numeric, str, None] = None, - max_: Union[Numeric, str, None] = None, + min_: Union[Numeric, JSFunc, None] = None, + max_: Union[Numeric, JSFunc, None] = None, min_interval: Numeric = 0, max_interval: Optional[Numeric] = None, + log_base: Optional[Numeric] = None, + start_value: Optional[Numeric] = None, + is_silent: bool = False, + is_trigger_event: bool = False, + jitter: Optional[Numeric] = None, + is_jitter_overlap: Optional[bool] = None, + jitter_margin: Optional[Numeric] = None, + axisbreaks_opts: Sequence[Union[AxisBreakOpts, dict, None]] = None, + axisbreak_area_opts: Union[AxisBreakAreaOpts, dict, None] = None, + axisbreak_label_layout_opts: Union[ + AxisBreakLabelLayoutOpts, dict, None, + ] = None, axisline_opts: Union[AxisLineOpts, dict, None] = None, axistick_opts: Union[AxisTickOpts, dict, None] = None, axislabel_opts: Union[LabelOpts, dict, None] = None, @@ -872,9 +1051,15 @@ class AxisOpts(BasicOpts): "nameLocation": name_location, "nameGap": name_gap, "nameRotate": name_rotate, + "nameTruncate": { + "maxWidth": name_truncate_max_width, + "ellipsis": name_truncate_ellipsis, + }, + "nameMoveOverlap": is_name_move_overlap, "interval": interval, "nameTextStyle": name_textstyle_opts, "gridIndex": grid_index, + "gridId": grid_id, "axisLine": axisline_opts, "axisTick": axistick_opts, "axisLabel": axislabel_opts, @@ -888,6 +1073,16 @@ class AxisOpts(BasicOpts): "max": max_, "minInterval": min_interval, "maxInterval": max_interval, + "logBase": log_base, + "startValue": start_value, + "silent": is_silent, + "triggerEvent": is_trigger_event, + "jitter": jitter, + "jitterOverlap": is_jitter_overlap, + "jitterMargin": jitter_margin, + "breaks": axisbreaks_opts, + "breakArea": axisbreak_area_opts, + "breakLabelLayout": axisbreak_label_layout_opts, "splitLine": splitline_opts, "splitArea": splitarea_opts, "minorTick": minor_tick_opts, @@ -898,6 +1093,26 @@ class AxisOpts(BasicOpts): self.opts.update(**animation_opts.opts) +class GridOuterOpts(BasicOpts): + def __init__( + self, + pos_left: Union[Numeric, str, None] = None, + pos_top: Union[Numeric, str, None] = None, + pos_right: Union[Numeric, str, None] = None, + pos_bottom: Union[Numeric, str, None] = None, + width: Union[Numeric, str, None] = None, + height: Union[Numeric, str, None] = None, + ): + self.opts: dict = { + "left": pos_left, + "top": pos_top, + "right": pos_right, + "bottom": pos_bottom, + "width": width, + "height": height, + } + + class GridOpts(BasicOpts): def __init__( self, @@ -911,6 +1126,9 @@ class GridOpts(BasicOpts): width: Union[Numeric, str, None] = None, height: Union[Numeric, str, None] = None, is_contain_label: bool = False, + outer_bounds_mode: Optional[str] = None, + outer_bounds_opts: Union[GridOuterOpts, dict, None] = None, + outer_bounds_contain: Optional[str] = None, background_color: str = "transparent", border_color: str = "#ccc", border_width: Numeric = 1, @@ -919,6 +1137,13 @@ class GridOpts(BasicOpts): shadow_offset_x: Numeric = 0, shadow_offset_y: Numeric = 0, tooltip_opts: Union[TooltipOpts, dict, None] = None, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, ): self.opts: dict = { "show": is_show, @@ -931,6 +1156,9 @@ class GridOpts(BasicOpts): "width": width, "height": height, "containLabel": is_contain_label, + "outerBoundsMode": outer_bounds_mode, + "outerBounds": outer_bounds_opts, + "outerBoundsContain": outer_bounds_contain, "backgroundColor": background_color, "borderColor": border_color, "borderWidth": border_width, @@ -939,6 +1167,13 @@ class GridOpts(BasicOpts): "shadowOffsetX": shadow_offset_x, "shadowOffsetY": shadow_offset_y, "tooltip": tooltip_opts, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, } @@ -1053,6 +1288,17 @@ class ParallelOpts(BasicOpts): pos_right: str = "13%", pos_bottom: str = "10%", pos_top: str = "20%", + z_level: Optional[Numeric] = None, + z: Optional[Numeric] = None, + width: Optional[str] = None, + height: Optional[str] = None, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, layout: Optional[str] = None, is_axis_expandable: bool = False, axis_expand_center: Optional[Numeric] = None, @@ -1065,6 +1311,17 @@ class ParallelOpts(BasicOpts): "right": pos_right, "bottom": pos_bottom, "top": pos_top, + "zlevel": z_level, + "z": z, + "width": width, + "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, "layout": layout, "axisExpandable": is_axis_expandable, "axisExpandCenter": axis_expand_center, @@ -1539,11 +1796,11 @@ class BlurOpts(BasicOpts): class SelectOpts(BasicOpts): def __init__( - self, - is_disabled: Optional[bool] = None, - itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, - linestyle_opts: Union[LineStyleOpts, dict, None] = None, - label_opts: Union[LabelOpts, dict, None] = None, + self, + is_disabled: Optional[bool] = None, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + linestyle_opts: Union[LineStyleOpts, dict, None] = None, + label_opts: Union[LabelOpts, dict, None] = None, ): self.opts: dict = { "disabled": is_disabled, @@ -1569,3 +1826,273 @@ class TreeLeavesOpts(BasicOpts): "blur": blur_opts, "select": select_opts, } + + +class MatrixDividerLineStyleOpts(BasicOpts): + def __init__( + self, + color: Optional[str] = "#aaa", + width: Optional[Numeric] = 1, + type_: Optional[str] = "solid", + dash_offset: Optional[Numeric] = 0, + cap: Optional[str] = "butt", + join: Optional[str] = "bevel", + miter_limit: Optional[Numeric] = 10, + shadow_blur: Optional[Numeric] = None, + shadow_color: Optional[str] = None, + shadow_offset_x: Optional[Numeric] = None, + shadow_offset_y: Optional[Numeric] = None, + opacity: Optional[Numeric] = 1, + ): + self.opts: dict = { + "color": color, + "width": width, + "type": type_, + "dashOffset": dash_offset, + "cap": cap, + "join": join, + "miterLimit": miter_limit, + "shadowBlur": shadow_blur, + "shadowColor": shadow_color, + "shadowOffsetX": shadow_offset_x, + "shadowOffsetY": shadow_offset_y, + "opacity": opacity, + } + + +class MatrixAxisDataOpts(BasicOpts): + def __init__( + self, + value: Union[Numeric, str] = None, + children: Union[dict, JSFunc, None] = None, + size: Optional[Numeric] = None, + ): + self.opts: dict = { + "value": value, + "children": children, + "size": size, + } + + +class MatrixAxisOpts(BasicOpts): + def __init__( + self, + is_show: bool = True, + data: Union[Sequence, dict, JSFunc, None] = None, + label_opts: Union[LabelOpts, dict, None] = None, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + is_silent: bool = False, + cursor: Optional[str] = None, + z2: Optional[Numeric] = None, + level_size: Union[Numeric, str, None] = None, + levels: Optional[Sequence] = None, + divider_line_style_opts: Union[ + MatrixDividerLineStyleOpts, dict, None, + ] = None, + ): + self.opts: dict = { + "show": is_show, + "data": data, + "label": label_opts, + "itemStyle": itemstyle_opts, + "silent": is_silent, + "cursor": cursor, + "z2": z2, + "levelSize": level_size, + "levels": levels, + "dividerLineStyle": divider_line_style_opts, + } + + +class MatrixBodyDataOpts(BasicOpts): + def __init__( + self, + coord: Optional[Sequence] = None, + is_coord_clamp: Optional[bool] = None, + is_merge_cells: Optional[bool] = None, + value: Union[Numeric, str, None] = None, + label_opts: Union[LabelOpts, dict, None] = None, + ): + self.opts: dict = { + "coord": coord, + "coordClamp": is_coord_clamp, + "mergeCells": is_merge_cells, + "value": value, + "label": label_opts, + } + + +class MatrixBodyOrCornerOpts(BasicOpts): + def __init__( + self, + data: Union[Sequence[MatrixBodyDataOpts], dict, None] = None, + label_opts: Union[LabelOpts, dict, None] = None, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + is_silent: bool = False, + cursor: Optional[str] = None, + z2: Optional[Numeric] = None, + ): + self.opts: dict = { + "data": data, + "label": label_opts, + "itemStyle": itemstyle_opts, + "silent": is_silent, + "cursor": cursor, + "z2": z2, + } + + +class MatrixBackgroundStyleOpts(BasicOpts): + def __init__( + self, + color: Optional[str] = None, + border_color: str = "#ccc", + border_width: Numeric = 1, + border_type: str = "solid", + border_radius: Union[Numeric, Sequence] = 0, + border_cap: str = "butt", + border_join: str = "bevel", + border_miter_limit: Optional[Numeric] = 10, + shadow_blur: Optional[Numeric] = None, + shadow_color: Optional[str] = None, + shadow_offset_x: Numeric = 0, + shadow_offset_y: Numeric = 0, + opacity: Optional[Numeric] = 1, + ): + self.opts: dict = { + "color": color, + "borderColor": border_color, + "borderWidth": border_width, + "borderType": border_type, + "borderRadius": border_radius, + "borderCap": border_cap, + "borderJoin": border_join, + "borderMiterLimit": border_miter_limit, + "shadowBlur": shadow_blur, + "shadowColor": shadow_color, + "shadowOffsetX": shadow_offset_x, + "shadowOffsetY": shadow_offset_y, + "opacity": opacity, + } + + +class MatrixOpts(BasicOpts): + def __init__( + self, + z_level: Numeric = 0, + z: Numeric = 2, + pos_left: Union[Numeric, str, None] = None, + pos_top: Union[Numeric, str, None] = None, + pos_right: Union[Numeric, str, None] = None, + pos_bottom: Union[Numeric, str, None] = None, + width: Union[Numeric, str, None] = None, + height: Union[Numeric, str, None] = None, + x_data: Union[MatrixAxisOpts, dict, None] = None, + y_data: Union[MatrixAxisOpts, dict, None] = None, + body_opts: Union[MatrixBodyOrCornerOpts, dict, None] = None, + corner_opts: Union[MatrixBodyOrCornerOpts, dict, None] = None, + background_style: Union[MatrixBackgroundStyleOpts, dict, None] = None, + border_z2: Optional[Numeric] = None, + tooltip_opts: TooltipOpts = None, + ): + self.opts: dict = { + "zlevel": z_level, + "z": z, + "left": pos_left, + "top": pos_top, + "right": pos_right, + "bottom": pos_bottom, + "width": width, + "height": height, + "x": x_data, + "y": y_data, + "body": body_opts, + "corner": corner_opts, + "backgroundStyle": background_style, + "borderZ2": border_z2, + "tooltip": tooltip_opts, + } + + +class ThumbnailWindowStyleOpts(BasicOpts): + def __init__( + self, + color: Optional[str] = "#9ea0a5", + border_color: str = "#b7b9be", + border_width: Numeric = 1, + border_type: str = "solid", + border_dash_offset: Numeric = 0, + border_cap: str = "butt", + border_join: str = "bevel", + border_miter_limit: Optional[Numeric] = 10, + shadow_blur: Optional[Numeric] = None, + shadow_color: Optional[str] = None, + shadow_offset_x: Numeric = 0, + shadow_offset_y: Numeric = 0, + opacity: Optional[Numeric] = 0.3, + ): + self.opts: dict = { + "color": color, + "borderColor": border_color, + "borderWidth": border_width, + "borderType": border_type, + "borderDashOffset": border_dash_offset, + "borderCap": border_cap, + "borderJoin": border_join, + "borderMiterLimit": border_miter_limit, + "shadowBlur": shadow_blur, + "shadowColor": shadow_color, + "shadowOffsetX": shadow_offset_x, + "shadowOffsetY": shadow_offset_y, + "opacity": opacity, + } + + +class ThumbnailOpts(BasicOpts): + def __init__( + self, + is_show: bool = True, + z_level: Numeric = 0, + z: Numeric = 2, + pos_left: Union[Numeric, str, None] = None, + pos_top: Union[Numeric, str, None] = None, + pos_right: Union[Numeric, str, None] = None, + pos_bottom: Union[Numeric, str, None] = None, + width: Union[Numeric, str, None] = None, + height: Union[Numeric, str, None] = None, + coordinate_system: Optional[str] = None, + coordinate_system_usage: Optional[str] = None, + coord: Optional[Union[Sequence, Numeric, str]] = None, + calendar_index: Optional[Numeric] = None, + calendar_id: Optional[Numeric] = None, + matrix_index: Optional[Numeric] = None, + matrix_id: Optional[Numeric] = None, + itemstyle_opts: Union[ItemStyleOpts, dict, None] = None, + window_style_opts: Union[ + ThumbnailWindowStyleOpts, dict, None, + ] = None, + series_index: Optional[Numeric] = None, + series_id: Union[Numeric, str, None] = None, + ): + self.opts: dict = { + "show": is_show, + "zlevel": z_level, + "z": z, + "left": pos_left, + "top": pos_top, + "right": pos_right, + "bottom": pos_bottom, + "width": width, + "height": height, + "coordinateSystem": coordinate_system, + "coordinateSystemUsage": coordinate_system_usage, + "coord": coord, + "calendarIndex": calendar_index, + "calendarId": calendar_id, + "matrixIndex": matrix_index, + "matrixId": matrix_id, + "itemStyle": itemstyle_opts, + "windowStyle": window_style_opts, + "seriesIndex": series_index, + "seriesId": series_id, + } diff --git a/pyecharts/options/series_options.py b/pyecharts/options/series_options.py index 8117811c..7e59a436 100644 --- a/pyecharts/options/series_options.py +++ b/pyecharts/options/series_options.py @@ -87,6 +87,7 @@ class TextStyleOpts(BasicOpts): width: Optional[str] = None, height: Optional[str] = None, rich: Optional[dict] = None, + is_rich_inherit_plain_label: bool = True, ): self.opts: dict = { "color": color, @@ -107,6 +108,7 @@ class TextStyleOpts(BasicOpts): "width": width, "height": height, "rich": rich, + "richInheritPlainLabel": is_rich_inherit_plain_label, } @@ -116,13 +118,17 @@ class LabelOpts(BasicOpts): is_show: bool = True, position: Optional[Union[str, Sequence]] = None, color: Optional[str] = None, + opacity: Optional[Numeric] = None, distance: Union[Numeric, Sequence, None] = None, font_size: Optional[Numeric] = None, font_style: Optional[str] = None, font_weight: Optional[str] = None, font_family: Optional[str] = None, rotate: Optional[Numeric] = None, + offset: Optional[Sequence[Numeric]] = None, margin: Optional[Numeric] = 8, + text_margin: Union[Numeric, Sequence, None] = None, + min_margin: Optional[Numeric] = None, interval: Union[Numeric, str, None] = None, horizontal_align: Optional[str] = None, vertical_align: Optional[str] = None, @@ -140,18 +146,23 @@ class LabelOpts(BasicOpts): text_shadow_blur: Optional[Numeric] = None, text_shadow_offset_x: Optional[Numeric] = None, text_shadow_offset_y: Optional[Numeric] = None, - offset: Optional[Sequence[Numeric]] = None, overflow: Optional[str] = None, rich: Optional[dict] = None, + is_rich_inherit_plain_label: bool = True, is_value_animation: bool = False, + text_style_opts: Optional[TextStyleOpts] = None, ): self.opts: dict = { "show": is_show, "position": position, "color": color, + "opacity": opacity, "distance": distance, "rotate": rotate, + "offset": offset, "margin": margin, + "textMargin": text_margin, + "minMargin": min_margin, "interval": interval, "fontSize": font_size, "fontStyle": font_style, @@ -175,18 +186,20 @@ class LabelOpts(BasicOpts): "textShadowOffsetY": text_shadow_offset_y, "overflow": overflow, "rich": rich, + "richInheritPlainLabel": is_rich_inherit_plain_label, "valueAnimation": is_value_animation, + "textStyle": text_style_opts, } class LineStyleOpts(BasicOpts): def __init__( self, - is_show: bool = True, - width: Numeric = 1, - opacity: Numeric = 1, - curve: Numeric = 0, - type_: str = "solid", + is_show: bool = False, + width: Optional[Numeric] = None, + opacity: Optional[Numeric] = None, + curve: Optional[Numeric] = None, + type_: Optional[str] = None, color: Union[str, Sequence, None] = None, ): self.opts: dict = { @@ -432,8 +445,23 @@ class Lines3DEffectOpts(BasicOpts): class AreaStyleOpts(BasicOpts): - def __init__(self, opacity: Optional[Numeric] = 0, color: Optional[JSFunc] = None): - self.opts: dict = {"opacity": opacity, "color": color} + def __init__( + self, + opacity: Optional[Numeric] = 0, + color: Optional[JSFunc] = None, + shadow_blur: Optional[Numeric] = None, + shadow_color: Optional[str] = None, + shadow_offset_x: Optional[Numeric] = None, + shadow_offset_y: Optional[Numeric] = None, + ): + self.opts: dict = { + "opacity": opacity, + "color": color, + "shadowBlur": shadow_blur, + "shadowColor": shadow_color, + "shadowOffsetX": shadow_offset_x, + "shadowOffsetY": shadow_offset_y, + } class SplitAreaOpts(BasicOpts): diff --git a/pyecharts/types.py b/pyecharts/types.py index a78ad851..8784e12e 100644 --- a/pyecharts/types.py +++ b/pyecharts/types.py @@ -11,6 +11,7 @@ from typing import ( ) from . import options as opts +from .options import ThumbnailOpts from .options.charts_options import BaseGraphic, GlobeLayersOpts from .options.series_options import JsCode, JSFunc, Numeric @@ -54,6 +55,7 @@ Map3DViewControl = Union[opts.Map3DViewControlOpts, dict, None] MarkArea = Union[opts.MarkAreaOpts, dict, None] MarkPoint = Union[opts.MarkPointOpts, dict, None] MarkLine = Union[opts.MarkLineOpts, dict, None] +Matrix = Union[opts.MatrixOpts, dict, None] MinorTick = Union[opts.MinorTickOpts, dict, None] Label = Union[opts.LabelOpts, dict, None] Legend = Union[opts.LegendOpts, dict] @@ -62,6 +64,7 @@ Lines3DEffect = Union[opts.Lines3DEffectOpts, dict, None] PieLabelLine = Union[opts.PieLabelLineOpts, dict, None] PieEmptyCircle = Union[opts.PieEmptyCircleStyle, dict, None] TextStyle = Union[opts.TextStyleOpts, dict, None] +Thumbnail = Union[ThumbnailOpts, dict, None] TimeLineControl = Union[opts.TimelineControlStyle, dict, None] TimeLinkCheckPoint = Union[opts.TimelineCheckPointerStyle, dict, None] Title = Union[opts.TitleOpts, dict] @@ -83,6 +86,20 @@ CalendarDayLabelOpts = Union[opts.CalendarDayLabelOpts, dict, None] CalendarMonthLabelOpts = Union[opts.CalendarMonthLabelOpts, dict, None] CalendarYearLabelOpts = Union[opts.CalendarYearLabelOpts, dict, None] +CustomItemPayload = Union[ + opts.CustomBarRangeItemPayloadOpts, + opts.CustomContourItemPayloadOpts, + opts.CustomLineRangeItemPayloadOpts, + opts.CustomSegmentedDoughnutItemPayloadOpts, + opts.CustomStageItemPayloadOpts, + opts.CustomViolinItemPayloadOpts, + dict, + None, +] + +ChordData = Union[opts.ChordData, dict] +ChordLink = Union[opts.ChordLink, dict] + GraphNode = Union[opts.GraphNode, dict] GraphLink = Union[opts.GraphLink, dict] GraphCategory = Union[opts.GraphCategory, dict] diff --git a/test/test_bar.py b/test/test_bar.py index 4454d994..95c7d50d 100644 --- a/test/test_bar.py +++ b/test/test_bar.py @@ -146,7 +146,7 @@ class TestBarChart(unittest.TestCase): @patch("pyecharts.render.engine.write_utf8_html_file") def test_bar_colors(self, fake_writer): c = Bar().add_xaxis(["A", "B", "C"]).add_yaxis("series0", [1, 2, 4]) - c.set_colors(["#AABBCC", "#BBCCDD", "#CCDDEE"] + c.colors) + c.set_colors(["#AABBCC", "#BBCCDD", "#CCDDEE"]) c.render() _, content = fake_writer.call_args[0] self.assertIn("#AABBCC", content) @@ -206,9 +206,9 @@ class TestBarChart(unittest.TestCase): def test_bar_default_remote_host(self, fake_writer): c = Bar().add_xaxis(["A", "B", "C"]).add_yaxis("series0", [1, 2, 4]) c.render() - self.assertEqual(c.js_host, "https://assets.pyecharts.org/assets/v5/") + self.assertEqual(c.js_host, "https://assets.pyecharts.org/assets/v6/") _, content = fake_writer.call_args[0] - self.assertIn("https://assets.pyecharts.org/assets/v5/echarts.min.js", content) + self.assertIn("https://assets.pyecharts.org/assets/v6/echarts.min.js", content) @patch("pyecharts.render.engine.write_utf8_html_file") def test_bar_custom_remote_host(self, fake_writer): diff --git a/test/test_chart.py b/test/test_chart.py index e40b42bc..30b032ef 100644 --- a/test/test_chart.py +++ b/test/test_chart.py @@ -181,19 +181,10 @@ class TestChartClass(unittest.TestCase): ) c.render() _, content = fake_writer.call_args[0] - # Old Version (Before 2.0) - # default_colors = ( - # "#c23531 #2f4554 #61a0a8 #d48265 #749f83 #ca8622 #bda29a #6e7074 " - # "#546570 #c4ccd3 #f05b72 #ef5b9c #f47920 #905a3d #fab27b #2a5caa " - # "#444693 #726930 #b2d235 #6d8346 #ac6767 #1d953f #6950a1 #918597" - # ).split() # New Version - default_colors = ( - "#5470c6 #91cc75 #fac858 #ee6666 #73c0de #3ba272 #fc8452 #9a60b4 " "#ea7ccc" - ).split() - expected_result = ["#80FFA5", "#00DDFF", *default_colors] - self.assertEqual(c.colors, expected_result) + expected_result = ["#80FFA5", "#00DDFF"] + self.assertEqual(c.options.get("color"), expected_result) @patch("pyecharts.render.engine.write_utf8_html_file") def test_chart_add_dataset(self, fake_writer): diff --git a/test/test_chart_options.py b/test/test_chart_options.py index 8cc273be..45769ee7 100644 --- a/test/test_chart_options.py +++ b/test/test_chart_options.py @@ -3,6 +3,12 @@ import unittest from pyecharts.commons.utils import remove_key_with_none_value from pyecharts.options.charts_options import ( BarBackgroundStyleOpts, + CustomBarRangeItemPayloadOpts, + CustomContourItemPayloadOpts, + CustomLineRangeItemPayloadOpts, + CustomSegmentedDoughnutItemPayloadOpts, + CustomStageItemPayloadOpts, + CustomViolinItemPayloadOpts, GlobeLayersOpts, GraphCategory, SunburstLevelOpts, @@ -148,3 +154,28 @@ class TestChartOptions(unittest.TestCase): option = SunburstLevelOpts() expected = {} self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_custom_item_payload_opts_remove_none(self): + option = CustomBarRangeItemPayloadOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + option = CustomContourItemPayloadOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + option = CustomLineRangeItemPayloadOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + option = CustomSegmentedDoughnutItemPayloadOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + option = CustomStageItemPayloadOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + option = CustomViolinItemPayloadOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) diff --git a/test/test_chord.py b/test/test_chord.py new file mode 100644 index 00000000..348f71f3 --- /dev/null +++ b/test/test_chord.py @@ -0,0 +1,48 @@ +import unittest +from unittest.mock import patch + +from pyecharts import options as opts +from pyecharts.charts import Chord + + +class TestChordChart(unittest.TestCase): + + @patch("pyecharts.render.engine.write_utf8_html_file") + def test_chord_base(self, fake_writer): + c = ( + Chord() + .add( + series_name="chord", + data=[ + opts.ChordData(name="A"), + opts.ChordData(name="B"), + opts.ChordData(name="C"), + opts.ChordData(name="D"), + ], + links=[ + opts.ChordLink( + source="A", + target="B", + value=40, + ), + opts.ChordLink( + source="A", + target="C", + value=20, + ), + opts.ChordLink( + source="B", + target="D", + value=20, + ), + ], + is_clockwise=False, + label_opts=opts.LabelOpts(is_show=True), + linestyle_opts=opts.LineStyleOpts(color="target"), + ) + ) + c.render() + _, content = fake_writer.call_args[0] + self.assertGreater(len(content), 2000) + self.assertEqual(c.theme, "white") + self.assertEqual(c.renderer, "canvas") diff --git a/test/test_custom.py b/test/test_custom.py index b3e5915c..1aee04b4 100644 --- a/test/test_custom.py +++ b/test/test_custom.py @@ -3,6 +3,7 @@ from unittest.mock import patch from pyecharts.charts import Custom from pyecharts.commons.utils import JsCode +from pyecharts.globals import ChartType class TestCustom(unittest.TestCase): @@ -42,3 +43,32 @@ class TestCustom(unittest.TestCase): _, content = fake_writer.call_args[0] self.assertGreater(len(content), 2000) self.assertIn("renderItem", content) + + def test_custom_echarts_x_with_error(self): + c = Custom() + try: + c.register_echarts_x(chart_type=ChartType.LINE) + except ValueError: + pass + + @patch("pyecharts.render.engine.write_utf8_html_file") + def test_custom_echarts_x(self, fake_writer): + for chart_type in [ + ChartType.VIOLIN, + ChartType.STAGE, + ChartType.DOUGHNUT, + ChartType.CONTOUR, + ChartType.BAR_RANGE, + ChartType.LINE_RANGE, + ]: + c = ( + Custom() + .register_echarts_x(chart_type=chart_type) + .add(series_name="test", render_item=chart_type) + ) + if chart_type != ChartType.DOUGHNUT: + c.add_xaxis(xaxis_data=["a", "b", "c"]) + c.render() + _, content = fake_writer.call_args[0] + self.assertIn("renderItem", content) + self.assertIn("xAxis", content) diff --git a/test/test_global_options.py b/test/test_global_options.py index 3eb01ddc..1725b597 100644 --- a/test/test_global_options.py +++ b/test/test_global_options.py @@ -7,12 +7,25 @@ from pyecharts.options.global_options import ( AngleAxisOpts, AriaLabelOpts, AriaDecalOpts, + AxisBreakOpts, + AxisBreakAreaOpts, + AxisBreakLabelLayoutOpts, AxisTickOpts, BlurOpts, CalendarYearLabelOpts, DatasetTransformOpts, Emphasis3DOpts, + GridOuterOpts, InitOpts, + MatrixDividerLineStyleOpts, + MatrixAxisDataOpts, + MatrixAxisOpts, + MatrixBodyDataOpts, + MatrixBodyOrCornerOpts, + MatrixBackgroundStyleOpts, + MatrixOpts, + ThumbnailWindowStyleOpts, + ThumbnailOpts, ParallelAxisOpts, RadiusAxisItem, RadiusAxisOpts, @@ -236,6 +249,7 @@ class TestGlobalOptions(unittest.TestCase): "selectorPosition": "auto", "selectorItemGap": 7, "selectorButtonGap": 10, + "triggerEvent": False, } self.assertEqual(expected, remove_key_with_none_value(option.opts)) @@ -260,6 +274,16 @@ class TestGlobalOptions(unittest.TestCase): } self.assertEqual(expected, remove_key_with_none_value(option.opts)) + def test_visual_map_continuous_options(self): + option = VisualMapOpts( + type_="continuous", + range_color=["red", "yellow"] + ) + self.assertEqual( + option.opts.get("inRange").get("color"), + ["red", "yellow"], + ) + def test_tool_tip_options_remove_none(self): option = TooltipOpts(textstyle_opts=None) expected = { @@ -267,16 +291,17 @@ class TestGlobalOptions(unittest.TestCase): "axisPointer": {"type": "line"}, "borderWidth": 0, "hideDelay": 100, + "confine": False, + "displayTransition": True, + "enterable": False, + 'order': 'seriesAsc', "padding": 5, "show": True, "showContent": True, "showDelay": 0, "trigger": "item", - "enterable": False, - "confine": False, "appendToBody": False, "transitionDuration": 0.4, - "order": "seriesAsc", "triggerOn": "mousemove|click", } self.assertEqual(expected, remove_key_with_none_value(option.opts)) @@ -372,3 +397,107 @@ class TestGlobalOptions(unittest.TestCase): option = SelectOpts() expected = {} self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_axis_break_opts_remove_none(self): + option = AxisBreakOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_axis_break_area_opts_remove_none(self): + option = AxisBreakAreaOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_axis_break_label_layout_opts_remove_none(self): + option = AxisBreakLabelLayoutOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_grid_outer_opts_remove_none(self): + option = GridOuterOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_divider_line_style_opts_remove_none(self): + option = MatrixDividerLineStyleOpts() + expected = { + "color": "#aaa", + "width": 1, + "type": "solid", + "dashOffset": 0, + "cap": "butt", + "join": "bevel", + "miterLimit": 10, + "opacity": 1, + } + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_axis_data_opts_remove_none(self): + option = MatrixAxisDataOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_axis_opts_remove_none(self): + option = MatrixAxisOpts() + expected = { + "show": True, + "silent": False, + } + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_body_data_opts_remove_none(self): + option = MatrixBodyDataOpts() + expected = {} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_body_or_corner_opts_remove_none(self): + option = MatrixBodyOrCornerOpts() + expected = {"silent": False} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_background_style_opts_remove_none(self): + option = MatrixBackgroundStyleOpts() + expected = { + "borderColor": "#ccc", + "borderWidth": 1, + "borderType": "solid", + "borderRadius": 0, + "borderCap": "butt", + "borderJoin": "bevel", + "borderMiterLimit": 10, + "shadowOffsetX": 0, + "shadowOffsetY": 0, + "opacity": 1, + } + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_matrix_opts_remove_none(self): + option = MatrixOpts() + expected = {"zlevel": 0, "z": 2} + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_thumbnail_window_style_opts_remove_none(self): + option = ThumbnailWindowStyleOpts() + expected = { + "color": "#9ea0a5", + "borderColor": "#b7b9be", + "borderWidth": 1, + "borderType": "solid", + "borderDashOffset": 0, + "borderCap": "butt", + "borderJoin": "bevel", + "borderMiterLimit": 10, + "shadowOffsetX": 0, + "shadowOffsetY": 0, + "opacity": 0.3, + } + self.assertEqual(expected, remove_key_with_none_value(option.opts)) + + def test_thumbnail_opts_remove_none(self): + option = ThumbnailOpts() + expected = { + "show": True, + "zlevel": 0, + "z": 2, + } + self.assertEqual(expected, remove_key_with_none_value(option.opts)) diff --git a/test/test_grid.py b/test/test_grid.py index 44a53eda..58c02d8b 100644 --- a/test/test_grid.py +++ b/test/test_grid.py @@ -318,7 +318,8 @@ class TestGridComponent(unittest.TestCase): ) bar.overlap(line) - self.assertEqual(bar.colors[:3], ["red", "green", "blue"]) + self.assertEqual(bar.options.get("color")[:3], + ["red", "green", "blue"]) return bar @patch("pyecharts.render.engine.write_utf8_html_file") @@ -615,3 +616,32 @@ class TestGridComponent(unittest.TestCase): grid_chart.render() _, content = fake_writer.call_args[0] self.assertIn("geo", content) + + @patch("pyecharts.render.engine.write_utf8_html_file") + def test_grid_multi_geo(self, fake_writer): + data_pair = [list(z) for z in zip(Faker.provinces, Faker.values())] + + grid_chart = Grid(init_opts=opts.InitOpts()) + geo_charts_len = 2 + for i in range(geo_charts_len): + geo_chart = ( + Geo() + .add_schema(maptype="china") + .add( + f"geo_{i}", + data_pair=data_pair, + type_=ChartType.SCATTER, + ) + .set_global_opts( + visualmap_opts=opts.VisualMapOpts(), + ) + ) + grid_chart.add( + chart=geo_chart, + grid_opts=opts.GridOpts(), + ) + + grid_chart.render() + _, content = fake_writer.call_args[0] + self.assertIn("geo", content) + self.assertEqual(len(grid_chart.options.get("geo")), geo_charts_len) diff --git a/test/test_map.py b/test/test_map.py index 2c89716a..96b77c13 100644 --- a/test/test_map.py +++ b/test/test_map.py @@ -46,8 +46,16 @@ class TestMapChart(unittest.TestCase): ) options = json.loads(c.dump_options()) expected = { - "label": {"show": False, "margin": 8, "valueAnimation": False}, - "itemStyle": {"borderColor": "white", "areaColor": "red"}, + "label": { + "show": False, + "richInheritPlainLabel": True, + "margin": 8, + "valueAnimation": False, + }, + "itemStyle": { + "borderColor": "white", + "areaColor": "red", + }, } self.assertEqual(expected, options["series"][0]["emphasis"]) diff --git a/test/test_page.py b/test/test_page.py index e916603b..17c40732 100644 --- a/test/test_page.py +++ b/test/test_page.py @@ -53,7 +53,7 @@ class TestPageComponent(unittest.TestCase): bar = _create_bar() line = _create_line() page = Page().add(bar, line) - self.assertEqual(page.js_host, "https://assets.pyecharts.org/assets/v5/") + self.assertEqual(page.js_host, "https://assets.pyecharts.org/assets/v6/") def test_page_jshost_custom(self): from pyecharts.globals import CurrentConfig @@ -85,7 +85,7 @@ class TestPageComponent(unittest.TestCase): content = Page().add(bar, line).load_javascript() self.assertEqual("", content.data) self.assertEqual( - ["https://assets.pyecharts.org/assets/v5/echarts.min.js"], content.lib + ["https://assets.pyecharts.org/assets/v6/echarts.min.js"], content.lib ) def _get_new_page(self, unique: bool = True) -> Page: diff --git a/test/test_series_options.py b/test/test_series_options.py index 836a32fc..6f36fac6 100644 --- a/test/test_series_options.py +++ b/test/test_series_options.py @@ -27,6 +27,9 @@ class TestSeriesOptions(unittest.TestCase): "distance": None, "rotate": None, "margin": 8, + "minMargin": None, + "offset": None, + "opacity": None, "interval": None, "fontSize": None, "fontStyle": None, @@ -44,12 +47,15 @@ class TestSeriesOptions(unittest.TestCase): "height": None, "textBorderColor": None, "textBorderWidth": None, + "textMargin": None, "textShadowColor": None, "textShadowBlur": None, "textShadowOffsetX": None, "textShadowOffsetY": None, + "textStyle": None, "overflow": None, "rich": None, + "richInheritPlainLabel": True, "valueAnimation": False, } self.assertEqual(expected, option.opts) @@ -74,6 +80,9 @@ class TestSeriesOptions(unittest.TestCase): "distance": None, "rotate": None, "margin": 8, + "minMargin": None, + "offset": None, + "opacity": None, "interval": None, "fontSize": None, "fontStyle": None, @@ -95,8 +104,11 @@ class TestSeriesOptions(unittest.TestCase): "textShadowBlur": .1, "textShadowOffsetX": .2, "textShadowOffsetY": .3, + "textMargin": None, + "textStyle": None, "overflow": None, "rich": None, + "richInheritPlainLabel": True, "valueAnimation": False, } self.assertEqual(expected, option.opts) diff --git a/test/test_tab.py b/test/test_tab.py index afaa3530..30583487 100644 --- a/test/test_tab.py +++ b/test/test_tab.py @@ -63,10 +63,10 @@ class TestTabComponent(unittest.TestCase): html = tab.render_notebook().__html__() self.assertIn("City name", html) - def test_page_jshost_default(self): + def test_tab_jshost_default(self): bar = _create_bar() tab = Tab().add(bar, "bar") - self.assertEqual(tab.js_host, "https://assets.pyecharts.org/assets/v5/") + self.assertEqual(tab.js_host, "https://assets.pyecharts.org/assets/v6/") def test_tab_jshost_custom(self): from pyecharts.globals import CurrentConfig