def to_treemap(data, proj, version): complexity = {'name': f'{proj}-{version}', 'children': []} extract(complexity, 'complexity', data) maintainability = {'name': f'{proj}-{version}', 'children': []} extract(maintainability, 'maintainability', data) testability = {'name': f'{proj}-{version}', 'children': []} extract(testability, 'testability', data) readability = {'name': f'{proj}-{version}', 'children': []} extract(readability, 'readability', data) reusability = {'name': f'{proj}-{version}', 'children': []} extract(reusability, 'reusability', data) inheritance = {'name': f'{proj}-{version}', 'children': []} extract(inheritance, 'inheritance', data) treemap = TreeMap() for indicator in [ 'complexity', 'maintainability', 'testability', 'readability', 'reusability', 'inheritance' ]: treemap = treemap.add(series_name=indicator, data=[locals()[indicator]], leaf_depth=2, roam=False, label_opts=opts.LabelOpts(position='inside')) treemap = (treemap.set_global_opts( tooltip_opts=opts.TooltipOpts(formatter='{b}<br/>{a}: {c}'), toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts( magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_='clear'))), legend_opts=opts.LegendOpts(is_show=True, selected_mode='single', pos_top='7%', orient='horizontal', padding=0), title_opts=opts.TitleOpts( title=f'Code Quality Treemap of {proj}-{version}', pos_left='center'))) grid = Grid() grid.add(treemap, grid_opts=opts.GridOpts(pos_top='100%')) return grid
def to_linechart(data, proj): versions = [version['version_name'] for version in data] linechart = Line().add_xaxis(xaxis_data=versions) for indicator in [ 'complexity', 'maintainability', 'testability', 'readability', 'reusability', 'inheritance' ]: linechart = linechart.add_yaxis( series_name=indicator, y_axis=[round(version[indicator], 2) for version in data], is_smooth=True, label_opts=opts.LabelOpts(is_show=False), linestyle_opts=opts.LineStyleOpts(width=2), ) linechart = (linechart.set_global_opts( tooltip_opts=opts.TooltipOpts(trigger="axis", axis_pointer_type="cross"), xaxis_opts=opts.AxisOpts(boundary_gap=False), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value}"), splitline_opts=opts.SplitLineOpts(is_show=True), ), toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts( magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_='clear'))), legend_opts=opts.LegendOpts(is_show=True, pos_top='middle', pos_left='1%', orient='vertical', padding=0), datazoom_opts=opts.DataZoomOpts(type_='slider', range_start=0, range_end=100), title_opts=opts.TitleOpts(title=f'Code Quality Linechart of {proj}', pos_left='center'))) grid = Grid() grid.add(linechart, grid_opts=opts.GridOpts(pos_left='150')) return grid
def dayloss_line_base(self, x, y, t, st): c = (Line( init_opts=opts.InitOpts(width="1000px", height="500px") ).add_xaxis(x).add_yaxis("线损率(%)", y, is_smooth=True).set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"), title_opts=opts.TitleOpts(title=t, subtitle=st), xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=-90), max_interval=366, type_="category", axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value} %"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( pixel_ratio=2, background_color='white'), restore=opts.ToolBoxFeatureRestoreOpts(is_show=False), data_view=opts.ToolBoxFeatureDataViewOpts(is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False), magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_='clear'), ))).set_series_opts( label_opts=opts.LabelOpts(is_show=False), markline_opts=opts.MarkLineOpts( data=[ opts.MarkLineItem(y=6), ], label_opts=opts.LabelOpts(is_show=False), ), )) return c
def __init__(self, title: str, output: str): self.title = title self.output = output self.datas = [] self.chart = (Line(init_opts=opts.InitOpts( page_title=self.title, theme=ThemeType.DARK, width="1280px", height="720px", )).set_global_opts( title_opts=opts.TitleOpts(title=self.title), xaxis_opts=opts.AxisOpts(type_="value", is_scale=True, split_number=10, name="bitrate/kbps"), yaxis_opts=opts.AxisOpts(type_="value", is_scale=True, name="vmaf"), toolbox_opts=opts.ToolboxOpts( is_show=True, orient="vertical", pos_left="right", feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( title="save as image", is_show=True), restore=opts.ToolBoxFeatureRestoreOpts(is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False), data_view=opts.ToolBoxFeatureDataViewOpts( is_show=False, is_read_only=True, title="data"), magic_type=opts.ToolBoxFeatureMagicTypeOpts(is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_=[]))), legend_opts=opts.LegendOpts(pos_top="bottom"), tooltip_opts=opts.TooltipOpts( is_show=True, formatter=pyecharts_utils.JsCode( "function(x) {return x.seriesName + '<br/>bitrate '+ x.data[0] + ' kbps<br/>vmaf ' + x.data[1];}" ))))
# 提示语 title="数据视图", # 是否不可编辑 is_read_only=False, ), # 缩放工具配置项,直角坐标系适用 opts.ToolBoxFeatureDataZoomOpts( # 是否显示该工具。 is_show=False, # 提示语 zoom_title="区域缩放", # 提示语 back_title="区域缩放还原", ), # 图表类型切换,适用于直角坐标系 opts.ToolBoxFeatureMagicTypeOpts( # 是否显示该工具 is_show=False, # 启用的动态类型 type_=['stack', 'line', 'bar', 'tiled'], ), # 工具箱选框组件配置项 opts.ToolBoxFeatureBrushOpts( # 选择显示哪些选框 type_=[]), )), ) maps.render('map.html')
def plot_ground_truth_analysis( all_score_columns: typing.List[str], title: str, output_path: str, df: pd.DataFrame, add_wrong_candidates: bool = False, wrong_candidates_score_column: str = None, ) -> None: """ use pyechart to plot html interactive figure """ df_processed = copy.deepcopy(df) for each_col in df_processed.columns: df_processed[each_col] = pd.to_numeric(df_processed[each_col], errors='ignore') xaxis_labels = [] memo = defaultdict(list) groupby_res = df_processed[df_processed["evaluation_label"] == 1].groupby(["column", "row"]) for key, each_group in reversed(tuple(groupby_res)): if add_wrong_candidates: df_wrong_examples = df_processed[(df_processed["column"] == key[0]) & (df_processed["row"] == key[1]) & (df_processed["evaluation_label"] == -1)] \ .sort_values(by=[wrong_candidates_score_column], ascending=False).iloc[:3, :] # add wrong candidate information for _, each_row in df_wrong_examples.iterrows(): longest_string = max(each_row["kg_labels"].split("|"), key=len) xaxis_labels.append(each_row["label_clean"] + " \n({})".format(longest_string)) for each_score_column in all_score_columns: memo[each_score_column].append("{:.2f}".format( each_row[each_score_column])) # add ground truth information xaxis_labels.append(each_group["label_clean"].iloc[0]) for each_score_column in all_score_columns: memo[each_score_column].append("{:.2f}".format( each_group[each_score_column].iloc[0])) # build figure bar = Bar() bar.add_xaxis(xaxis_labels) for k, v in memo.items(): bar.add_yaxis(k, v) # set the global options bar.set_global_opts( title_opts=opts.TitleOpts(title=title, pos_left='40%'), legend_opts=opts.LegendOpts(pos_left="center", pos_top="bottom", orient='horizontal'), brush_opts=opts.BrushOpts(), toolbox_opts=opts.ToolboxOpts(feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( title="save as image"), magic_type=opts.ToolBoxFeatureMagicTypeOpts( line_title="switch to line chart", bar_title="switch to bar chart", stack_title="switch to stacked values", tiled_title="switch to tiled values"), data_zoom=opts.ToolBoxFeatureDataZoomOpts( zoom_title="zoom in", back_title="zoom reset"), restore=opts.ToolBoxFeatureRestoreOpts(title="reset"), data_view=opts.ToolBoxFeatureDataViewOpts( title="Data table view", lang=["Table view", "Close", "Refresh"], ), brush=opts.ToolBoxFeatureBrushOpts( rect_title="rectangle choice", polygon_title="polygon choice", clear_title="clear choices", keep_title="keep choices"))), datazoom_opts=opts.DataZoomOpts(orient="vertical"), # yaxis_opts=opts.AxisOpts(name='labels', name_gap=5000, name_rotate=15), tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="shadow"), xaxis_opts=opts.AxisOpts(axistick_opts=opts.AxisTickOpts( is_inside=True, length=850, linestyle_opts=opts.LineStyleOpts(type_="dotted", opacity=0.5)))) # do not shown bar label values bar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) bar.reversal_axis() grid = (Grid(init_opts=opts.InitOpts( width="1500px", height="1000px", page_title="Table Linker visualization page")).add( bar, grid_opts=opts.GridOpts(pos_top='5%', pos_bottom="10%", pos_right='5%', pos_left="20%"))) grid.render(output_path + ".html")
# 是否显示该工具。 is_show=True, # 提示语 zoom_title="区域缩放", # 提示语 back_title="缩放还原", ), # 图表类型切换,适用于直角坐标系 opts.ToolBoxFeatureMagicTypeOpts( # 是否显示该工具 is_show=True, # 启用的动态类型('stack','line','bar','tiled') type_=['stack', 'line', 'bar', 'tiled'], # 折线标题文本 line_title="折线图", # 柱状标题文本 bar_title="柱状图", # 堆积标题文本 stack_title="堆叠", # 平铺标题文 tiled_title="平铺", ), # 工具箱选框组件配置项 opts.ToolBoxFeatureBrushOpts( # 选择显示哪些选框 type_=[] ), ) ), )
def day_sxdl(self, x, mc, a, b, c, k): c = (Line( init_opts=opts.InitOpts(width="1000px", height="500px") ).add_xaxis(x).add_yaxis("电压A", a, is_smooth=True).add_yaxis( "电压B", b, is_smooth=True).add_yaxis( "电压C", c, is_smooth=True).set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"), title_opts={ 'text': mc, 'subtext': None }, xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=-90), max_interval=366, type_="category", axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value} v"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), toolbox_opts=opts. ToolboxOpts(feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( pixel_ratio=2, background_color='white'), restore=opts.ToolBoxFeatureRestoreOpts(is_show=False), data_view=opts.ToolBoxFeatureDataViewOpts( is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts( is_show=False), magic_type=opts.ToolBoxFeatureMagicTypeOpts( is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_='clear'), ))).set_series_opts(label_opts=opts.LabelOpts( is_show=False), ).extend_axis( yaxis=opts.AxisOpts(name='方差', axislabel_opts=opts.LabelOpts( formatter="{value} ")))) line1 = Line().add_xaxis(x).add_yaxis( "方差", k, yaxis_index=1, is_smooth=True, linestyle_opts=opts.LineStyleOpts( color="black", width=2, type_="solid")).set_series_opts( label_opts=opts.LabelOpts(is_show=False), ) c.overlap(line1) return c # def day_loss_1(self,x,y,t,st,z,m): # c = self.dayloss_line_base(x,y,t,st) # c = c.extend_axis( # yaxis=opts.AxisOpts( # axislabel_opts=opts.LabelOpts(formatter="{value} kWh") # ) # ).extend_axis( # yaxis=opts.AxisOpts( # name = '数据完整率', # position = 'right', # offset = 62, # axislabel_opts=opts.LabelOpts(formatter="{value} "), # axisline_opts=opts.AxisLineOpts( # linestyle_opts=opts.LineStyleOpts(color="#675bba") # ), # ) # ) # line = Line().add_xaxis(x).add_yaxis("供入电量", z,yaxis_index=1,is_smooth=True).set_series_opts( # label_opts=opts.LabelOpts(is_show=False), ) # line_1 = Line().add_xaxis(x).add_yaxis("数据完整率", m,yaxis_index=2).set_series_opts( # label_opts=opts.LabelOpts(is_show=False), ) # c.overlap(line) # c.overlap(line_1) # return c # def day_loss_2(self,x,y,t,st,a,b): # c = self.dayloss_line_base(x,y,t,st) # c = c.extend_axis( # yaxis=opts.AxisOpts( # axislabel_opts=opts.LabelOpts(formatter="{value} kWh") # ) # ) # line = Line().add_xaxis(a).add_yaxis("用电量", b,yaxis_index=1,is_smooth=True).set_series_opts( # label_opts=opts.LabelOpts(is_show=False), ) # c.overlap(line) # return c # class electricity(): # """docstring for electricity""" # def __init__(self,df): # self.df = df # def day_data(self,a): # tq = self.df[self.df.测量点号==a][['数据时间','正向']].set_index('数据时间').sort_values(by='数据时间') # x = [i[-5:] for i in tq.index] # y = [float(i[0]) for i in tq.values] # t = a # return x,y,t # def measure_num(self): # num = set(i for i in self.df.测量点号) # num = list(num)[1:] # return num # class relation(object): # """docstring for relation""" # def curr_relation(self,x,y,a,b): # lineloss = pd.Series(y,index=x) # day_electricity = pd.Series(b,index= a) # c = lineloss.corr(day_electricity) # # c1 = lineloss.cov(day_electricity) # return c # IO = '石鼓12月.xls' # k = [] # day_loss = data(IO) # tq_index = day_loss.day_lineloss_index() # for i in tq_index: # x,y,a,z,m = data(IO).day_lineloss(i) # nc = relation().curr_relation(x,y,x,z) # c = drawing().day_loss_1(x,y, a+ str(nc),z,m) # k.append(c) # drawing().all_day_lineloss(k,'石鼓12') # IO = '石鼓12月.xls' # name = '宝丰12.xlsx' # num = electricity(name).measure_num() # day_loss = data(IO) # a,b,j,z,m = data(IO).day_lineloss('宝丰公用台变') # k1 = [] # for i in num: # x,y,t = electricity(name).day_data(i) # c = relation().curr_relation(a,b,x,y) # c1 = drawing().day_loss_2(a,b,str(t)+' & '+str(c),x,y) # k1.append(c1) # ny = np.array(electricity(name).day_data(92)[1]) + np.array(electricity(name).day_data(37)[1]) # c = relation().curr_relation(a,b,x,ny) # c1 = drawing().day_loss_2(a,b,'9237'+str(c),x,ny) # k1.append(c1) # drawing().all_day_lineloss(k1,'宝丰12') # k2 = [] # for i in num: # x,y,t = electricity(name).day_data(i) # c = relation().curr_relation(a,b,x,y) # k2.append(c) # print(str(c) + 10*'-'+str(i)) # print(10*'--') # k3 = [] # nyy= [] # for i in num: # x,y,t = electricity(name).day_data(i) # c = relation().curr_relation(a,b,x,y) # print(c[0]) # if c[0] > 0.5: # nyy.append(np.array(y)) # c1 = drawing().day_loss_2(a,b,t,x,y) # k3.append(c1) # c2 = drawing().day_loss_2(a,b,'all',x,sum(nyy)) # k3.append(c2) # drawing().all_day_lineloss(k3,'test_class_5') # c = relation().curr_relation(a,b,x,sum(nyy)) # print(c)
def html_plot(file): sp = file.split(".") with open(file) as f: l = f.readlines() i = 0 ks = {} for line in l: if i == 0: head = line.strip().split("\t") i = 1 else: t = line.strip().split("\t") name = t[0] del t[0] ks[name] = t bar = Bar(init_opts=opts.InitOpts( page_title=sp[0] + "-ks.htmlpolt", width="1500px", height="700px")) bar.add_xaxis(head) for key, value in ks.items(): bar.add_yaxis(key, value, category_gap=0, stack="stack1", is_large=True) bar.set_series_opts(label_opts=opts.LabelOpts(is_show=False)) bar.set_global_opts( title_opts=opts.TitleOpts(title=sp[0] + ".ks.polt", subtitle="Plot by Tree2gd v1.0"), toolbox_opts=opts.ToolboxOpts( is_show=True, pos_top='10%', orient='vertical', pos_left='right', feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( title="Save as png"), restore=opts.ToolBoxFeatureRestoreOpts(title="Recovery"), data_view=opts.ToolBoxFeatureDataViewOpts( title="Data", lang=['Data View', 'Close', 'Refresh']), data_zoom=opts.ToolBoxFeatureDataZoomOpts(is_show=False), magic_type=opts.ToolBoxFeatureMagicTypeOpts( line_title="Switch to line plot", bar_title="Switch to histogram plot", stack_title="Switch to stack plot", tiled_title="Switch to tiled plot"), brush=opts.ToolBoxFeatureBrushOpts( rect_title="Rectangle selection", polygon_title="Circle selection", line_x_title="X line selection", line_y_title="Y line selection", keep_title="Keep selection", clear_title="Clear selection"), )), legend_opts=opts.LegendOpts(pos_left='right', ), datazoom_opts=[ opts.DataZoomOpts(range_start=0, range_end=60), opts.DataZoomOpts(type_="inside") ], xaxis_opts=opts.AxisOpts(name="Ks"), ) bar.render(os.sep.join(["..", "ks_html_plot", sp[0] + ".ks.plot.html"]))
def day_sxdl(self, x, mc, a, b, c, m, n, rca, rcb, rcc, j, rcj): c = (Line( init_opts=opts.InitOpts(width="1000px", height="500px") ).add_xaxis(x).add_yaxis( "电流A", a, is_smooth=True, itemstyle_opts=opts.ItemStyleOpts(color='black')).add_yaxis( "电流B", b, is_smooth=True, itemstyle_opts=opts.ItemStyleOpts(color='blue')).add_yaxis( "电流C", c, is_smooth=True, itemstyle_opts=opts.ItemStyleOpts( color='green')).set_global_opts( tooltip_opts=opts.TooltipOpts( is_show=True, trigger="axis", axis_pointer_type="cross"), title_opts=opts.TitleOpts( title=mc, subtitle='A: ' + str(rca)[:12] + ' ' + 'B: ' + str(rcb)[:12] + ' ' + 'C: ' + str(rcc)[:12] + ' '), xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=-90), max_interval=366, type_="category", axispointer_opts=opts.AxisPointerOpts( is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts( formatter="{value} A"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts( is_show=True), ), toolbox_opts=opts. ToolboxOpts(feature=opts.ToolBoxFeatureOpts( save_as_image=opts. ToolBoxFeatureSaveAsImageOpts( pixel_ratio=2, background_color='white'), restore=opts.ToolBoxFeatureRestoreOpts( is_show=False), data_view=opts.ToolBoxFeatureDataViewOpts( is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts( is_show=False), magic_type=opts.ToolBoxFeatureMagicTypeOpts( is_show=False), brush=opts.ToolBoxFeatureBrushOpts( type_='clear'), ))).set_series_opts( label_opts=opts.LabelOpts(is_show=False), ). extend_axis(yaxis=opts.AxisOpts(name='线损率', axislabel_opts=opts.LabelOpts( formatter="{value} %")))) line = (Line(init_opts=opts.InitOpts( width="1000px", height="500px")).add_xaxis(m).add_yaxis( "线损率", n, is_smooth=True, linestyle_opts=opts.LineStyleOpts(color="red", width=2, type_="solid") ).set_series_opts( label_opts=opts.LabelOpts(is_show=False), ).set_global_opts( tooltip_opts=opts.TooltipOpts(is_show=True, trigger="axis", axis_pointer_type="cross"), title_opts=opts.TitleOpts(title=mc, subtitle='相关性系数: ' + str(rcj)[:12]), xaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(rotate=-90), max_interval=366, type_="category", axispointer_opts=opts.AxisPointerOpts(is_show=True, type_="shadow"), ), yaxis_opts=opts.AxisOpts( axislabel_opts=opts.LabelOpts(formatter="{value} %"), axistick_opts=opts.AxisTickOpts(is_show=True), splitline_opts=opts.SplitLineOpts(is_show=True), ), toolbox_opts=opts. ToolboxOpts(feature=opts.ToolBoxFeatureOpts( save_as_image=opts.ToolBoxFeatureSaveAsImageOpts( pixel_ratio=2, background_color='white'), restore=opts.ToolBoxFeatureRestoreOpts(is_show=False), data_view=opts.ToolBoxFeatureDataViewOpts( is_show=False), data_zoom=opts.ToolBoxFeatureDataZoomOpts( is_show=False), magic_type=opts.ToolBoxFeatureMagicTypeOpts( is_show=False), brush=opts.ToolBoxFeatureBrushOpts(type_='clear'), ))).set_series_opts(label_opts=opts.LabelOpts( is_show=False), ).extend_axis( yaxis=opts.AxisOpts(name='方差', axislabel_opts=opts.LabelOpts( formatter="{value} ")))) line3 = (Line().add_xaxis(m).add_yaxis( "线损率", n, yaxis_index=1, is_smooth=True, is_selected=False, linestyle_opts=opts.LineStyleOpts( color="red", width=2, type_="dotted")).set_series_opts( label_opts=opts.LabelOpts(is_show=False), )) line1 = Line().add_xaxis(x).add_yaxis( "方差", j, yaxis_index=1, is_smooth=True, linestyle_opts=opts.LineStyleOpts( color="black", width=2, type_="solid")).set_series_opts( label_opts=opts.LabelOpts(is_show=False), ) d = line.overlap(line1) c.overlap(line3) return c, d
def Plot(self, jine: list, hushu: list, coef: list, date :str = None, title : str = None, size_def = lambda x: 50 if 10 + x > 50 else 10 + x): ##配置全局变量 j_list = [0 for _ in jine] h_list = [0 for _ in hushu] plot = Scatter(init_opts = opts.InitOpts(width = self.width, height = self.height, theme = self.theme)) plot.set_global_opts( title_opts=opts.TitleOpts(title=title), xaxis_opts = opts.AxisOpts(type_="value", splitline_opts=opts.SplitLineOpts(is_show=False), min_ = self.x_min, max_ = self.x_max, name = self.data_name[self.x_index]), yaxis_opts = opts.AxisOpts(type_="value", splitline_opts=opts.SplitLineOpts(is_show=False), min_ = self.y_min, max_ = self.y_max, name = self.data_name[self.y_index]), toolbox_opts = opts.ToolboxOpts(orient = 'horizontal', pos_top = 0, feature = opts.ToolBoxFeatureOpts( save_as_image = opts.ToolBoxFeatureSaveAsImageOpts(type_ = "jpeg", pixel_ratio = 4, background_color = 'white'), restore = opts.ToolBoxFeatureRestoreOpts(), data_zoom = opts.ToolBoxFeatureDataZoomOpts(), data_view = opts.ToolBoxFeatureDataViewOpts(is_show = False), magic_type = opts.ToolBoxFeatureMagicTypeOpts(is_show = False), brush = opts.ToolBoxFeatureBrushOpts(type_=[]))), tooltip_opts=opts.TooltipOpts(is_show=True, trigger="item", axis_pointer_type="cross") ) ##逐个添加点 for item in self.data_value: #数据处理 local = str(item[self.local_index]) num = float(item[self.x_index]) gold = float(item[self.y_index]) name = str(item[self.name_index]) size = 0. for s in range(len(self.size_index)): size += item[self.size_index[s]]*self.size_coef[s] tips = '日期:{}'.format(date) for s in range(len(self.data_name)): tips += '<br>' tips += '{}:{}'.format(self.data_name[s], item[s]) #添加点及其tips plot.add_xaxis([num]) plot.add_yaxis(local, [gold], symbol_size = size_def(size), tooltip_opts=opts.TooltipOpts(formatter = tips), label_opts=opts.LabelOpts(formatter = name)) #计算达标人数 for i in range(len(j_list)): if gold >= jine[i]: j_list[i] += 1 for i in range(len(h_list)): if num >= hushu[i]: h_list[i] += 1 ##添加达标线及其注释点 for item in range(len(j_list)): plot.add_xaxis([self.x_max]) plot.add_yaxis('达标线', [jine[item]], symbol_size = 25, symbol = 'pin', label_opts = opts.LabelOpts(is_show = False), tooltip_opts = opts.TooltipOpts(formatter = '达标人数:{}<br>未达标人数:{}'.format(j_list[item], self.num-j_list[item])), markline_opts = opts.MarkLineOpts(data = [opts.MarkLineItem(y = jine[item], name = '金额达标线{}'.format(i+1))], label_opts = opts.LabelOpts(is_show = False), symbol_size = 0)) for item in range(len(h_list)): plot.add_xaxis([hushu[item]]) plot.add_yaxis('达标线', [self.y_max], symbol_size = 25, symbol = 'pin', label_opts = opts.LabelOpts(is_show = False), tooltip_opts = opts.TooltipOpts(formatter = '奖励系数:x{}<br>达标人数:{}<br>未达标人数:{}'.format(coef[item], h_list[item], self.num-h_list[item])), markline_opts = opts.MarkLineOpts(data = [opts.MarkLineItem(x = hushu[item], name = '户数达标线{}'.format(i+1))], label_opts = opts.LabelOpts(is_show = False), symbol_size = 0)) return plot