def partition_analysis(partition_name): dictionary_of_dir_files = {} extensions = set() extension_dict = {} file_size_dict = {} number_of_files = 0 number_of_directories = 0 for (root, directories, files) in os.walk(partition_name): number_of_directories, number_of_files = number_of_elements( number_of_directories, directories, number_of_files, files) dictionary_of_dir_files = { 'directories': number_of_directories, 'files': number_of_files } for file_name in files: extension = (os.path.splitext(file_name)[1][1:]).lower() extensions, extension_dict = get_extensions( extension, extensions, extension_dict) full_path = os.path.abspath(os.path.join(root, file_name)) file_size_dict = get_file_sizes(full_path, extension, file_size_dict) print_number_of_elements(dictionary_of_dir_files) print_extensions_info(extensions, extension_dict) print_file_sizes_info(file_size_dict) page = Page() page.add(create_chart_dir_files(dictionary_of_dir_files), create_chart_extension_dict(extension_dict), create_chart_file_size_dict(file_size_dict)) page.render()
def test_page_iter(): charts = [gen_bar_base(), gen_line_base()] p = Page() p.add(*charts) for idx, c in enumerate(p): assert_equal(c, charts[idx]) assert_equal(len(p), len(charts))
def test_page_before_render(): charts = [gen_bar_base(), gen_line_base()] p = Page() p.add(*charts) assert_false(hasattr(p, "local_cfg")) assert_false(hasattr(p, "notebook_cfg")) p.before_render() assert_true(hasattr(p, "local_cfg")) assert_true(hasattr(p, "notebook_cfg"))
scatter_base().render() def scatter_dotsize_tickcount(): chart = Scatter("Scatter-散点大小") chart.set_options(dot_size=2, y_tick_count=8) chart.add_series("series-A", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]) chart.add_series("series-B", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]) return chart def scatter_show_line(): chart = Scatter("Scatter-散点连成线") chart.set_options(y_tick_count=8, is_show_line=True) chart.add_series("series-A", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]) chart.add_series("series-B", [(z[0], z[1]) for z in zip(Faker.values(), Faker.values())]) return chart page = Page() page.add(scatter_base(), scatter_dotsize_tickcount(), scatter_show_line()) page.render()
def main(): page = Page() page.add(scatter_base(), scatter_dotsize_tickcount(), scatter_show_line()) put_html(page.render_notebook())
from cutecharts.components import Page from example.example_bar import bar_base from example.example_line import line_base from example.example_pie import pie_base from example.example_radar import radar_base from example.example_scatter import scatter_base page = Page() page.add(bar_base(), line_base(), pie_base(), radar_base(), scatter_base()) page.render()
from cutecharts.charts import Bar from cutecharts.components import Page from cutecharts.faker import Faker 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 bar_base().render() 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 page = Page() page.add(bar_base(), bar_tickcount_colors()) page.render()
def main(): page = Page() page.add(bar_base(), bar_tickcount_colors()) put_html(page.render_notebook())
def main(): page = Page() page.add(radar_base(), radar_legend_colors()) put_html(page.render_notebook())
def main(): page = Page() page.add(pie_base(), pie_legend_font(), pie_radius()) put_html(page.render_notebook())
from cutecharts.charts import Radar from cutecharts.components import Page from cutecharts.faker import Faker def radar_base() -> Radar: chart = Radar("Radar-基本示例") chart.set_options(labels=Faker.choose()) chart.add_series("series-A", Faker.values()) chart.add_series("series-B", Faker.values()) return chart radar_base().render() def radar_legend_colors(): chart = Radar("Radar-颜色调整") chart.set_options(labels=Faker.choose(), colors=Faker.colors, legend_pos="upRight") chart.add_series("series-A", Faker.values()) chart.add_series("series-B", Faker.values()) return chart page = Page() page.add(radar_base(), radar_legend_colors()) page.render()
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") chart.set_options( labels=Faker.choose(), legend_pos="upRight", font_family='"Times New Roman",Georgia,Serif;', ) chart.add_series(Faker.values()) return chart def pie_radius(): chart = Pie("Pie-Radius") chart.set_options(labels=Faker.choose(), inner_radius=0) chart.add_series(Faker.values()) return chart page = Page() page.add(pie_base(), pie_legend_font(), pie_radius()) page.render()
def main(): page = Page() page.add(bar_base(), line_base(), pie_base(), radar_base(), scatter_base()) put_html(page.render_notebook())
def main(): page = Page() page.add(line_base(), line_legend(), line_tickcount_colors()) put_html(page.render_notebook())
y_label="I'm ylabel") chart.add_series("series-A", Faker.values()) chart.add_series("series-B", Faker.values()) return chart line_base().render() def line_legend(): chart = Line("Line-Legend 位置") chart.set_options(labels=Faker.choose(), legend_pos="upRight") chart.add_series("series-A", Faker.values()) chart.add_series("series-B", Faker.values()) return chart def line_tickcount_colors(): chart = Line("Line-调整颜色") chart.set_options(labels=Faker.choose(), colors=Faker.colors, y_tick_count=8) chart.add_series("series-A", Faker.values()) chart.add_series("series-B", Faker.values()) return chart page = Page() page.add(line_base(), line_legend(), line_tickcount_colors()) page.render()