小白学Python(17)——pyecharts 日历图 Calendar

Calendar-2017年微信步数情况

 

 1 import datetime
 2 import random
 3 
 4 from pyecharts import options as opts
 5 from pyecharts.charts import Calendar
 6 
 7 begin = datetime.date(2017, 1, 1)
 8 end = datetime.date(2017, 12, 31)
 9 data = [
10         [str(begin + datetime.timedelta(days=i)), random.randint(1000, 25000)]
11         for i in range((end - begin).days + 1)
12     ]
13 
14 calendar=(
15         Calendar()
16         .add("", data, calendar_opts=opts.CalendarOpts(range_="2017"))
17         .set_global_opts(
18             title_opts=opts.TitleOpts(title="Calendar-2017年微信步数情况"),
19             visualmap_opts=opts.VisualMapOpts(
20                 max_=20000,
21                 min_=500,
22                 orient="horizontal",
23                 is_piecewise=True,
24                 pos_top="230px",
25                 pos_left="100px",
26             ),
27         )
28     )
29 
30 calendar.render()

 

posted @ 2019-08-23 21:11  徐海建  阅读(2832)  评论(0编辑  收藏  举报