import datetime

import random

from pyecharts import options as opts

from pyecharts.charts import 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(init_opts=opts.InitOpts(width='1200px',height=' 250px'))

c.add('',data,calendar_opts = opts.CalendarOpts (range_ =2017))

c.set_global_opts(title_opts = opts.TitleOpts(title='日历图'),

                  visualmap_opts = opts.VisualMapOpts(

                  max_=25000,

                  min_=500,

                  orient='horizontal',

                  is_piecewise=True,

                  pos_top='230px',

                  pos_left='100px'))

c.render_notebook()

posted on 2021-11-22 20:49  xuegaochengzi  阅读(85)  评论(0编辑  收藏  举报