def getRadar(self, sheet: xlrd.sheet) -> Radar: namelist = sheet.col_values(0, 1) maxvaluelist = sheet.col_values(1, 1) maxlist = [ opts.RadarIndicatorItem(name=namelist[i], max_=maxvaluelist[i]) for i in range(len(namelist)) ] valuelists = dict() for i in range(2, sheet.ncols): valuelists[sheet.cell(0, i).value] = sheet.col_values(i, 1) r = Radar() r.add_schema( schema=maxlist, splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) #设置颜色的列表 colorstr = ["#CD0000", "#5CACEE", "#7B68EE", "#FFFF00"] colorth = 0 for name, values in valuelists.items(): r.add( series_name=name, data=values, linestyle_opts=opts.LineStyleOpts(color=colorstr[colorth]), ) colorth = (colorth + 1) % len(colorstr) #颜色循环 r.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) r.set_global_opts(title_opts=opts.TitleOpts( title=sheet.name, title_textstyle_opts=opts.TextStyleOpts(color="#fff")), legend_opts=opts.LegendOpts()) return r
def draw_radar_for_observation_result() -> Radar: value = [[43, 58, 78, 65, 86, 63]] min_val = 0 max_val = 100 # 用于调整雷达各维度的范围大小 c_schema = [{"name": "交往能力", "max": max_val, "min": min_val, }, {"name": "感知能力", "max": max_val, "min": min_val, "color": "#ff0000"}, {"name": "运动能力", "max": max_val, "min": min_val, "color": "#000000"}, {"name": "注意力", "max": max_val, "min": min_val, "color": "#00ffff"}, {"name": "语言能力", "max": max_val, "min": min_val, "color": "#ff00ff"}, {"name": "自我照顾能力", "max": max_val, "min": min_val, "color": "#ff00ff"} ] # 画图 radar = Radar(init_opts=opts.InitOpts(width="750px", height="500px")) # radar = Radar() radar.add_schema(c_schema, textstyle_opts=opts.TextStyleOpts(color="#3344ff")) radar.add(None, value, color="#f9713c", symbol='circle', label_opts=opts.LabelOpts(is_show=True), areastyle_opts=opts.AreaStyleOpts(opacity=0.5, color="#f9713c")) # radar.set_global_opts(title_opts=opts.TitleOpts(title="Radar-基本示例")) # radar.render("observation_result.html") return radar
def year_store_order_base(): # 不同门店的年营业额数据查询 dataX, dataY1, dataY2 = year_store_query() # 对象声明 radar = Radar(init_opts=opts.InitOpts( width="1280px", height="720px", bg_color="#CCCCCC")) radar.add_schema( schema=[ opts.RadarIndicatorItem(name="门店订单金额", max_=34000), opts.RadarIndicatorItem(name="门店顾客数", max_=10000), opts.RadarIndicatorItem(name="门店商品类型", max_=10000), opts.RadarIndicatorItem(name="门店订单量", max_=10000) ], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) radar.add( series_name="Store 1", data=[list(dataY1)], linestyle_opts=opts.LineStyleOpts(color="#CD0000"), ) radar.add( series_name="Store 2", data=[list(dataY2)], linestyle_opts=opts.LineStyleOpts(color="#5CACEE"), ) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts(title_opts=opts.TitleOpts(title="2005年门店竞争优势多维分析"), legend_opts=opts.LegendOpts()) return radar
def DrawRadar(city_name): schema = [('最高气温', 45), ('气压', 1500), ('湿度', 100), ('最低气温', 45), ('PM2.5', 200)] data = qr.get_data(city_name) values = [[int(data['Htemperature']), int(data['QY']), int(data['SD'].strip('%')), int(data['Ltemperature']), int(data['pm25'])]] radar = Radar() radar.config(schema) radar.add('%s天气信息' % city_name, values, is_splitline=True, is_axisline_show=True) radar.render('weatherRadar.html')
def radar_demo(): radar = Radar() # data1 = [[12, 0, 2, 18, 0, 1]] radar_data1 = [2.0, 4.9, 7.0, 23.2, 25.6, 76.7, 135.6, 162.2, 32.6, 20.0, 6.4, 3.3]#降水量 # schema = [ # ("执行成功", 20), ("执行失败", 5), ("执行异常", 5), # ("回滚成功", 20), ("回滚失败", 5), ("执行中断", 5) # ] schema = [ ("Jan", 5), ("Feb", 10), ("Mar", 10), ("Apr", 50), ("May", 50), ("Jun", 200), ("Jul", 200), ("Aug", 200), ("Sep", 50), ("Oct", 50), ("Nov", 10), ("Dec", 5) ] radar.add_schema(schema) radar.add("执行状态", radar_data1) radar.render("/aa.html")
def drawRadar(arr, value, valuemax, name): radar = Radar(init_opts=opts.InitOpts( width="1280px", height="720px", bg_color="#CCCCCC")) v_max = [list(z) for z in zip(arr, valuemax)] radar.add_schema( schema=[opts.RadarIndicatorItem(name=k, max_=v) for k, v in v_max], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) radar.add( series_name=name, data=value, linestyle_opts=opts.LineStyleOpts(color="#CD0000"), ) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts(title_opts=opts.TitleOpts(title=name), legend_opts=opts.LegendOpts()) radar.render("{0}.html".format(name))
def DrawRadar(title, data, savepath): print('正在分析评分构成...') radar = Radar() radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts( title_opts=opts.TitleOpts(title="Radar-评分分布统计雷达图", pos_left='center'), legend_opts=opts.LegendOpts(orient="vertical", pos_top="middle", pos_left="2%"), ) values = [[data[i][1] for i in range(len(data))]] # 把整个列表当做一个要画的东西 attrs = [data[i][0] for i in range(len(data))] # 改名字 attrs = list(map(int, attrs)) attrs = [str(i) + '星' for i in attrs] num = len(attrs) # 雷达图有几项 schema = [{"name": attrs[i], "max": 230} for i in (range(num))] radar.add_schema(schema=schema) radar.add('豆瓣评分构成', values) radar.render(os.path.join(savepath, '%s.html' % title))
def plot_radar(series_radiant, series_dire): c_schema = [{ "name": "控制", "max": 15, "min": 0 }, { "name": "核心", "max": 15, "min": 0 }, { "name": "辅助", "max": 15, "min": 0 }, { "name": "逃生", "max": 15, "min": 0 }, { "name": "爆发", "max": 15, "min": 0 }, { "name": "先手", "max": 15, "min": 0 }, { "name": "耐久", "max": 15, "min": 0 }, { "name": "推进", "max": 15, "min": 0 }] radar = Radar() radar.add_schema(schema=c_schema) radar.add("radiant", series_radiant, color="#f9713c") radar.add("dire", series_dire, color="#b3e4a1") radar.render("Rader.html")
jse['points'].values.tolist()[0], jse['rebounds'].values.tolist()[0], jse['assists'].values.tolist()[0], jse['steals'].values.tolist()[0], jse['blocked'].values.tolist()[0], jse['fouls'].values.tolist()[0], jse['turnovers'].values.tolist()[0] ]] radar = Radar() radar.add_schema(schema=[ opts.RadarIndicatorItem(name='得分', max_=30), opts.RadarIndicatorItem(name="篮板", max_=15), opts.RadarIndicatorItem(name="助攻", max_=10), opts.RadarIndicatorItem(name="抢断", max_=5), opts.RadarIndicatorItem(name="封盖", max_=5), opts.RadarIndicatorItem(name="犯规", max_=5), opts.RadarIndicatorItem(name="失误", max_=5), ]) radar.add("博格达诺维奇", bgdnwq_list) radar.add("富尼耶", fny_list) radar.add("卢比奥", lba_list) radar.add("斯科拉", skl_list) radar.add("加索尔", jse_list) # radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.render_notebook() # 投篮命中率 bgdnwq_goals_percentage = bgdnwq['goals_percentage'].values.tolist()[0] fny_goals_percentage = fny['goals_percentage'].values.tolist()[0] lba_goals_percentage = lba['goals_percentage'].values.tolist()[0] skl_goals_percentage = skl['goals_percentage'].values.tolist()[0] jse_goals_percentage = jse['goals_percentage'].values.tolist()[0] data_list = [
week = date_to_week(data['入网时间']) week1 = [week] radar = Radar() schema = [{ "name": '星期天', "max": 1000 }, { "name": '星期一', "max": 1000 }, { "name": '星期二', "max": 1000 }, { "name": '星期三', "max": 1000 }, { "name": '星期四', "max": 1000 }, { "name": '星期五', "max": 1000 }, { "name": '星期六', "max": 1000 }] radar.add(data=week1, series_name='入网时间') radar.add_schema(schema) radar.render('render.html')
def radar(student, studentName, course, week, rubrics, studentScore, avgScore, commentor, comment, dir): page = Page(page_title='%s %s WEEK%d 评分'%(studentName, course, week),layout=Page.SimplePageLayout) studentRawData = [studentScore] avgRawData = [avgScore] rubricsItem = [] for i in range(len(rubrics)): rubricsItem.append({"name": "%s"%rubrics[i][0], "max": 5, "min": 0}) ''' 弃用 rubricsItem = [{"name": "KnowledgeAcquisition", "max": 5, "min": 0}, {"name": "Motivation", "max": 5, "min": 0}, {"name": "Communication", "max": 5, "min": 0}, {"name": "HandsOnSkills", "max": 5, "min": 0}, {"name": "ThinkingSkills", "max": 5, "min": 0}, {"name": "Responsibility", "max": 5, "min": 0}, {"name": "ProjectExecution", "max": 5, "min": 0}] ''' radarChart = Radar() radarChart.add_schema(schema=rubricsItem,shape="polygon") radarChart.add('WEEK%d %s'%(week, studentName), studentRawData, color="#1F1C18") radarChart.add('WEEK%d Class Average'%week, avgRawData, color="#94060A", is_selected = False) tableScores = Table() scoreHeaders = ["Rubrics Item", "Score", "Class Average"] scoreRows = [] for i in range(len(rubrics)): print(rubrics) print(studentScore) print(avgScore) scoreRows.append([rubrics[i][0], studentScore[i], avgScore[i]]) ''' 弃用 scoreRows = [ ["Knowledge Acquisition", studentScore[0], avgScore[0]], ["Motivation", studentScore[1], avgScore[1]], ["Communication", studentScore[2], avgScore[2]], ["Hands-On Skills", studentScore[3], avgScore[3]], ["ThinkingSkills", studentScore[4], avgScore[4]], ["Responsibility", studentScore[5], avgScore[5]], ["Project Execution", studentScore[6], avgScore[6]] ] ''' tableScores.add(scoreHeaders, scoreRows).set_global_opts( title_opts=opts.ComponentTitleOpts(title="Scores") ) tableComments = Table() commentHeaders = ["Commentor","Comment"] commentRows = [] for i in range(len(commentor)): commentRows.append([commentor[i], comment[i]]) tableComments.add(commentHeaders, commentRows).set_global_opts( title_opts=opts.ComponentTitleOpts(title="Comments") ) page.add(radarChart) page.add(tableScores) page.add(tableComments) #page.render("%s/%dWEEK%d.html"%(dir, student, week)) page.render("%s\%dWEEK%d.html"%(dir, student, week))
connection.close() # 执行主函数 if __name__ == '__main__': print(store_query()) data1, data2, data3 = store_query() radar = Radar(init_opts=opts.InitOpts(theme=ThemeType.DARK,width="1280px", height="720px")) radar.add_schema(schema=[ opts.RadarIndicatorItem(name="门店订单金额", max_=50000), opts.RadarIndicatorItem(name="门店订单量", max_=10000), opts.RadarIndicatorItem(name="门店顾客数", max_=10000), opts.RadarIndicatorItem(name="门店商品类型", max_=10000), ], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1) ), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) radar.add(series_name="1号门店", data=[list(data1)], linestyle_opts=opts.LineStyleOpts(color="#CD0000") ) radar.add(series_name="2号门店", data=[list(data2)], linestyle_opts=opts.LineStyleOpts(color="#5CACEE") ) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts( title_opts=opts.TitleOpts(title="门店竞争优势多维分析"), legend_opts=opts.LegendOpts() ) radar.render('radar.html')
def find_difference_render(data,X,query,table_path,answer): colorList = ['#f36c6c', '#e6cf4e', '#20d180', '#0093ff',"#ca8622","#726930",] if len(data)==2: bar1=Bar() bar1.add_xaxis(X[1]) bar1.add_yaxis("",data[0][1],label_opts=opts.LabelOpts(position="insideLeft")) bar1.reversal_axis() bar1.set_global_opts( datazoom_opts=[opts.DataZoomOpts(range_start=10,range_end=90,orient="vertical"), opts.DataZoomOpts(type_="inside")], xaxis_opts=opts.AxisOpts( position="top" ), yaxis_opts=opts.AxisOpts( is_inverse=True ), graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n' +"\n"+ 'A:' + ' ' + answer], font="14px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) bar2=Bar() bar2.add_xaxis(X[1]) bar2.add_yaxis("",data[1][1],label_opts=opts.LabelOpts(position="insideRight")) bar2.reversal_axis() bar2.set_global_opts( datazoom_opts=[opts.DataZoomOpts(range_start=10, range_end=90, orient="vertical"), opts.DataZoomOpts(type_="inside")], xaxis_opts=opts.AxisOpts( position="top", is_inverse=True ), yaxis_opts=opts.AxisOpts( is_inverse=True, position="right" ), graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n' +"\n"+ 'A:' + ' ' + answer], font="14px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) grid1 = Grid(init_opts=opts.InitOpts( width="100%", height="100%", renderer=globals.RenderType.SVG, ) ) grid1.add(bar1, grid_opts=opts.GridOpts( pos_left="60%",pos_bottom="30%" )) grid1.add(bar2, grid_opts=opts.GridOpts( pos_right="60%",pos_bottom="30%" )) grid1.render("a.html") option1 = grid1.dump_options_with_quotes() option1 = json.loads(option1) lable=[] for i in range(len(X[1])): lable.append(opts.RadarIndicatorItem(name=X[1][i])) # r_data=[] # for record in data: # r_data.append(record[1]) radar=Radar(init_opts=opts.InitOpts(bg_color="#CCCCCC")) radar.add_schema( schema=lable, splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1) ), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) for i in range(len(data)): radar.add( series_name=data[i][0], label_opts=opts.LabelOpts(is_show=False), data=[data[i][1]], linestyle_opts=opts.LineStyleOpts( color=colorList[i], width=3 ) ) radar.set_global_opts( graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", z=100, ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n'+"\n" + 'A:' + ' ' + answer], font="10px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) grid2 = Grid(init_opts=opts.InitOpts( width="100%", height="100%", renderer=globals.RenderType.SVG, )) grid2.add(radar, grid_opts={'left': '20%', 'bottom': '40%',"top":"1%"}) option2 = grid2.dump_options_with_quotes() option2 = json.loads(option2) bar3=Bar() bar3.add_xaxis(X[1]) for i in range(len(data)): bar3.add_yaxis(data[i][0],data[i][1],label_opts=opts.LabelOpts(is_show=False)) bar3.set_global_opts( datazoom_opts=[opts.DataZoomOpts(range_start=10, range_end=90), opts.DataZoomOpts(type_="inside")], xaxis_opts=opts.AxisOpts( name=X[0] ), graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n' +"\n"+ 'A:' + ' ' + answer], font="14px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) grid3 = Grid(init_opts=opts.InitOpts( width="100%", height="100%", renderer=globals.RenderType.SVG, )) grid3.add(bar3, grid_opts={'left': '20%', 'bottom': '30%'}) option3 = grid3.dump_options_with_quotes() option3 = json.loads(option3) option = {"option": [option1,option2,option3], "query": query} return option elif len(data)>2 and len(data[0][1])>1: lable=[] for i in range(len(X[1])): lable.append(opts.RadarIndicatorItem(name=X[1][i])) # r_data=[] # for record in data: # r_data.append(record[1]) radar=Radar(init_opts=opts.InitOpts(bg_color="#CCCCCC")) radar.add_schema( schema=lable, splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1) ), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) radar.set_global_opts( graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n' +"\n"+ 'A:' + ' ' + answer], font="14px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) for i in range(len(data)): radar.add( series_name=data[i][0], label_opts=opts.LabelOpts(is_show=False), data=[data[i][1]], linestyle_opts=opts.LineStyleOpts( color=colorList[i], width=3 ) ) grid1 = Grid(init_opts=opts.InitOpts( width="100%", height="100%", renderer=globals.RenderType.SVG, )) grid1.add(radar, grid_opts={'left': '20%', 'bottom': '30%'}) option1 = grid1.dump_options_with_quotes() option1 = json.loads(option1) bar = Bar() bar.add_xaxis(X[1]) for i in range(len(data)): bar.add_yaxis(data[i][0], data[i][1],label_opts=opts.LabelOpts(is_show=False)) bar.set_global_opts( datazoom_opts=[opts.DataZoomOpts(range_start=10, range_end=90), opts.DataZoomOpts(type_="inside")], xaxis_opts=opts.AxisOpts( name=X[0] ), graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n' +"\n"+ 'A:' + ' ' + answer], font="14px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) grid2 = Grid(init_opts=opts.InitOpts( width="100%", height="100%", renderer=globals.RenderType.SVG, )) grid2.add(bar, grid_opts={'left': '20%', 'bottom': '30%'}) option2 = grid2.dump_options_with_quotes() option2 = json.loads(option2) option = {"option": [option1,option2], "query": query} return option elif len(data)>2 and len(data[0][1])==1: bar = Bar() bar.add_xaxis(X[1]) for i in range(len(data)): bar.add_yaxis(data[i][0], data[i][1],label_opts=opts.LabelOpts(is_show=False)) bar.set_global_opts( datazoom_opts=[opts.DataZoomOpts(range_start=10, range_end=90), opts.DataZoomOpts(type_="inside")], xaxis_opts=opts.AxisOpts( name=X[0] ), graphic_opts=[opts.GraphicText( graphic_item=opts.GraphicItem( left="center", top="bottom", ), graphic_textstyle_opts=opts.GraphicTextStyleOpts( # 可以通过jsCode添加js代码,也可以直接用字符串 text=['\n' + "Q:" + ' ' + query + '\n' +"\n"+ 'A:' + ' ' + answer], font="14px Microsoft YaHei", graphic_basicstyle_opts=opts.GraphicBasicStyleOpts( fill="#333" ) ) )] ) grid2 = Grid(init_opts=opts.InitOpts( width="100%", height="100%", renderer=globals.RenderType.SVG, )) grid2.add(bar, grid_opts={'left': '20%', 'bottom': '34%'}) option2 = grid2.dump_options_with_quotes() option2 = json.loads(option2) option = {"option": [option2], "query": query} return option
qieerxi_pass = team[team['club'] == '切尔西']['pass'].values.tolist() qieerxi_shot = team[team['club'] == '切尔西']['shot'].values.tolist() qieerxi_data = [] qieerxi_tmp_data = [ int(qieerxi_score[0]), int(qieerxi_speed[0]), int(qieerxi_power[0]), int(qieerxi_defend[0]), int(qieerxi_tape[0]), int(qieerxi_pass[0]), int(qieerxi_shot[0]) ] qieerxi_data.append(qieerxi_tmp_data) radar = Radar() radar.add_schema(schema=[ opts.RadarIndicatorItem(name='综合得分', max_=100), opts.RadarIndicatorItem(name='速度', max_=100), opts.RadarIndicatorItem(name='力量', max_=100), opts.RadarIndicatorItem(name='防守', max_=100), opts.RadarIndicatorItem(name='盘带', max_=100), opts.RadarIndicatorItem(name='传球', max_=100), opts.RadarIndicatorItem(name='射术', max_=100) ]) radar.add('利物浦', liwupu_data, color="#f9713c") radar.add('曼城', mancheng_data, color="#30ff00") radar.add('阿森纳', asenna_data, color="#9400D3") radar.add('曼联', manlian_data, color="#141414") radar.add('切尔西', qieerxi_data, color="#00F5FF") radar.render_notebook()
dim=7, name="等级", type_="category", data=["优", "良", "轻度污染", "中度污染", "重度污染", "严重污染"], ), ] parallel = Parallel() # 添加坐标轴和数据 parallel.add_schema(schema=schema).add("", data) parallel.render_notebook() # %% [markdown] # ### Radar -- 雷达图 radar = Radar() radar.add_schema(schema=[ opts.RadarIndicatorItem(name=_k, max_=200) for _k in list("ABCDFG") ]) radar.add("Expectation", [Faker.values()]).add("Reality", [Faker.values()]) radar.render_notebook() # %% [markdown] # ### ThemeRiver -- 流量图 themeriver = ThemeRiver() with open("data/themeriver.json") as j: data = json.load(j) cats = list(set([i[-1] for i in data])) themeriver.add(cats, data, singleaxis_opts=opts.SingleAxisOpts(type_="time")) themeriver.render_notebook()
def draw_radar(season_x, season_name, filechart, seasonareacolor, seasonlinecolor): # 建立schema的json文件 season_x.columns = [season_name] season_index = season_x.index.to_list() # print(season_index) # n_max, n_min = max(season_x), min(season_x) n_max = max(enumerate(season_x[0]), key=operator.itemgetter(1))[1] n_min = min(enumerate(season_x[0]), key=operator.itemgetter(1))[1] # 用于获取对象的哪些维的数据 # print(n_max, n_min) df_season = pd.DataFrame({'name': season_index}) df_season['max'], df_season['min'] = n_max, n_min # season_js = df_season.to_json(orient='records') # print(season_js) # 设置16方位, 逆时针排序 season_js = [ {"name": "N", "max": n_max, "min": n_min}, {"name": "NNW", "max": n_max, "min": n_min}, {"name": "NW", "max": n_max, "min": n_min}, {"name": "WNW", "max": n_max, "min": n_min}, {"name": "W", "max": n_max, "min": n_min}, {"name": "WSW", "max": n_max, "min": n_min}, {"name": "SW", "max": n_max, "min": n_min}, {"name": "SSW", "max": n_max, "min": n_min}, {"name": "S", "max": n_max, "min": n_min}, {"name": "SSE", "max": n_max, "min": n_min}, {"name": "SE", "max": n_max, "min": n_min}, {"name": "ESE", "max": n_max, "min": n_min}, {"name": "E", "max": n_max, "min": n_min}, {"name": "ENE", "max": n_max, "min": n_min}, {"name": "NE", "max": n_max, "min": n_min}, {"name": "NNE", "max": n_max, "min": n_min}, ] # 设置数据 fengsus = season_x[0].to_list() data_fengsu = [{'value': fengsus, 'name': '风频数'}] # print(data_fengsu) charts = Radar() charts.set_colors(['#4587E7']) # 设置颜色 charts.add_schema(schema=season_js, shape='circle', center=['50%', '50%'], radius='80%', angleaxis_opts=opts.AngleAxisOpts( min_=0, # 坐标轴刻度最小值 max_=360, # 坐标轴刻度最大值 is_clockwise=True, interval=22.5, # 强制设置坐标轴分割间隔 axistick_opts=opts.AxisTickOpts(is_show=False), axislabel_opts=opts.LabelOpts(is_show=False,), # 坐标轴线标签配置项 axisline_opts=opts.AxisLineOpts(is_show=True), # 坐标轴线风格配置项 splitline_opts=opts.SplitLineOpts(is_show=True) # 分割线配置项 ), radiusaxis_opts=opts.RadiusAxisOpts( min_=n_min, # 坐标轴刻度最小值 max_=n_max, # 坐标轴刻度最大值 interval=2, # 强制设置坐标轴分割间隔 splitarea_opts=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=0.2, ) ), splitline_opts=opts.SplitLineOpts(is_show=True, linestyle_opts=opts.LineStyleOpts(is_show=True, width=0.5, color='grey')), axislabel_opts=opts.LabelOpts(is_show=True, font_size=12, color='grey'), # 坐标轴线标签配置项 ), polar_opts=opts.PolarOpts(), splitarea_opt=opts.SplitAreaOpts(is_show=True), splitline_opt=opts.SplitLineOpts(is_show=False), # 分割线配置项 textstyle_opts=opts.TextStyleOpts(color='black', font_size=14) ) charts.add(series_name='%s玫瑰图' % season_name, # 系列名称 data=data_fengsu, # 系列数据 areastyle_opts=opts.AreaStyleOpts(opacity=0.5, # 系列面样式设置 color=seasonareacolor), linestyle_opts=opts.LineStyleOpts(width=2, # 系列线样式设置 color=seasonlinecolor), label_opts=opts.LabelOpts(is_show=False), ) # 系列标签设置 charts.render(filechart)
def plt(key): """连接hbase""" connection = happybase.Connection(host="localhost", port=9090) """打开传输""" connection.open() """连接表""" basicFeaturesTable = happybase.Table('basicFeaturesTable', connection) socialAttributesTable = happybase.Table('socialAttributesTable', connection) consumptionFeaturesTable = happybase.Table('consumptionFeaturesTable', connection) internetFeaturesTable = happybase.Table('internetFeaturesTable', connection) consumptionCharacteristicsTable = happybase.Table( 'consumptionCharacteristicsTable', connection) internetBehaviorTable = happybase.Table('internetBehaviorTable', connection) """获取信息""" try: key_name = basicFeaturesTable.row(key, columns=["name"]) except: """连接hbase""" connection = happybase.Connection(host="localhost", port=9090) """打开传输""" connection.open() """连接表""" basicFeaturesTable = happybase.Table('basicFeaturesTable', connection) socialAttributesTable = happybase.Table('socialAttributesTable', connection) consumptionFeaturesTable = happybase.Table('consumptionFeaturesTable', connection) internetFeaturesTable = happybase.Table('internetFeaturesTable', connection) consumptionCharacteristicsTable = happybase.Table( 'consumptionCharacteristicsTable', connection) internetBehaviorTable = happybase.Table('internetBehaviorTable', connection) key_name = basicFeaturesTable.row(key, columns=["name"]) key_name = list(key_name.values()) key_name = key_name[0].decode() try: sInfo = socialAttributesTable.row(key, columns=["incLevel", "eduLevel"]) cInfo = consumptionFeaturesTable.row(key, columns=["CMLevel", "CTLevel"]) iInfo = internetFeaturesTable.row(key, columns=["intLevel"]) consumptionCharacteristicsInfo = consumptionCharacteristicsTable.row( key, columns=["commodity", "price", "date"]) internetBehaviorInfo = internetBehaviorTable.row \ (key, columns= ["date", "news", "communications", "entertainment", "domersticServices", "busApp", "toolUse"] ) except: """连接hbase""" connection = happybase.Connection(host="localhost", port=9090) """打开传输""" connection.open() """连接表""" basicFeaturesTable = happybase.Table('basicFeaturesTable', connection) socialAttributesTable = happybase.Table('socialAttributesTable', connection) consumptionFeaturesTable = happybase.Table('consumptionFeaturesTable', connection) internetFeaturesTable = happybase.Table('internetFeaturesTable', connection) consumptionCharacteristicsTable = happybase.Table( 'consumptionCharacteristicsTable', connection) internetBehaviorTable = happybase.Table('internetBehaviorTable', connection) sInfo = socialAttributesTable.row(key, columns=["incLevel", "eduLevel"]) cInfo = consumptionFeaturesTable.row(key, columns=["CMLevel", "CTLevel"]) iInfo = internetFeaturesTable.row(key, columns=["intLevel"]) consumptionCharacteristicsInfo = consumptionCharacteristicsTable.row( key, columns=["commodity", "price", "date"]) internetBehaviorInfo = internetBehaviorTable.row \ (key, columns= ["date", "news", "communications", "entertainment", "domersticServices", "busApp", "toolUse"] ) """消费情况图""" consumptionCharacteristicsValues = list( consumptionCharacteristicsInfo.values()) consumptionCharacteristicsValues = list( map(lambda x: x.decode(), consumptionCharacteristicsValues)) consumptionCharacteristicsValues[ int(len(consumptionCharacteristicsValues) / 3):-int(len(consumptionCharacteristicsValues) / 3)] \ = list(map(int, consumptionCharacteristicsValues[int(len(consumptionCharacteristicsValues) / 3): -int(len(consumptionCharacteristicsValues) / 3)])) consumptionCharacteristicsValues[-int(len(consumptionCharacteristicsValues) / 3):] \ = list(map(int, consumptionCharacteristicsValues[-int(len(consumptionCharacteristicsValues) / 3):])) consumptionCharacteristicsData = [] consumptionCharacteristicsData.append( consumptionCharacteristicsValues[:int( len(consumptionCharacteristicsValues) / 3)]) consumptionCharacteristicsData.append(consumptionCharacteristicsValues[ int(len(consumptionCharacteristicsValues) / 3):-int(len(consumptionCharacteristicsValues) / 3)]) consumptionCharacteristicsData.append(consumptionCharacteristicsValues[ -int(len(consumptionCharacteristicsValues) / 3):]) consumptionCharacteristicsData = pd.DataFrame( consumptionCharacteristicsData).T consumptionCharacteristicsData.columns = ["commodity", "date", "price"] consumptionCharacteristicsData.sort_values(by="date", inplace=True) consumptionCharacteristicsData_y = consumptionCharacteristicsData.loc[:, "date"].tolist( ) consumptionCharacteristicsData_y = list( map(str, consumptionCharacteristicsData_y)) consumptionCharacteristicsData_x = consumptionCharacteristicsData.loc[:, "price"].tolist( ) consumptionCharacteristicsData_commodity = consumptionCharacteristicsData.loc[:, "commodity"].tolist( ) quzhong_consumptionCharacteristicsData_y = list( set(consumptionCharacteristicsData_y)) if len(quzhong_consumptionCharacteristicsData_y) != len( consumptionCharacteristicsData_y): for i in range(len(quzhong_consumptionCharacteristicsData_y)): count_consumptionCharacteristicsData_y = consumptionCharacteristicsData_y. \ count(quzhong_consumptionCharacteristicsData_y[i]) if count_consumptionCharacteristicsData_y != 1: index = consumptionCharacteristicsData_y.index( quzhong_consumptionCharacteristicsData_y[i]) consumptionCharacteristicsData_y = consumptionCharacteristicsData_y[:index + 1] + \ consumptionCharacteristicsData_y[ index + count_consumptionCharacteristicsData_y:] consumptionCharacteristicsData_x[index] = sum( consumptionCharacteristicsData_x[ index:index + count_consumptionCharacteristicsData_y]) consumptionCharacteristicsData_x = consumptionCharacteristicsData_x[:index + 1] + \ consumptionCharacteristicsData_x[ index + count_consumptionCharacteristicsData_y:] consumptionCharacteristicsData_commodity[index] = \ ",".join( consumptionCharacteristicsData_commodity[index:index + count_consumptionCharacteristicsData_y]) consumptionCharacteristicsData_commodity \ = consumptionCharacteristicsData_commodity[:index + 1] + \ consumptionCharacteristicsData_commodity[index + count_consumptionCharacteristicsData_y:] consumptionCharacteristicsData_xx = \ [list(z) for z in zip(consumptionCharacteristicsData_x, consumptionCharacteristicsData_commodity)] scatter = Scatter(init_opts=opts.InitOpts(width="850px", height="380px")) scatter.add_xaxis(consumptionCharacteristicsData_y) scatter.add_yaxis("", consumptionCharacteristicsData_xx, color="red") scatter.set_global_opts( tooltip_opts=opts.TooltipOpts( trigger="item", axis_pointer_type="cross", formatter=JsCode( "function (params) {return '消费日期:' + params.name + ' <br/>消费金额:' + params.value[1] + '元 <br/>消费产品:' + params.value[2];}" )), yaxis_opts=opts.AxisOpts( name="消费金额", type_="value", name_textstyle_opts=opts.TextStyleOpts(color="white"), ########### axislabel_opts=opts.LabelOpts(formatter="{value} 元", border_color="white", color="white"), ######## axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), xaxis_opts=opts.AxisOpts( name="消费日期", type_="category", name_textstyle_opts=opts.TextStyleOpts(color="white"), ########### axislabel_opts=opts.LabelOpts(border_color="white", color="white"), ############## axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), legend_opts=opts.LegendOpts(is_show=False)) scatter.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) line = Line(init_opts=opts.InitOpts(width="850px", height="380px")) line.add_xaxis(consumptionCharacteristicsData_y) line.add_yaxis(series_name="", y_axis=consumptionCharacteristicsData_x, color="red") scatter.overlap(line) scatter.render("./static/html/pictureConsumptionCharacteristics.html") """互联网行为图""" internetBehaviorInfoKeys = list(internetBehaviorInfo.keys()) internetBehaviorInfoKeys = list( map(lambda x: x.decode(), internetBehaviorInfoKeys)) internetBehaviorInfoKeys = list( map(lambda x: x[:x.index(':')], internetBehaviorInfoKeys)) internetBehaviorInfoValues = list(internetBehaviorInfo.values()) internetBehaviorInfoValues = list( map(lambda x: x.decode(), internetBehaviorInfoValues)) internetBehaviorInfoValues = list(map(int, internetBehaviorInfoValues)) internetBehaviorData = [] splitNum = int(len(internetBehaviorInfoValues) / 7) internetBehaviorData.append(internetBehaviorInfoValues[:splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[splitNum:2 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[2 * splitNum:3 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[3 * splitNum:4 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[4 * splitNum:5 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[5 * splitNum:6 * splitNum]) internetBehaviorData.append(internetBehaviorInfoValues[6 * splitNum:7 * splitNum]) internetBehaviorData = pd.DataFrame(internetBehaviorData).T internetBehaviorData.columns = [ internetBehaviorInfoKeys[0], internetBehaviorInfoKeys[splitNum], internetBehaviorInfoKeys[2 * splitNum], internetBehaviorInfoKeys[3 * splitNum], internetBehaviorInfoKeys[4 * splitNum], internetBehaviorInfoKeys[5 * splitNum], internetBehaviorInfoKeys[6 * splitNum] ] internetBehaviorData.sort_values(by="date", inplace=True) internetBehaviorData_y = internetBehaviorData.loc[:, "date"].tolist() internetBehaviorData_y = list(map(str, internetBehaviorData_y)) bar = Bar(init_opts=opts.InitOpts(width="800px", height="380px")) bar.add_xaxis(internetBehaviorData_y) bar.add_yaxis(series_name="新闻资讯", yaxis_data=internetBehaviorData.loc[:, "news"].tolist(), stack="stack") bar.add_yaxis( series_name="通信交流", yaxis_data=internetBehaviorData.loc[:, "communications"].tolist(), stack="stack") bar.add_yaxis( series_name="娱乐休闲", yaxis_data=internetBehaviorData.loc[:, "entertainment"].tolist(), stack="stack") bar.add_yaxis( series_name="生活服务", yaxis_data=internetBehaviorData.loc[:, "domersticServices"].tolist(), stack="stack") bar.add_yaxis(series_name="商务应用", yaxis_data=internetBehaviorData.loc[:, "busApp"].tolist(), stack="stack") bar.add_yaxis(series_name="工具使用", yaxis_data=internetBehaviorData.loc[:, "toolUse"].tolist(), stack="stack") bar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) bar.set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"), xaxis_opts=opts.AxisOpts( name="日期", name_textstyle_opts=opts.TextStyleOpts(color="white"), ########### type_="category", axislabel_opts=opts.LabelOpts(border_color="white", color="white"), ############# axispointer_opts=opts.AxisPointerOpts(is_show=True), ), yaxis_opts=opts.AxisOpts( name="时间", name_textstyle_opts=opts.TextStyleOpts(color="white"), type_="value", min_=0, max_=24, interval=4, axislabel_opts=opts.LabelOpts(formatter="{value} 小时", border_color="white", color="white"), ########### axistick_opts=opts.AxisTickOpts(is_show=True), ), datazoom_opts=opts.DataZoomOpts(type_="inside"), legend_opts=opts.LegendOpts(is_show=True, textstyle_opts=opts.TextStyleOpts( border_color="white", color="wihte"), orient='horizontal')) bar.render("./static/html/pictureInternetBehavior.html") """个人特征图""" sValue = list(sInfo.values()) sValue = list(map(lambda x: x.decode(), sValue)) cValue = list(cInfo.values()) cValue = list(map(lambda x: x.decode(), cValue)) iValue = list(iInfo.values()) iValue = list(map(lambda x: x.decode(), iValue)) value = sValue + cValue + iValue value = list(map(int, value)) value = [value[1], value[2], value[3], value[0], value[4]] value = [value] rader = Radar(init_opts=opts.InitOpts(width="350px", height="350px")) rader.add_schema(schema=[ opts.RadarIndicatorItem(name="收入指数", max_=5), opts.RadarIndicatorItem(name="消费金\n额指数", max_=5), opts.RadarIndicatorItem(name="消费次数指数", max_=5), opts.RadarIndicatorItem(name="学历指数", max_=5), opts.RadarIndicatorItem(name="网络依\n赖指数", max_=5), ], shape='polygon') rader.add(series_name=key_name, data=value) rader.set_global_opts(legend_opts=opts.LegendOpts(is_show=False)) rader.render("./static/html/pictureCompositiveInfo.html")
liquid.render('pyecharts-liquid.html') # 雷达图 v1 = [[4300, 10000, 28000, 35000, 50000, 19000], [3300, 13000, 25000, 30000, 48000, 24000]] v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] radar = Radar() radar.add_schema(schema=[ opts.RadarIndicatorItem(name='销售', max_=6500), opts.RadarIndicatorItem(name='管理', max_=16000), opts.RadarIndicatorItem(name='信息技术', max_=30000), opts.RadarIndicatorItem(name='客服', max_=38000), opts.RadarIndicatorItem(name='研发', max_=52000), opts.RadarIndicatorItem(name='市场', max_=25000), ]) radar.add('预算分配', v1) radar.add('实际开销', v2) radar.set_global_opts(title_opts=opts.TitleOpts(title='Radar Sample')) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.render('pyecharts-radar.html') # 词云图 words = [ ('Sam S Club', 10000), ('Macys', 6181), ('Amy Schumer', 4386), ('Jurassic World', 4055), ('Charter Communications', 2467), ] wordcloud = WordCloud() wordcloud.add('', words, word_size_range=[20, 100])
def dsp_bv(): # 显示育种值 import xlrd prepare = locals() # file = "breeding.xlsx" f1 = xlrd.open_workbook(file) sheet1 = f1.sheet_by_name('Sheet1') radar = Radar(init_opts=opts.InitOpts( width="1280px", height="720px", #bg_color='rgba(255,250,205,0.2)' )) lst1 = bv(file)[0] # 接收计算的给性状各公牛的育种值 lst2 = bv(file)[1] # 公牛编号 lst3 = bv(file)[2] # 性状名 for i in range(len(lst1[0])): # 初始化各公牛的个性状育种值列表(每个列表代表一头公牛个性状的育种值) prepare["blupscore" + str(i)] = [] for i in range(len(lst2)): # 公牛编号 for j in range(len(lst3)): # 性状 prepare["blupscore" + str(i)].append(round(lst1[j][i], 4)) scoreprint = [[] for i in range(3)] for i in range(len(lst2)): scoreprint[i].append(prepare["blupscore" + str(i)]) # for i in range(len(lst2)): # print(scoreprint[i]) # lst3 = cbv(file)[2] radar.add_schema(schema=[ opts.RadarIndicatorItem(name="体重", max_=10, min_=-10), opts.RadarIndicatorItem(name="体高", max_=10, min_=-10), opts.RadarIndicatorItem(name="体长", max_=10, min_=-10), opts.RadarIndicatorItem(name="胸围", max_=10, min_=-10), opts.RadarIndicatorItem(name="眼肌面积", max_=10, min_=-10) ], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="black")) color = ["red", "blue", "green", "black", "purple"] for i in range(len(lst2)): radar.add(series_name=str(int(lst2[i])), data=scoreprint[i], color=color[i] ) # series_name的value要为str类型,否则不会显示opts.LegendOpts()效果 # radar.add(series_name=str(lst2[0]), data=scoreprint[0], color=color[0]) # radar.add(series_name=str(lst2[1]), data=scoreprint[1], color=color[1]) radar.set_global_opts(title_opts=opts.TitleOpts(title="显示已有数据的各公牛的性状育种值"), legend_opts=opts.LegendOpts()) # v1 = [[4300, 10000, 28000, 35000, 50000, 19000]] # v2 = [[5000, 14000, 28000, 31000, 42000, 21000]] # c = ( # Radar() # .add_schema( # schema=[ # opts.RadarIndicatorItem(name="销售", max_=6500), # opts.RadarIndicatorItem(name="管理", max_=16000), # opts.RadarIndicatorItem(name="信息技术", max_=30000), # opts.RadarIndicatorItem(name="客服", max_=38000), # opts.RadarIndicatorItem(name="研发", max_=52000), # opts.RadarIndicatorItem(name="市场", max_=25000), # ] # ) # .add("预算分配", v1) # .add("实际开销", v2) # .set_series_opts(label_opts=opts.LabelOpts(is_show=False)) # .set_global_opts( # legend_opts=opts.LegendOpts(selected_mode="single"), # title_opts=opts.TitleOpts(title="Radar-单例模式"), # )) # radar.render("display.html") picture = radar return render_template("display.html", picture_options=picture.dump_options())
if __name__ == '__main__': print(year_store_query()) dataX, dataY1, dataY2 = year_store_query() radar = Radar(init_opts=opts.InitOpts( width="1280px", height="720px", bg_color="#CCCCCC")) radar.add_schema( schema=[ opts.RadarIndicatorItem(name="门店订单金额", max_=34000), opts.RadarIndicatorItem(name="门店顾客数", max_=10000), opts.RadarIndicatorItem(name="门店商品类型", max_=10000), opts.RadarIndicatorItem(name="门店订单量", max_=10000) ], splitarea_opt=opts.SplitAreaOpts( is_show=True, areastyle_opts=opts.AreaStyleOpts(opacity=1)), textstyle_opts=opts.TextStyleOpts(color="#fff"), ) radar.add( series_name="Store 1", data=[list(dataY1)], linestyle_opts=opts.LineStyleOpts(color="#CD0000"), ) radar.add( series_name="Store 2", data=[list(dataY2)], linestyle_opts=opts.LineStyleOpts(color="#5CACEE"), ) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) radar.set_global_opts(title_opts=opts.TitleOpts(title="2005年门店竞争优势多维分析"), legend_opts=opts.LegendOpts()) radar.render('radar.html')
def Cartography(): #创建地图 map = Map( init_opts=opts.InitOpts(width="1900px", height="900px", bg_color="#d0effa", page_title="全球新冠疫情_1")) map.add("确诊人数",[list(z) for z in zip(names_new, confirm)],is_map_symbol_show=False, maptype="world",label_opts=opts.LabelOpts(is_show=False),itemstyle_opts=opts.ItemStyleOpts(color="rgb(98,121,146)"))#地图区域颜色 map.set_global_opts(title_opts = opts.TitleOpts(title='全球新冠疫情确诊人数'),legend_opts=opts.LegendOpts(is_show=False), visualmap_opts=opts.VisualMapOpts(max_=2000000, is_piecewise=True, pieces=[ {"max": 3000000,"min": 500001,"label":">500000","color":"#460303"}, {"max": 500000, "min": 100001, "label": "100001-500000", "color": "#8A0808"}, {"max": 100000, "min": 10001, "label": "10001-100000", "color": "#B40404"}, {"max": 10000, "min": 1001, "label": "1001-10000", "color": "#DF0101"}, {"max": 1000, "min": 101, "label": "101-1000", "color": "#F78181"}, {"max": 100, "min": 1, "label": "1-100", "color": "#F5A9A9"}, {"max": 0, "min": 0, "label": "0", "color": "#fababa"}, ]) ) map.render('Global_new_crown_epidemic_map.html') #创建饼图 pie = Pie(init_opts=opts.InitOpts(width='1900px', height='900px',page_title="全球新冠疫情_2",bg_color="#fee4e7")) # 添加数据 pie.add("", [list(z) for z in zip(country_list, dead_list)], radius=['20%', '100%'],#设置内径外径 center=['60%', '65%'], rosetype='area')#圆心角相同,通过半径展现数据大小#rosetype='radius'圆心角展现数据百分比,半径展现数据大小 # 设置全局配置 pie.set_global_opts(title_opts=opts.TitleOpts(title='全球新冠疫情',subtitle='死亡人数超过\n5000的国家\n (除中国)', title_textstyle_opts=opts.TextStyleOpts(font_size=15,color= '#f40909'), subtitle_textstyle_opts= opts.TextStyleOpts(font_size=15,color= '#8a0b0b'), pos_right= 'center',pos_left= '57%',pos_top= '60%',pos_bottom='center'), legend_opts=opts.LegendOpts(is_show=False)) # 设置系列配置和颜色 pie.set_series_opts(label_opts=opts.LabelOpts(is_show=True, position='inside', font_size=13, formatter='{b}:{c}', font_style='italic', font_family='Microsoft YaHei')) pie.set_colors(color_matching) pie.render('Global_new_crown_epidemic_Rose.html') #创建雷达图 radar = Radar(init_opts=opts.InitOpts(width='1900px',height='900px',page_title="全球新冠疫情_3",bg_color="#d1eff3")) #由于雷达图传入的数据得为多维数据,所以这里需要做一下处理 radar_data1 = [list(dead_list)] radar_data2 = [list(heal_list)] radar.add_schema( schema=[ opts.RadarIndicatorItem(name='巴西', max_=8000), opts.RadarIndicatorItem(name='荷兰', max_=8000), opts.RadarIndicatorItem(name='伊朗', max_=20000), opts.RadarIndicatorItem(name='德国', max_=40000), opts.RadarIndicatorItem(name='比利时', max_=70000), opts.RadarIndicatorItem(name='英国', max_=80000), opts.RadarIndicatorItem(name='法国 ', max_=110000), opts.RadarIndicatorItem(name='西班牙', max_=150000), opts.RadarIndicatorItem(name='意大利', max_=170000), opts.RadarIndicatorItem(name='美国', max_=220000), ] ) radar.add("死亡人数",radar_data1,color='blue',areastyle_opts = opts.AreaStyleOpts(opacity = 0.2,color='blue')) radar.add("治愈人数",radar_data2,color='red',areastyle_opts=opts.AreaStyleOpts(opacity=0.3,color='red')) radar.set_series_opts(label_opts=opts.LabelOpts(is_show=True)) radar.set_global_opts(title_opts=opts.TitleOpts(title="死亡人数与治愈人数对比")) radar.render("Death_Versus_Heal.html")