pyecharts中table
时间: 2023-10-27 15:08:18 浏览: 180
pyecharts中的Table类继承自基类ChartMixin,用于绘制表格。在使用Table类之前,需要先安装第三方库prettytable(pyecharts的依赖库)。Table类提供了add()方法来添加表格的表头和数据行,并通过set_global_opts()方法设置表格的标题和样式。在调用render()方法后,会生成一个HTML文件展示表格。
以下是一个简单的Table案例:
```python
from pyecharts.components import Table
table = Table()
headers = ["City name", "Area", "Population", "Annual Rainfall"]
rows = [
["Brisbane", 5905, 1857594, 1146.4],
["Adelaide", 1295, 1158259, 600.5],
["Darwin", 112, 120900, 1714.7],
["Hobart", 1357, 205556, 619.5],
["Sydney", 2058, 4336374, 1214.8],
["Melbourne", 1566, 3806092, 646.9],
["Perth", 5386, 1554769, 869.4],
]
table.add(headers, rows)
table.set_global_opts(
{"title": "Table-基本示例", "subtitle": "我是副标题支持换行哦", "title_style": "style='color:red'", "subtitle_style": "style='color:green'"}
)
table.render()
```
阅读全文