def gen_bar_base() -> Bar: c = Bar("Bar") c.set_options(labels=["A", "B"], x_label="I'm xlabel", y_label="I'm ylabel") c.add_series("series-A", ["1", "2"]) return c
def bar_base(): chart = Bar("Bar-基本示例", width="100%") chart.set_options(labels=["可乐", "雪碧", "橙汁", "绿茶", "奶茶", "百威", "青岛"], x_label="I'm xlabel", y_label="I'm ylabel") chart.add_series("series-A", [127, 33, 110, 29, 146, 121, 36]) return put_html(chart.render_notebook())
def drawBar(title, data, series_name, x_label, y_label, savedir='results'): checkDir(savedir) chart = Bar(title) chart.set_options(labels=list(data.keys()), x_label=x_label, y_label=y_label) chart.add_series(series_name, list(data.values())) chart.render(os.path.join(savedir, title + '.html'))
def create_chart_extension_dict(extension_dict): extension_dict = dict( sorted(extension_dict.items(), key=lambda item: item[1])) labels = list(extension_dict.keys()) values = list(extension_dict.values()) chart = Bar("The chart for the number of file extensions") chart.set_options(labels=labels, x_label="Extensions", y_label="Number of extensions", colors=['#E09DE1' for _ in range(len(labels))]) chart.add_series("The number of extensions", values) return chart
def create_chart_file_size_dict(file_size_dict): file_size_dict = dict( sorted(file_size_dict.items(), key=lambda item: item[1])) labels = list(file_size_dict.keys()) values = list(file_size_dict.values()) chart = Bar( "The chart for the distribution of file sizes of each extension") chart.set_options(labels=labels, x_label="Extensions", y_label="Sum of file sizes", colors=['#1EAFAE' for _ in range(len(labels))]) chart.add_series("The Sum of sizes", values) return chart
def create_chart(labels: list, values: list): chart = Bar("Food comparison") chart.set_options(labels=labels, x_label="Food", y_label="Delicious level") chart.add_series("Delicious level", values) return chart
def bar_base() -> Bar: chart = Bar("Bar-基本示例") chart.set_options(labels=Faker.choose(), x_label="I'm xlabel", y_label="I'm ylabel") chart.add_series("series-A", Faker.values()) return chart
def bar_tickcount_colors(): chart = Bar("Bar-调整颜色") chart.set_options(labels=Faker.choose(), y_tick_count=10, colors=Faker.colors) chart.add_series("series-A", Faker.values()) return chart