最近在学习pyecharts时,又发现了和它十分类似的模块——cutecharts,这个模块可以叫做pyecharts的姊妹,就和它的名字一样,制作的动态图十分cute。但是支持的图表类型不多,目前只支持条形图、折线图、饼图、雷达图、散点图。
cutecharts的项目结构与pyecharts以前版本基本相同,支持pyecharts的所有核心功能,但是不支持现在v1版本的pyecharts语法
cutecharts的具体的内容,可以参考cutecharts作者的Github,写的十分详细
cutecharts 项目地址:https://github.com/chenjiandongx/cutecharts/
安装
pip install cutecharts
from cutecharts.charts import Bar
from cutecharts.components import Page
from cutecharts.faker import Faker
def bar_base() -> Bar:
chart = Bar("Bar-基本示例")
chart.set_options(labels=Faker.choose(),
x_label="I'm xlabel",
y_label="I'm ylabel",
y_tick_count=10, #y轴刻度间距
colors=Faker.colors)
chart.add_series("series-A", Faker.values())
return chart
bar_base().render("bar_base.html")
"""
:param labels: X 坐标轴标签数据
:param x_label: X 坐标轴名称
:param y_label: Y 坐标轴名称
:param y_tick_count: Y 轴刻度分割段数
:param colors: label 颜色数组
:param font_family: CSS font-family
"""
"""
:param name: series 名称
:param data: series 数据列表
"""
from cutecharts.charts import Line
from cutecharts.components import Page
from cutecharts.faker import Faker
def line_base() -> Line:
chart = Line("Line-基本示例")
chart.set_options(labels=Faker.choose(),
x_label="I'm xlabel",
y_label="I'm ylabel",
legend_pos="upRight")
chart.add_series("series-A", Faker.values())
chart.add_series("series-B", Faker.values())
return chart
line_base().render('line_base.html')
"""
:param labels: X 坐标轴标签数据
:param x_label: X 坐标轴名称
:param y_label: Y 坐标轴名称
:param y_tick_count: Y 轴刻度分割段数
:param legend_pos: 图例位置,有 "upLeft", "upRight", "downLeft", "downRight" 可选
:param colors: label 颜色数组
:param font_family: CSS font-family
"""
"""
:param name: series 名称
:param data: series 数据列表
"""
from cutecharts.charts import Pie
from cutecharts.components import Page
from cutecharts.faker import Faker
def pie_base() -> Pie:
chart = Pie("Pie-基本示例")
chart.set_options(labels=Faker.choose(),
legend_pos="upRight",
font_family='"Times New Roman",Georgia,Serif;',)
chart.add_series(Faker.values())
return chart
pie_base().render('pie_base.html')
"""
:param labels: 数据标签列表
:param inner_radius: Pie 图半径
:param legend_pos: 图例位置,有 "upLeft", "upRight", "downLeft", "downRight" 可选
:param colors: label 颜色数组
:param font_family: CSS font-family
"""
"""
:param data: series 数据列表
"""
from cutecharts.charts import Pie
from cutecharts.components import Page
from cutecharts.faker import Faker
def pie_base() -> Pie:
chart = Pie("Pie-基本示例")
chart.set_options(labels=Faker.choose(),
legend_pos="upRight",
font_family='"Times New Roman",Georgia,Serif;',
inner_radius=0,
)
chart.add_series(Faker.values())
return chart
pie_base().render('pie_base.html')
from cutecharts.charts import Radar
from cutecharts.components import Page
from cutecharts.faker import Faker
def radar_base() -> Radar:
chart = Radar("Radar-基本示例")
chart.set_options(labels=Faker.choose(),
colors=Faker.colors,
legend_pos="upRight") #downLeft
chart.add_series("series-A", Faker.values())
chart.add_series("series-B", Faker.values())
return chart
radar_base().render('radar_base.html')
from cutecharts.charts import Scatter
from cutecharts.components import Page
from cutecharts.faker import Faker
def scatter_base() -> Scatter:
chart = Scatter("Scatter-基本示例")
chart.set_options(x_label="I'm xlabel",
y_label="I'm ylabel",
dot_size=2, # Scatter-散点大小
y_tick_count=10)
chart.add_series(
"series-A", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]
)
chart.add_series(
"series-B", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]
)
return chart
scatter_base().render('scatter_base.html')
from cutecharts.charts import Scatter
from cutecharts.components import Page
from cutecharts.faker import Faker
def scatter_base() -> Scatter:
chart = Scatter("Scatter-基本示例")
chart.set_options(x_label="I'm xlabel",
y_label="I'm ylabel",
dot_size=2, # Scatter-散点大小
y_tick_count=10,
is_show_line=True # Scatter-散点连成线
)
chart.add_series(
"series-A", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]
)
chart.add_series(
"series-B", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]
)
return chart
scatter_base().render('scatter_base.html')
"""
:param x_label: X 坐标轴名称
:param y_label: Y 坐标轴名称
:param x_tick_count: X 轴刻度分割段数
:param y_tick_count: Y 轴刻度分割段数
:param is_show_line: 是否将散点连成线
:param dot_size: 散点大小
:param time_format: 日期格式
:param legend_pos: 图例位置,有 "upLeft", "upRight", "downLeft", "downRight" 可选
:param colors: label 颜色数组
:param font_family: CSS font-family
"""
"""
:param name: series 名称
:param data: series 数据列表,[(x1, y1), (x2, y2)]
"""