def get_gauge(data_y: list, gauge_name=""): gauge = Gauge() gauge.add( gauge_name, [(gauge_name, (sum(data_y) * 100) / (len(data_y) * max(data_y)))], axisline_opts=opts.AxisLineOpts(linestyle_opts=opts.LineStyleOpts( color=[(0.3, "#67e0e3"), (0.7, "#37a2da"), (1, "#fd666d")], width=30), ), ) gauge.set_global_opts( # title_opts=opts.TitleOpts(title=gauge_name), legend_opts=opts.LegendOpts(is_show=False), ) return gauge
def gauge_html(self, chart_id, title, val): # 实例化 gauge = Gauge(self.init_opts) # 绑定id gauge.chart_id = chart_id # 添加参数 gauge.add("", [("", val)], min_=0, max_=100) # 全局参数 gauge.set_global_opts( title_opts=self.title_opts(title), # 标题选项 legend_opts=options.LegendOpts(is_show=False), # 不显示图例组件 ) # 返回图表html代码 return gauge.render_embed()
def gauge(dados, componente, metrica, temaEscuro=False, abrir_local=False): if (temaEscuro): gauge = Gauge(init_opts=opts.InitOpts(theme=ThemeType.CHALK)) else: gauge = Gauge(init_opts=opts.InitOpts(theme=ThemeType.VINTAGE)) gauge.add('', [(componente, dados)], start_angle=190, end_angle=-10, title_label_opts=opts.GaugeTitleOpts(font_size=28, color=("white" if temaEscuro else "black")), detail_label_opts=opts.GaugeDetailOpts(font_size=36, offset_center=[0, "25%"], formatter=(str(dados) + str(metrica)), color=("white" if temaEscuro else "black"))) gauge.set_global_opts(title_opts=opts.TitleOpts(title="Uso de " + componente)) make_snapshot(driver, gauge.render("chart.html"), "chart.png") abrirGrafico(abrir_local) return 0
def getGauge(self, sheet: xlrd.sheet) -> Gauge: key = sheet.cell(0, 0).value value = sheet.cell(0, 1).value g = Gauge() g.add( series_name=sheet.name, data_pair=[(key, value)], title_label_opts=opts.LabelOpts(font_size=40, color="blue", font_family="Microsoft YaHei"), ) #改标题字体颜色 g.set_global_opts( legend_opts=opts.LegendOpts(is_show=False), #tooltip_opts=opts.TooltipOpts(is_show=True, formatter="{a} <br/>{b} : {c}%",textstyle_opts=opts.TextStyleOpts(color="#fff")),#图例颜色和显示格式 title_opts=opts.TitleOpts(title=sheet.name) #加上图标题 ) return g
def gauge_html(self, chart_id, title, val): gauge = Gauge(init_opts=opts.InitOpts(width="100%", height="300px")) gauge.set_global_opts( title_opts=opts.TitleOpts( title="{}-{}".format(self.dt, title), title_textstyle_opts=opts.TextStyleOpts(color="white", font_size=14), pos_left="center" ), legend_opts=opts.LegendOpts(is_show=False), ) # 绑定id gauge.chart_id = chart_id gauge.add( series_name="", data_pair=[["", val]], title_label_opts=opts.LabelOpts(color="white"), ) return gauge.render_embed() # 返回图表html代码
def NPS(NPS_List): Item = NPS_List[0] nps = NPS_List[1] laber = str(NPS_List[1]) + '%' gauge =Gauge( init_opts=opts.InitOpts( width='400px', height='300px' ) ) gauge.add( series_name=Item, data_pair=[('NPS',nps)], min_=-100, max_=100, split_number=4, axisline_opts=opts.AxisLineOpts( linestyle_opts=opts.LineStyleOpts( color=[[0.5, "#37a2da"], [1, "#fd666d"]], width=30 ) ), itemstyle_opts=opts.ItemStyleOpts( color='rgba(212,105,105,1)' ), detail_label_opts=opts.LabelOpts( font_size=20, position='bottom', formatter=laber ) ) gauge.set_global_opts( title_opts=opts.TitleOpts( subtitle='NPS-' + Item, pos_right='center', subtitle_textstyle_opts=opts.TextStyleOpts( color='rgba(0,0,0,0.8)', font_size=16 ) ), legend_opts=opts.LegendOpts(is_show=False) ) return gauge
def BG(): gauge =Gauge( init_opts=opts.InitOpts( bg_color={"type": "pattern", "image": JsCode("img"), "repeat": "no-repeat"}, width='1200px', height='300px' ) ) gauge.set_global_opts( title_opts=opts.TitleOpts( title='碧桂园集中式商业消费者满意度研究', pos_left='center', title_textstyle_opts=opts.TextStyleOpts( color='rgba(0,0,0,0.8)', font_size=20 ) ) ) gauge.add_js_funcs("var img = new Image(); img.src = 'https://s1.ax1x.com/2020/03/27/GPWPKI.jpg';") return gauge