def get(self): begin = datetime.date(2020, 1, 1) end = datetime.date(2020, 12, 31) uu_id = self.get_argument('uuid', None) accesslist = self.session.query( func.date_format(ShorturlOverview.short_url_createTime, '%Y-%m-%d').label('date'), func.count(ShorturlOverview.short_url_id)).filter( ShorturlOverview.short_url == ShortUrlInfo.short_code).filter( ShortUrlInfo.uuid == uu_id).group_by('date').order_by( 'date').all() data = [] for d in accesslist: clist_item = [] clist_item.append(d[0]) clist_item.append(d[1]) data.append(clist_item) calendar = Calendar() calendar.add( '', data, calendar_opts=opt.CalendarOpts( range_='2020', daylabel_opts=opt.CalendarDayLabelOpts(name_map='en'), monthlabel_opts=opt.CalendarMonthLabelOpts(name_map='en'), ), ) calendar.set_global_opts( title_opts=opt.TitleOpts( title='Calendar - The number of clicks per day in 2020'), visualmap_opts=opt.VisualMapOpts( max_=200, min_=1, orient="horizontal", is_piecewise=True, pos_top="230px", pos_left="100px", ), ) calendar.render(path=settings['template_path'] + '/calendar.html', encoding='utf-8') self.render('calendar.html')
time_list = date.split('-') time = datetime.date(int(time_list[0]), int(time_list[1]), int(time_list[2])) list1.append([str(time), pm]) calendar = Calendar() calendar.add( '', list1, calendar_opts=opts.CalendarOpts( pos_top="120", pos_left="30", pos_right="30", range_="2017", yearlabel_opts=opts.CalendarYearLabelOpts(is_show=False), ), ) calendar.set_global_opts( title_opts=opts.TitleOpts(pos_top="30", pos_left="center", title="2017年印度德里空气质量情况"), visualmap_opts=opts.VisualMapOpts(max_=300, min_=0, orient="horizontal", is_piecewise=False), ) calendar.render('heatmap.html')
from pyecharts.charts import Calendar import pyecharts.options as opts from datetime import date from random import randint import datetime begin = date(2019, 1, 1) end = date(2019, 12, 24) data = [ [str(begin + datetime.timedelta(days=i)), randint(0, 10000)] for i in range((end - begin).days) ] # 1号,2号,3号 cal = Calendar(init_opts=opts.InitOpts(page_title='test_page')) cal.add(series_name='', yaxis_data=data, calendar_opts=opts.CalendarOpts( range_=[begin, end])) cal.set_global_opts(title_opts=opts.TitleOpts(title='test2one'), toolbox_opts=opts.ToolboxOpts(), visualmap_opts=opts.VisualMapOpts( max_=10000, min_=0, is_piecewise=True )) cal.render('./Calendar.html')
# print(data) # %% from pyecharts.charts import Calendar from pyecharts import options as opts cald = Calendar().add("", data, calendar_opts=opts.CalendarOpts( range_=['2019-06', '2020-02'])).set_global_opts( title_opts=opts.TitleOpts(title="MasControl"), visualmap_opts=opts.VisualMapOpts( max_=5, min_=0, orient="horizontal", is_piecewise=True, pos_top="230px", pos_left="100px", ), ) cald.render() # %% from pyecharts.render import make_snapshot from snapshot_selenium import snapshot make_snapshot(snapshot, cald.render(), "masterSurvery.png")