mirror of
https://github.com/pyecharts/pyecharts.git
synced 2025-12-08 20:59:23 +00:00
40 lines
995 B
Python
40 lines
995 B
Python
# coding=utf-8
|
|
import datetime
|
|
import random
|
|
|
|
from example.commons import Collector
|
|
from pyecharts import options as opts
|
|
from pyecharts.charts import Calendar, Page
|
|
|
|
C = Collector()
|
|
|
|
|
|
@C.funcs
|
|
def calendar_base() -> Calendar:
|
|
begin = datetime.date(2017, 1, 1)
|
|
end = datetime.date(2017, 12, 31)
|
|
data = [
|
|
[str(begin + datetime.timedelta(days=i)), random.randint(1000, 25000)]
|
|
for i in range((end - begin).days + 1)
|
|
]
|
|
|
|
c = (
|
|
Calendar()
|
|
.add("", data, calendar_opts=opts.CalendarOpts(range_="2017"))
|
|
.set_global_opts(
|
|
title_opts=opts.TitleOpts(title="Calendar-2017年微信步数情况"),
|
|
visualmap_opts=opts.VisualMapOpts(
|
|
max_=20000,
|
|
min_=500,
|
|
orient="horizontal",
|
|
is_piecewise=True,
|
|
pos_top="230px",
|
|
pos_left="100px",
|
|
),
|
|
)
|
|
)
|
|
return c
|
|
|
|
|
|
Page().add(*[fn() for fn, _ in C.charts]).render()
|