Exemple #1
0
 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()
Exemple #2
0
    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代码