def pie_base() -> Pie: chart = Pie("Pie-基本示例") chart.set_options(labels=Faker.choose()) chart.add_series(Faker.values()) return chart pie_base().render()
def pie_legend_font(): chart = Pie("Pie-Legend", width="100%") chart.set_options( labels=Faker.choose(), legend_pos="upRight", font_family='"Times New Roman",Georgia,Serif;', ) chart.add_series(Faker.values()) return chart
def create_chart_dir_files(dictionary_of_dir_files): labels = list(dictionary_of_dir_files.keys()) values = list(dictionary_of_dir_files.values()) chart = Pie("The chart for the number of directories and files") chart.set_options(labels=labels, inner_radius=0, colors=['#FFE07F', '#5AD2EC']) chart.add_series(values) return chart
def gen_pie_base() -> Pie: c = Pie("Pie") c.set_options(labels=["A", "B"]) c.add_series(["1", "2"]) return c
def drawPie(title, data, savedir='results'): checkDir(savedir) chart = Pie(title) chart.set_options(labels=list(data.keys())) chart.add_series(list(data.values())) chart.render(os.path.join(savedir, title+'.html'))
def pie_base() -> Pie: chart = Pie("Pie-基本示例", width="100%") chart.set_options(labels=Faker.choose()) chart.add_series(Faker.values()) return chart
def pie_radius(): chart = Pie("Pie-Radius", width="100%") chart.set_options(labels=Faker.choose(), inner_radius=0) chart.add_series(Faker.values()) return chart
def pie_base(): chart = Pie("Pie-基本示例", width="100%") chart.set_options( labels=["小米", "三星", "华为", "苹果", "魅族", "VIVO", "OPPO"]) chart.add_series([25, 87, 114, 131, 130, 94, 146]) return put_html(chart.render_notebook())
#from cutecharts.globals import use_jupyter_lab; use_jupyter_lab() - if using JupyterLab from cutecharts.charts import Pie import imageio chart = Pie('Biscoito ou Bolacha (%)', width='500px', height='600px') chart.set_options(labels=list(['Bolacha', 'Biscoito', 'Tanto faz']), inner_radius=0, colors=["#ff774a", "#20a483", "#918f8e"], legend_pos='upRight', font_family='monospace') chart.add_series(list([71.4, 14.3, 14.3])) #chart.load_javascript() - if using JupyterLab #chart.render_notebook() - if using JupyterLab chart.render() #save each interactive state of the chart as picture using screencapture or selenium package. #we used screeshots since we only had 3 states in the pie: cute_charts_{picture_number}.png cute_frames = [] for number in range(3): for i in range(10): cute_frames.append(f'cute_charts_{number + 1}.png') with imageio.get_writer('biscoito_bolacha.gif', mode='I') as writer: for frame_name in cute_frames: image = imageio.imread(frame_name) writer.append_data(image)