mirror of
https://github.com/pyecharts/pyecharts.git
synced 2025-12-08 20:59:23 +00:00
Add: mypy checker (#1106)
This commit is contained in:
parent
002c578b0c
commit
d7bb09a71b
3
.gitignore
vendored
3
.gitignore
vendored
@ -99,3 +99,6 @@ ENV/
|
||||
# example
|
||||
example/*.png
|
||||
example/*.html
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
|
||||
@ -21,7 +21,7 @@ class Base:
|
||||
`Base`类是所有图形类的基类,提供部分初始化参数和基本的方法
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[InitOpts, dict] = InitOpts()):
|
||||
def __init__(self, init_opts: InitOpts = InitOpts()):
|
||||
self.width = init_opts.width
|
||||
self.height = init_opts.height
|
||||
self.renderer = init_opts.renderer
|
||||
|
||||
@ -12,7 +12,7 @@ class Bar(RectChart):
|
||||
with heights or lengths proportional to the values that they represent.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ class BMap(GeoChartBase):
|
||||
Support scatter plot, line
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.js_dependencies.add("bmap")
|
||||
self._is_geo_chart = True
|
||||
|
||||
@ -13,7 +13,7 @@ class Boxplot(RectChart):
|
||||
of a set of data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
|
||||
@ -12,7 +12,7 @@ class Calendar(Chart):
|
||||
Two categories of axes must be used in rectangular coordinates.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(calendar=opts.CalendarOpts().opts)
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class EffectScatter(RectChart):
|
||||
Use animation effects to visually highlight designated data set.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ class Funnel(Chart):
|
||||
and then decisions can be made.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -11,7 +11,7 @@ class Gauge(Chart):
|
||||
The gauge displays a single key business measure.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -9,7 +9,7 @@ from ...globals import ChartType, TooltipFormatterType
|
||||
|
||||
|
||||
class GeoChartBase(Chart):
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.set_global_opts()
|
||||
self._coordinates = COORDINATES
|
||||
@ -27,7 +27,7 @@ class GeoChartBase(Chart):
|
||||
self.add_coordinate(k, v[0], v[1])
|
||||
return self
|
||||
|
||||
def get_coordinate(self, name: str) -> Sequence:
|
||||
def get_coordinate(self, name: str) -> Optional[Sequence]:
|
||||
if name in self._coordinates:
|
||||
return self._coordinates[name]
|
||||
|
||||
@ -165,7 +165,7 @@ class Geo(GeoChartBase):
|
||||
support scatter plot and line
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self._coordinate_system: Optional[str] = "geo"
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class Graph(Chart):
|
||||
The graph is used to represent the relational data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -13,7 +13,7 @@ class HeatMap(RectChart):
|
||||
Two categories of axes must be used in rectangular coordinates.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
self.set_global_opts(visualmap_opts=opts.VisualMapOpts(orient="horizontal"))
|
||||
|
||||
@ -12,7 +12,7 @@ class Line(RectChart):
|
||||
with single line to show the change trend of data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class Liquid(Chart):
|
||||
The liquid chart is mainly used to highlight the percentage of data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.js_dependencies.add("echarts-liquidfill")
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class Map(Chart):
|
||||
Map are mainly used for visualization of geographic area data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -12,7 +12,7 @@ class Parallel(Chart):
|
||||
high dimensional data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(parallel=opts.ParallelOpts().opts)
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ class Pie(Chart):
|
||||
the number of data points.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -11,7 +11,7 @@ class Polar(Chart):
|
||||
Polar coordinates can be used for scatter and polyline graphs.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.add_schema()
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class Radar(Chart):
|
||||
Radar maps are mainly used to represent multivariable data.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add_schema(
|
||||
@ -56,15 +56,6 @@ class Radar(Chart):
|
||||
areastyle_opts: opts.AreaStyleOpts = opts.AreaStyleOpts(),
|
||||
tooltip_opts: Union[opts.TooltipOpts, dict, None] = None,
|
||||
):
|
||||
if isinstance(label_opts, opts.LabelOpts):
|
||||
label_opts = label_opts.opts
|
||||
if isinstance(linestyle_opts, opts.LineStyleOpts):
|
||||
linestyle_opts = linestyle_opts.opts
|
||||
if isinstance(areastyle_opts, opts.AreaStyleOpts):
|
||||
areastyle_opts = areastyle_opts.opts
|
||||
if isinstance(tooltip_opts, opts.TooltipOpts):
|
||||
tooltip_opts = tooltip_opts.opts
|
||||
|
||||
self._append_legend(series_name, is_selected)
|
||||
self.options.get("series").append(
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ class Sankey(Chart):
|
||||
the intermediate process of processing, transformation to the final form.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -14,7 +14,7 @@ class Scatter(RectChart):
|
||||
visualmap component can be used.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options.update(yAxis=[opts.AxisOpts().opts])
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@ class Sunburst(Chart):
|
||||
hierarchical relationships like rectangle tree graphs.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -13,7 +13,7 @@ class ThemeRiver(Chart):
|
||||
over a period of time.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -13,7 +13,7 @@ class Tree(Chart):
|
||||
and right subtrees.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@ -12,7 +12,7 @@ class TreeMap(Chart):
|
||||
It mainly uses area to highlight the important nodes in the hierarchy of "tree".
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
|
||||
def add(
|
||||
|
||||
@ -27,7 +27,7 @@ class WordCloud(Chart):
|
||||
appear frequently in the text.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.js_dependencies.add("echarts-wordcloud")
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ class Chart(Base):
|
||||
`Chart`类是所有非自定义类的基类,继承自 `Base` 类
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.colors = (
|
||||
"#c23531 #2f4554 #61a0a8 #d48265 #749f83 #ca8622 #bda29a #6e7074 "
|
||||
@ -198,12 +198,12 @@ class Chart3D(Chart):
|
||||
`Chart3D`类是所有 3D 类图表的基类,继承自 `Chart` 类
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
init_opts.renderer = RenderType.CANVAS
|
||||
super().__init__(init_opts)
|
||||
self.js_dependencies.add("echarts-gl")
|
||||
self.options.update(visualMap=opts.VisualMapOpts().opts)
|
||||
self._3d_chart_type = None # 3d chart type, don't use it directly
|
||||
self._3d_chart_type: Optional[str] = None # 3d chart type,don't use it directly
|
||||
|
||||
def add(
|
||||
self,
|
||||
|
||||
@ -13,7 +13,7 @@ class Grid(Base):
|
||||
and scatter chart (bubble chart) can be drawn in grid.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options: Optional[dict] = None
|
||||
self._axis_index: int = 0
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
from ... import options as opts
|
||||
from ...charts.chart import Base
|
||||
from ...commons.types import Numeric, Optional, Union
|
||||
from ...commons.types import Numeric, Optional, Union, Sequence
|
||||
|
||||
|
||||
class Timeline(Base):
|
||||
@ -8,11 +8,11 @@ class Timeline(Base):
|
||||
`Timeline` provides functions like switching and playing between multiple charts.
|
||||
"""
|
||||
|
||||
def __init__(self, init_opts: Union[opts.InitOpts, dict] = opts.InitOpts()):
|
||||
def __init__(self, init_opts: opts.InitOpts = opts.InitOpts()):
|
||||
super().__init__(init_opts=init_opts)
|
||||
self.options = {"baseOption": {"series": [], "timeline": {}}, "options": []}
|
||||
self.add_schema()
|
||||
self._time_points = []
|
||||
self._time_points: Sequence = []
|
||||
|
||||
def add_schema(
|
||||
self,
|
||||
|
||||
@ -19,7 +19,7 @@ class Table:
|
||||
self.page_title = page_title
|
||||
self.js_host = js_host
|
||||
self.js_dependencies: OrderedSet = OrderedSet("bulma")
|
||||
self._charts = []
|
||||
self._charts: Sequence = []
|
||||
|
||||
def add(self, headers: Sequence, rows: Sequence, attributes: Optional[dict] = None):
|
||||
|
||||
|
||||
@ -88,4 +88,4 @@ def save_as(image_data: bytes, output_name: str, file_type: str):
|
||||
b.paste(m, mask=m.split()[3])
|
||||
b.save(output_name, file_type, quality=100)
|
||||
except ModuleNotFoundError:
|
||||
raise Exception("Please install PIL for % image type" % file_type)
|
||||
raise Exception("Please install PIL for {} image type".format(file_type))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user