diff --git a/.github/workflows/trigger-benchmark.yml b/.github/workflows/trigger-benchmark.yml index a69cd5ca38..1070634172 100644 --- a/.github/workflows/trigger-benchmark.yml +++ b/.github/workflows/trigger-benchmark.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Trigger taipy-benchmark computation - uses: peter-evans/repository-dispatch@v1 + uses: peter-evans/repository-dispatch@v3 with: token: ${{secrets.TAIPY_INTEGRATION_TESTING_ACCESS_TOKEN}} repository: avaiga/taipy-benchmark diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a4899cb020..e7cc30920d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,10 +12,10 @@ For questions, please get in touch on [Discord](https://discord.com/invite/SJyz2 Taipy is organised in two main repositories: -- [taipy](https://github.com/Avaiga/taipy) is the main repository that containing the code of Taipy packages. +- [taipy](https://github.com/Avaiga/taipy) is the main repository that contains the code of Taipy packages. - [taipy-doc](https://github.com/Avaiga/taipy-doc) is the documentation repository. -## Never contributed on an open source project before ? +## Never contributed to an open source project before ? Have a look on this [GitHub documentation](https://docs.github.com/en/get-started/quickstart/contributing-to-projects). diff --git a/README.md b/README.md index 1fa1d9b655..24a8ce8a23 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ - -![Hactoberfestnew](https://github.com/user-attachments/assets/149a5cee-6af1-4d4e-9c43-6fcf82a9b07e) +[![Hacktoberfest_clickable](https://github.com/user-attachments/assets/b1b5a430-6df9-40c2-999f-de3433f61251)](https://assorted-son-815.notion.site/Hacktoberfest-2024-with-Taipy-2a5032a3f01642709e88ffaa5d0d169e)
diff --git a/doc/gui/examples/blocks/pane_anchor/__init__.py b/doc/gui/examples/blocks/pane_anchor/__init__.py index e02b81801b..916df4920e 100644 --- a/doc/gui/examples/blocks/pane_anchor/__init__.py +++ b/doc/gui/examples/blocks/pane_anchor/__init__.py @@ -1 +1 @@ -# This file makes this directory a module on its own, mandatody for mypy. +# This file makes this directory a module on its own, mandatory for mypy. diff --git a/doc/gui/examples/blocks/pane_anchor/builder.py b/doc/gui/examples/blocks/pane_anchor/builder.py index 0b15146451..ba29698d92 100644 --- a/doc/gui/examples/blocks/pane_anchor/builder.py +++ b/doc/gui/examples/blocks/pane_anchor/builder.py @@ -28,4 +28,4 @@ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Anchor") diff --git a/doc/gui/examples/blocks/pane_anchor/markdown.py b/doc/gui/examples/blocks/pane_anchor/markdown.py index 3e9c781f46..e9bb4147a7 100644 --- a/doc/gui/examples/blocks/pane_anchor/markdown.py +++ b/doc/gui/examples/blocks/pane_anchor/markdown.py @@ -28,4 +28,4 @@ """ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Anchor") diff --git a/doc/gui/examples/blocks/pane_as_page/__init__.py b/doc/gui/examples/blocks/pane_as_page/__init__.py index e02b81801b..916df4920e 100644 --- a/doc/gui/examples/blocks/pane_as_page/__init__.py +++ b/doc/gui/examples/blocks/pane_as_page/__init__.py @@ -1 +1 @@ -# This file makes this directory a module on its own, mandatody for mypy. +# This file makes this directory a module on its own, mandatory for mypy. diff --git a/doc/gui/examples/blocks/pane_as_page/builder.py b/doc/gui/examples/blocks/pane_as_page/builder.py index 58a8c8fc28..911283975b 100644 --- a/doc/gui/examples/blocks/pane_as_page/builder.py +++ b/doc/gui/examples/blocks/pane_as_page/builder.py @@ -53,9 +53,10 @@ def on_change(state, var_name: str): state.final_amount = state.initial_investment * progress +pages = { + "main": page, + "_rate_pane": rate_page, +} + if __name__ == "__main__": - pages = { - "main": page, - "_rate_pane": rate_page, - } - Gui(pages=pages).run() + Gui(pages=pages).run(title="Pane - As page") diff --git a/doc/gui/examples/blocks/pane_as_page/markdown.py b/doc/gui/examples/blocks/pane_as_page/markdown.py index 61c0f16084..2f85dfc123 100644 --- a/doc/gui/examples/blocks/pane_as_page/markdown.py +++ b/doc/gui/examples/blocks/pane_as_page/markdown.py @@ -50,9 +50,11 @@ def on_change(state, var_name: str): state.final_amount = state.initial_investment * progress +pages = { + "main": page, + "_rate_pane": rate_page, +} + + if __name__ == "__main__": - pages = { - "main": page, - "_rate_pane": rate_page, - } - Gui(pages=pages).run() + Gui(pages=pages).run(title="Pane - As page") diff --git a/doc/gui/examples/blocks/pane_persistent/__init__.py b/doc/gui/examples/blocks/pane_persistent/__init__.py index e02b81801b..916df4920e 100644 --- a/doc/gui/examples/blocks/pane_persistent/__init__.py +++ b/doc/gui/examples/blocks/pane_persistent/__init__.py @@ -1 +1 @@ -# This file makes this directory a module on its own, mandatody for mypy. +# This file makes this directory a module on its own, mandatory for mypy. diff --git a/doc/gui/examples/blocks/pane_persistent/builder.py b/doc/gui/examples/blocks/pane_persistent/builder.py index 69b576e1b5..4878ffb9e6 100644 --- a/doc/gui/examples/blocks/pane_persistent/builder.py +++ b/doc/gui/examples/blocks/pane_persistent/builder.py @@ -27,4 +27,4 @@ tgb.text("Here is the content of the page.") if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Persistent") diff --git a/doc/gui/examples/blocks/pane_persistent/markdown.py b/doc/gui/examples/blocks/pane_persistent/markdown.py index 06ef6b9469..d87708f1d1 100644 --- a/doc/gui/examples/blocks/pane_persistent/markdown.py +++ b/doc/gui/examples/blocks/pane_persistent/markdown.py @@ -30,4 +30,4 @@ """ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Persistent") diff --git a/doc/gui/examples/blocks/pane_simple/__init__.py b/doc/gui/examples/blocks/pane_simple/__init__.py index e02b81801b..916df4920e 100644 --- a/doc/gui/examples/blocks/pane_simple/__init__.py +++ b/doc/gui/examples/blocks/pane_simple/__init__.py @@ -1 +1 @@ -# This file makes this directory a module on its own, mandatody for mypy. +# This file makes this directory a module on its own, mandatory for mypy. diff --git a/doc/gui/examples/blocks/pane_simple/builder.py b/doc/gui/examples/blocks/pane_simple/builder.py index 5d477bff64..3f466f7cb7 100644 --- a/doc/gui/examples/blocks/pane_simple/builder.py +++ b/doc/gui/examples/blocks/pane_simple/builder.py @@ -35,4 +35,4 @@ def on_action(state): tgb.button("Show pane") if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Simple") diff --git a/doc/gui/examples/blocks/pane_simple/markdown.py b/doc/gui/examples/blocks/pane_simple/markdown.py index c4be96e51b..1b58db1298 100644 --- a/doc/gui/examples/blocks/pane_simple/markdown.py +++ b/doc/gui/examples/blocks/pane_simple/markdown.py @@ -36,4 +36,4 @@ def on_action(state): """ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Simple") diff --git a/doc/gui/examples/blocks/pane_simple_lambda/__init__.py b/doc/gui/examples/blocks/pane_simple_lambda/__init__.py index e02b81801b..916df4920e 100644 --- a/doc/gui/examples/blocks/pane_simple_lambda/__init__.py +++ b/doc/gui/examples/blocks/pane_simple_lambda/__init__.py @@ -1 +1 @@ -# This file makes this directory a module on its own, mandatody for mypy. +# This file makes this directory a module on its own, mandatory for mypy. diff --git a/doc/gui/examples/blocks/pane_simple_lambda/builder.py b/doc/gui/examples/blocks/pane_simple_lambda/builder.py index 5760edc57d..e503040745 100644 --- a/doc/gui/examples/blocks/pane_simple_lambda/builder.py +++ b/doc/gui/examples/blocks/pane_simple_lambda/builder.py @@ -29,4 +29,4 @@ tgb.button("Show pane", on_action=lambda s: s.assign("show_pane", True)) if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Lambda") diff --git a/doc/gui/examples/blocks/pane_simple_lambda/markdown.py b/doc/gui/examples/blocks/pane_simple_lambda/markdown.py index b2df9b66b6..b7ec17935a 100644 --- a/doc/gui/examples/blocks/pane_simple_lambda/markdown.py +++ b/doc/gui/examples/blocks/pane_simple_lambda/markdown.py @@ -30,4 +30,4 @@ """ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Pane - Lambda") diff --git a/doc/gui/examples/broadcast.py b/doc/gui/examples/broadcast.py index 71906cad3e..bfc05460c9 100644 --- a/doc/gui/examples/broadcast.py +++ b/doc/gui/examples/broadcast.py @@ -54,21 +54,19 @@ def start_or_stop(state: State): state.assign("button_text", button_texts[1 if thread else 0]) -if __name__ == "__main__": - button_texts = ["Start", "Stop"] - # Text in the start/stop button (initially "Start") - button_text = button_texts[0] - - page = """ -# Broadcasting values +button_texts = ["Start", "Stop"] +# Text in the start/stop button (initially "Start") +button_text = button_texts[0] +page = """ Counter: <|{counter}|> Timer: <|{button_text}|button|on_action=start_or_stop|> - """ +""" +if __name__ == "__main__": # Declare "button_text" as a shared variable. # Assigning a value to a state's 'button_text' property is propagated to all clients Gui.add_shared_variable("button_text") - Gui(page).run() + Gui(page).run(title="Broadcasting values") diff --git a/doc/gui/examples/broadcast_callback.py b/doc/gui/examples/broadcast_callback.py index ef9aab481d..d375d87808 100644 --- a/doc/gui/examples/broadcast_callback.py +++ b/doc/gui/examples/broadcast_callback.py @@ -38,16 +38,16 @@ def update_time(gui): sleep(1) -if __name__ == "__main__": - current_time = datetime.now() - update = False +current_time = datetime.now() +update = False - page = """ +page = """ Current time is: <|{current_time}|format=HH:mm:ss|> Update: <|{update}|toggle|> - """ +""" +if __name__ == "__main__": gui = Gui(page) # Run thread that regularly updates the current time @@ -55,4 +55,4 @@ def update_time(gui): thread.daemon = True thread.start() - gui.run() + gui.run(title="Broadcast - Callback") diff --git a/doc/gui/examples/broadcast_change.py b/doc/gui/examples/broadcast_change.py index 56c70e3f2c..c62a71742b 100644 --- a/doc/gui/examples/broadcast_change.py +++ b/doc/gui/examples/broadcast_change.py @@ -32,13 +32,13 @@ def update_time(gui): sleep(1) -if __name__ == "__main__": - current_time = datetime.now() +current_time = datetime.now() - page = """ +page = """ Current time is: <|{current_time}|format=HH:mm:ss|> - """ +""" +if __name__ == "__main__": gui = Gui(page) # Run thread that regularly updates the current time @@ -46,4 +46,4 @@ def update_time(gui): thread.daemon = True thread.start() - gui.run() + gui.run(title="Broadcast - Change") diff --git a/doc/gui/examples/charts/advanced-selection.py b/doc/gui/examples/charts/advanced-selection.py index 385ad83a76..e6b09a0c0a 100644 --- a/doc/gui/examples/charts/advanced-selection.py +++ b/doc/gui/examples/charts/advanced-selection.py @@ -53,11 +53,9 @@ def on_change(state, var, val): mean_value = 0.0 page = """ -# Advanced - Selection - ## Mean of <|{len(selected_indices)}|raw|> selected points: <|{mean_value}|format=%.2f|raw|> <|{data}|chart|selected={selected_indices}|layout={layout}|plot_config={config}|> """ - Gui(page).run() + Gui(page).run(title="Chart - Advanced - Selection") diff --git a/doc/gui/examples/charts/advanced-shapes.py b/doc/gui/examples/charts/advanced-shapes.py index 765bdc583e..b96780f4c3 100644 --- a/doc/gui/examples/charts/advanced-shapes.py +++ b/doc/gui/examples/charts/advanced-shapes.py @@ -21,45 +21,44 @@ def f(x): return x * x * x / 3 - x -if __name__ == "__main__": - # x values: [-2.2, ..., 2.2] - x = [(x - 10) / 4.5 for x in range(0, 21)] - - data = { - "x": x, - # y: [f(-2.2), ..., f(2.2)] - "y": [f(x) for x in x], - } +# x values: [-2.2, ..., 2.2] +x = [(x - 10) / 4.5 for x in range(0, 21)] - shape_size = 0.1 +data = { + "x": x, + # y: [f(-2.2), ..., f(2.2)] + "y": [f(x) for x in x], +} - layout = { - "shapes": [ - # Shape for local maximum (x = -1) - { - "x0": -1 - shape_size, - "y0": f(-1) - 2 * shape_size, - "x1": -1 + shape_size, - "y1": f(-1) + 2 * shape_size, - "fillcolor": "green", - "opacity": 0.5, - }, - # Shape for local minimum (x = 1) - { - "x0": 1 - shape_size, - "y0": f(1) - 2 * shape_size, - "x1": 1 + shape_size, - "y1": f(1) + 2 * shape_size, - "fillcolor": "red", - "opacity": 0.5, - }, - ] - } +shape_size = 0.1 - page = """ -# Advanced - Annotations +layout = { + "shapes": [ + # Shape for local maximum (x = -1) + { + "x0": -1 - shape_size, + "y0": f(-1) - 2 * shape_size, + "x1": -1 + shape_size, + "y1": f(-1) + 2 * shape_size, + "fillcolor": "green", + "opacity": 0.5, + }, + # Shape for local minimum (x = 1) + { + "x0": 1 - shape_size, + "y0": f(1) - 2 * shape_size, + "x1": 1 + shape_size, + "y1": f(1) + 2 * shape_size, + "fillcolor": "red", + "opacity": 0.5, + }, + ] +} +page = """ <|{data}|chart|layout={layout}|> - """ +""" - Gui(page).run() + +if __name__ == "__main__": + Gui(page).run(title="Chart - Advanced - Annotations") diff --git a/doc/gui/examples/charts/advanced-unbalanced-datasets.py b/doc/gui/examples/charts/advanced-unbalanced-datasets.py index 18f79495a4..65b835b58c 100644 --- a/doc/gui/examples/charts/advanced-unbalanced-datasets.py +++ b/doc/gui/examples/charts/advanced-unbalanced-datasets.py @@ -15,27 +15,25 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # The first data set uses the x interval [-10..10], - # with one point at every other unit - x1_range = [x * 2 for x in range(-5, 6)] - - # The second data set uses the x interval [-4..4], - # with ten point between every unit - x2_range = [x / 10 for x in range(-40, 41)] +# The first data set uses the x interval [-10..10], +# with one point at every other unit +x1_range = [x * 2 for x in range(-5, 6)] - # Definition of the two data sets - data = [ - # Coarse data set - {"x": x1_range, "Coarse": [x * x for x in x1_range]}, - # Fine data set - {"x": x2_range, "Fine": [x * x for x in x2_range]}, - ] +# The second data set uses the x interval [-4..4], +# with ten point between every unit +x2_range = [x / 10 for x in range(-40, 41)] - page = """ -# Advanced - Unbalanced data sets +# Definition of the two data sets +data = [ + # Coarse data set + {"x": x1_range, "Coarse": [x * x for x in x1_range]}, + # Fine data set + {"x": x2_range, "Fine": [x * x for x in x2_range]}, +] +page = """ <|{data}|chart|x[1]=0/x|y[1]=0/Coarse|x[2]=1/x|y[2]=1/Fine|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Advanced - Unbalanced data sets") diff --git a/doc/gui/examples/charts/advanced_annotations.py b/doc/gui/examples/charts/advanced_annotations.py index 28ade723b2..47bda391ad 100644 --- a/doc/gui/examples/charts/advanced_annotations.py +++ b/doc/gui/examples/charts/advanced_annotations.py @@ -42,10 +42,8 @@ def f(x): } page = """ -# Advanced - Annotations - <|{data}|chart|layout={layout}|> """ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Chart - Advanced - Annotations") diff --git a/doc/gui/examples/charts/advanced_python_lib.py b/doc/gui/examples/charts/advanced_python_lib.py index f3c5763c5b..e91804dc28 100644 --- a/doc/gui/examples/charts/advanced_python_lib.py +++ b/doc/gui/examples/charts/advanced_python_lib.py @@ -48,4 +48,4 @@ if __name__ == "__main__": - Gui(page).run() + Gui(page).run(title="Chart - Advanced - Python lib") diff --git a/doc/gui/examples/charts/bar-facing.py b/doc/gui/examples/charts/bar-facing.py index 9df35f95b0..35bff0fa86 100644 --- a/doc/gui/examples/charts/bar-facing.py +++ b/doc/gui/examples/charts/bar-facing.py @@ -18,69 +18,67 @@ from taipy.gui import Gui -if __name__ == "__main__": - n_years = 10 - - proportions_female = numpy.zeros(n_years) - proportions_male = numpy.zeros(n_years) +n_years = 10 - # Prepare the data set with random variations - proportions_female[0] = 0.4 - proportions_male[0] = proportions_female[0] * (1 + numpy.random.normal(0, 0.1)) +proportions_female = numpy.zeros(n_years) +proportions_male = numpy.zeros(n_years) - for i in range(1, n_years): - mean_i = (0.5 - proportions_female[i - 1]) / 5 - new_value = proportions_female[i - 1] + numpy.random.normal(mean_i, 0.1) +# Prepare the data set with random variations +proportions_female[0] = 0.4 +proportions_male[0] = proportions_female[0] * (1 + numpy.random.normal(0, 0.1)) - new_value = min(max(0, new_value), 1) - proportions_female[i] = new_value - proportions_male[i] = proportions_female[i] * (1 + numpy.random.normal(0, 0.1)) +for i in range(1, n_years): + mean_i = (0.5 - proportions_female[i - 1]) / 5 + new_value = proportions_female[i - 1] + numpy.random.normal(mean_i, 0.1) - data = { - "Hobbies": [ - "Archery", - "Tennis", - "Football", - "Basket", - "Volley", - "Golf", - "Video-Games", - "Reading", - "Singing", - "Music", - ], - "Female": proportions_female, - # Negate these values so they appear to the left side - "Male": -proportions_male, - } + new_value = min(max(0, new_value), 1) + proportions_female[i] = new_value + proportions_male[i] = proportions_female[i] * (1 + numpy.random.normal(0, 0.1)) - properties = { - # Shared y values - "y": "Hobbies", - # Bars for the female data set - "x[1]": "Female", - "color[1]": "#c26391", - # Bars for the male data set - "x[2]": "Male", - "color[2]": "#5c91de", - # Both data sets are represented with an horizontal orientation - "orientation": "h", - # - "layout": { - # This makes left and right bars aligned on the same y value - "barmode": "overlay", - # Set a relevant title for the x axis - "xaxis": {"title": "Gender"}, - # Hide the legend - "showlegend": False, - "margin": {"l": 100}, - }, - } +data = { + "Hobbies": [ + "Archery", + "Tennis", + "Football", + "Basket", + "Volley", + "Golf", + "Video-Games", + "Reading", + "Singing", + "Music", + ], + "Female": proportions_female, + # Negate these values so they appear to the left side + "Male": -proportions_male, +} - page = """ -# Bar - Facing +properties = { + # Shared y values + "y": "Hobbies", + # Bars for the female data set + "x[1]": "Female", + "color[1]": "#c26391", + # Bars for the male data set + "x[2]": "Male", + "color[2]": "#5c91de", + # Both data sets are represented with an horizontal orientation + "orientation": "h", + # + "layout": { + # This makes left and right bars aligned on the same y value + "barmode": "overlay", + # Set a relevant title for the x axis + "xaxis": {"title": "Gender"}, + # Hide the legend + "showlegend": False, + "margin": {"l": 100}, + }, +} +page = """ <|{data}|chart|type=bar|properties={properties}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bar facing") diff --git a/doc/gui/examples/charts/bar-multiple.py b/doc/gui/examples/charts/bar-multiple.py index eb4f52a2fd..5dddf7a883 100644 --- a/doc/gui/examples/charts/bar-multiple.py +++ b/doc/gui/examples/charts/bar-multiple.py @@ -18,38 +18,36 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin - percentages = [ - (1852, 50.83), - (1856, 45.29), - (1860, 39.65), - (1864, 55.03), - (1868, 52.66), - (1872, 55.58), - (1876, 47.92), - (1880, 48.31), - (1884, 48.85), - (1888, 47.80), - (1892, 46.02), - (1896.0, 51.02), - (1900, 51.64), - (1904, 56.42), - (1908, 51.57), - (1912, 41.84), - (1916, 49.24), - (1920, 60.32), - (1924, 54.04), - (1928, 58.21), - ] - data = pandas.DataFrame(percentages, columns=["Year", "Won"]) - lost = [100 - t[1] for t in percentages] - data["Lost"] = lost - - page = """ -# Bar - Multiple +# Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin +percentages = [ + (1852, 50.83), + (1856, 45.29), + (1860, 39.65), + (1864, 55.03), + (1868, 52.66), + (1872, 55.58), + (1876, 47.92), + (1880, 48.31), + (1884, 48.85), + (1888, 47.80), + (1892, 46.02), + (1896.0, 51.02), + (1900, 51.64), + (1904, 56.42), + (1908, 51.57), + (1912, 41.84), + (1916, 49.24), + (1920, 60.32), + (1924, 54.04), + (1928, 58.21), +] +data = pandas.DataFrame(percentages, columns=["Year", "Won"]) +lost = [100 - t[1] for t in percentages] +data["Lost"] = lost +page = """ <|{data}|chart|type=bar|x=Year|y[1]=Won|y[2]=Lost|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bar multiple") diff --git a/doc/gui/examples/charts/bar-simple.py b/doc/gui/examples/charts/bar-simple.py index 7cae01ea04..1c59e653a6 100644 --- a/doc/gui/examples/charts/bar-simple.py +++ b/doc/gui/examples/charts/bar-simple.py @@ -17,59 +17,57 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin - percentages = [ - (1852, 50.83), - (1856, 45.29), - (1860, 39.65), - (1864, 55.03), - (1868, 52.66), - (1872, 55.58), - (1876, 47.92), - (1880, 48.31), - (1884, 48.85), - (1888, 47.80), - (1892, 46.02), - (1896.0, 51.02), - (1900, 51.64), - (1904, 56.42), - (1908, 51.57), - (1912, 41.84), - (1916, 49.24), - (1920, 60.32), - (1924, 54.04), - (1928, 58.21), - (1932, 57.41), - (1936, 60.80), - (1940, 54.74), - (1944, 53.39), - (1948, 49.55), - (1952, 55.18), - (1956, 57.37), - (1960, 49.72), - (1964, 61.05), - (1968, 43.42), - (1972, 60.67), - (1976, 50.08), - (1980, 50.75), - (1984, 58.77), - (1988, 53.37), - (1992, 43.01), - (1996, 49.23), - (2000, 47.87), - (2004, 50.73), - (2008, 52.93), - (2012, 51.06), - (2016, 46.09), - (2020, 51.31), - ] - data = pandas.DataFrame(percentages, columns=["Year", "%"]) - - page = """ -# Bar - Simple +# Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin +percentages = [ + (1852, 50.83), + (1856, 45.29), + (1860, 39.65), + (1864, 55.03), + (1868, 52.66), + (1872, 55.58), + (1876, 47.92), + (1880, 48.31), + (1884, 48.85), + (1888, 47.80), + (1892, 46.02), + (1896.0, 51.02), + (1900, 51.64), + (1904, 56.42), + (1908, 51.57), + (1912, 41.84), + (1916, 49.24), + (1920, 60.32), + (1924, 54.04), + (1928, 58.21), + (1932, 57.41), + (1936, 60.80), + (1940, 54.74), + (1944, 53.39), + (1948, 49.55), + (1952, 55.18), + (1956, 57.37), + (1960, 49.72), + (1964, 61.05), + (1968, 43.42), + (1972, 60.67), + (1976, 50.08), + (1980, 50.75), + (1984, 58.77), + (1988, 53.37), + (1992, 43.01), + (1996, 49.23), + (2000, 47.87), + (2004, 50.73), + (2008, 52.93), + (2012, 51.06), + (2016, 46.09), + (2020, 51.31), +] +data = pandas.DataFrame(percentages, columns=["Year", "%"]) +page = """ <|{data}|chart|type=bar|x=Year|y=%|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bar simple") diff --git a/doc/gui/examples/charts/bar-stacked.py b/doc/gui/examples/charts/bar-stacked.py index 7c45f67ac8..86e9e4772a 100644 --- a/doc/gui/examples/charts/bar-stacked.py +++ b/doc/gui/examples/charts/bar-stacked.py @@ -17,42 +17,40 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin - percentages = [ - (1852, 50.83), - (1856, 45.29), - (1860, 39.65), - (1864, 55.03), - (1868, 52.66), - (1872, 55.58), - (1876, 47.92), - (1880, 48.31), - (1884, 48.85), - (1888, 47.80), - (1892, 46.02), - (1896.0, 51.02), - (1900, 51.64), - (1904, 56.42), - (1908, 51.57), - (1912, 41.84), - (1916, 49.24), - (1920, 60.32), - (1924, 54.04), - (1928, 58.21), - ] - - # Lost percentage = 100-Won percentage - full = [(t[0], t[1], 100 - t[1]) for t in percentages] - - data = pandas.DataFrame(full, columns=["Year", "Won", "Lost"]) - - layout = {"barmode": "stack"} - - page = """ -# Bar - Stacked - +# Source https://en.wikipedia.org/wiki/List_of_United_States_presidential_elections_by_popular_vote_margin +percentages = [ + (1852, 50.83), + (1856, 45.29), + (1860, 39.65), + (1864, 55.03), + (1868, 52.66), + (1872, 55.58), + (1876, 47.92), + (1880, 48.31), + (1884, 48.85), + (1888, 47.80), + (1892, 46.02), + (1896.0, 51.02), + (1900, 51.64), + (1904, 56.42), + (1908, 51.57), + (1912, 41.84), + (1916, 49.24), + (1920, 60.32), + (1924, 54.04), + (1928, 58.21), +] + +# Lost percentage = 100-Won percentage +full = [(t[0], t[1], 100 - t[1]) for t in percentages] + +data = pandas.DataFrame(full, columns=["Year", "Won", "Lost"]) + +layout = {"barmode": "stack"} + +page = """ <|{data}|chart|type=bar|x=Year|y[1]=Won|y[2]=Lost|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bar stacked") diff --git a/doc/gui/examples/charts/basics-multiple.py b/doc/gui/examples/charts/basics-multiple.py index 18435d429e..4613d25c5f 100644 --- a/doc/gui/examples/charts/basics-multiple.py +++ b/doc/gui/examples/charts/basics-multiple.py @@ -15,23 +15,21 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # x values are [-10..10] - x_range = range(-10, 11) - - # The data set holds the _x_ series and two distinct series for _y_ - data = { - "x": x_range, - # y1 = x*x - "y1": [x * x for x in x_range], - # y2 = 100-x*x - "y2": [100 - x * x for x in x_range], - } +# x values are [-10..10] +x_range = range(-10, 11) - page = """ -# Basics - Multiple traces +# The data set holds the _x_ series and two distinct series for _y_ +data = { + "x": x_range, + # y1 = x*x + "y1": [x * x for x in x_range], + # y2 = 100-x*x + "y2": [100 - x * x for x in x_range], +} +page = """ <|{data}|chart|x=x|y[1]=y1|y[2]=y2|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Multiple traces") diff --git a/doc/gui/examples/charts/basics-simple.py b/doc/gui/examples/charts/basics-simple.py index 52b4b28830..d1ee7c56d7 100644 --- a/doc/gui/examples/charts/basics-simple.py +++ b/doc/gui/examples/charts/basics-simple.py @@ -15,13 +15,11 @@ # ----------------------------------------------------------------------------------------- from taipy import Gui -if __name__ == "__main__": - # The chart control's data is defined as inline - # code. - page = """ -# Basics - Simple line - +# The chart control's data is defined as inline +# code. +page = """ <|{[x*x for x in range(0, 11)]}|chart|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Simple") diff --git a/doc/gui/examples/charts/basics-timeline.py b/doc/gui/examples/charts/basics-timeline.py index 10468259e0..42dfa0d357 100644 --- a/doc/gui/examples/charts/basics-timeline.py +++ b/doc/gui/examples/charts/basics-timeline.py @@ -18,17 +18,15 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Generate a random value for every hour on a given day - data = { - "Date": pandas.date_range("2023-01-04", periods=24, freq="H"), - "Value": pandas.Series(numpy.random.randn(24)), - } - - page = """ -# Basics - Timeline +# Generate a random value for every hour on a given day +data = { + "Date": pandas.date_range("2023-01-04", periods=24, freq="H"), + "Value": pandas.Series(numpy.random.randn(24)), +} +page = """ <|{data}|chart|x=Date|y=Value|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Timeline") diff --git a/doc/gui/examples/charts/basics-title.py b/doc/gui/examples/charts/basics-title.py index cb1af3ccdc..98b13b1289 100644 --- a/doc/gui/examples/charts/basics-title.py +++ b/doc/gui/examples/charts/basics-title.py @@ -15,18 +15,16 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - layout = { - "xaxis": { - # Force the title of the x axis - "title": "Values for x" - } +layout = { + "xaxis": { + # Force the title of the x axis + "title": "Values for x" } +} - page = """ -# Basics - Title - +page = """ <|{[x*x for x in range(0, 11)]}|chart|title=Plotting x squared|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Title") diff --git a/doc/gui/examples/charts/basics-two-y-axis.py b/doc/gui/examples/charts/basics-two-y-axis.py index 361c14c086..ca3badbf08 100644 --- a/doc/gui/examples/charts/basics-two-y-axis.py +++ b/doc/gui/examples/charts/basics-two-y-axis.py @@ -15,42 +15,40 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # x values are [-10..10] - x_range = range(-10, 11) - - # The data set holds the _x_ series and two distinct series for _y_ - data = { - "x": x_range, - # y1 = x*x - "y1": [x * x for x in x_range], - # y2 = 2-x*x/50 - "y2": [(100 - x * x) / 50 for x in x_range], - } +# x values are [-10..10] +x_range = range(-10, 11) - layout = { - "yaxis2": { - # Second axis overlays with the first y axis - "overlaying": "y", - # Place the second axis on the right - "side": "right", - # and give it a title - "title": "Second y axis", - }, - "legend": { - # Place the legend above chart - "yanchor": "bottom" - }, - } +# The data set holds the _x_ series and two distinct series for _y_ +data = { + "x": x_range, + # y1 = x*x + "y1": [x * x for x in x_range], + # y2 = 2-x*x/50 + "y2": [(100 - x * x) / 50 for x in x_range], +} - page = """ -# Basics - Multiple axis +layout = { + "yaxis2": { + # Second axis overlays with the first y axis + "overlaying": "y", + # Place the second axis on the right + "side": "right", + # and give it a title + "title": "Second y axis", + }, + "legend": { + # Place the legend above chart + "yanchor": "bottom" + }, +} +page = """ Shared axis: <|{data}|chart|x=x|y[1]=y1|y[2]=y2|height=300px|> With two axis: <|{data}|chart|x=x|y[1]=y1|y[2]=y2|yaxis[2]=y2|layout={layout}|height=300px|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Multiple axis") diff --git a/doc/gui/examples/charts/basics-xrange.py b/doc/gui/examples/charts/basics-xrange.py index bc8e2b325c..fe41dec61a 100644 --- a/doc/gui/examples/charts/basics-xrange.py +++ b/doc/gui/examples/charts/basics-xrange.py @@ -15,17 +15,15 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # x values are [-10..10] - x_range = range(-10, 11) - - # The data set that holds both the x and the y values - data = {"X": x_range, "Y": [x * x for x in x_range]} +# x values are [-10..10] +x_range = range(-10, 11) - page = """ -# Basics - X range +# The data set that holds both the x and the y values +data = {"X": x_range, "Y": [x * x for x in x_range]} +page = """ <|{data}|chart|x=X|y=Y|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - X range") diff --git a/doc/gui/examples/charts/bubble-hover.py b/doc/gui/examples/charts/bubble-hover.py index 74424f5e76..978bcd04ca 100644 --- a/doc/gui/examples/charts/bubble-hover.py +++ b/doc/gui/examples/charts/bubble-hover.py @@ -15,25 +15,23 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "x": [1, 2, 3], - "y": [1, 2, 3], - "Texts": ["Blue
Small", "Green
Medium", "Red
Large"], - "Sizes": [60, 80, 100], - "Colors": [ - "rgb(93, 164, 214)", - "rgb(44, 160, 101)", - "rgb(255, 65, 54)", - ], - } - - marker = {"size": "Sizes", "color": "Colors"} +data = { + "x": [1, 2, 3], + "y": [1, 2, 3], + "Texts": ["Blue
Small", "Green
Medium", "Red
Large"], + "Sizes": [60, 80, 100], + "Colors": [ + "rgb(93, 164, 214)", + "rgb(44, 160, 101)", + "rgb(255, 65, 54)", + ], +} - page = """ -# Bubble - Hover text +marker = {"size": "Sizes", "color": "Colors"} +page = """ <|{data}|chart|mode=markers|x=x|y=y|marker={marker}|text=Texts|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bubble - Hover text") diff --git a/doc/gui/examples/charts/bubble-simple.py b/doc/gui/examples/charts/bubble-simple.py index f2bf56ee03..6fb4361f03 100644 --- a/doc/gui/examples/charts/bubble-simple.py +++ b/doc/gui/examples/charts/bubble-simple.py @@ -16,21 +16,19 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "x": [1, 2, 3], - "y": [1, 2, 3], - "Colors": ["blue", "green", "red"], - "Sizes": [20, 40, 30], - "Opacities": [1, 0.4, 1], - } - - marker = {"color": "Colors", "size": "Sizes", "opacity": "Opacities"} +data = { + "x": [1, 2, 3], + "y": [1, 2, 3], + "Colors": ["blue", "green", "red"], + "Sizes": [20, 40, 30], + "Opacities": [1, 0.4, 1], +} - page = """ -# Bubble - Simple +marker = {"color": "Colors", "size": "Sizes", "opacity": "Opacities"} +page = """ <|{data}|chart|mode=markers|x=x|y=y|marker={marker}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bubble - Simple") diff --git a/doc/gui/examples/charts/bubble-symbols.py b/doc/gui/examples/charts/bubble-symbols.py index abecf011ca..00cbf4a80a 100644 --- a/doc/gui/examples/charts/bubble-symbols.py +++ b/doc/gui/examples/charts/bubble-symbols.py @@ -16,24 +16,22 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "x": [1, 2, 3, 4, 5], - "y": [10, 7, 4, 1, 5], - "Sizes": [20, 30, 40, 50, 30], - "Symbols": ["circle-open", "triangle-up", "hexagram", "star-diamond", "circle-cross"], - } - - marker = { - "color": "#77A", - "size": "Sizes", - "symbol": "Symbols", - } +data = { + "x": [1, 2, 3, 4, 5], + "y": [10, 7, 4, 1, 5], + "Sizes": [20, 30, 40, 50, 30], + "Symbols": ["circle-open", "triangle-up", "hexagram", "star-diamond", "circle-cross"], +} - page = """ -# Bubble - Symbols +marker = { + "color": "#77A", + "size": "Sizes", + "symbol": "Symbols", +} +page = """ <|{data}|chart|mode=markers|x=x|y=y|marker={marker}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Bubble - Symbols") diff --git a/doc/gui/examples/charts/candlestick-simple.py b/doc/gui/examples/charts/candlestick-simple.py index 91b9cacdd1..3cf61aecba 100644 --- a/doc/gui/examples/charts/candlestick-simple.py +++ b/doc/gui/examples/charts/candlestick-simple.py @@ -18,19 +18,17 @@ from taipy import Gui -if __name__ == "__main__": - # Extraction of a month of stock data for AAPL using the - # yfinance package (see https://pypi.org/project/yfinance/). - ticker = yfinance.Ticker("AAPL") - # The returned value is a Pandas DataFrame. - stock = ticker.history(interval="1d", start="2018-08-01", end="2018-08-31") - # Copy the DataFrame's index to a new column - stock["Date"] = stock.index - - page = """ -# Candlestick - Simple +# Extraction of a month of stock data for AAPL using the +# yfinance package (see https://pypi.org/project/yfinance/). +ticker = yfinance.Ticker("AAPL") +# The returned value is a Pandas DataFrame. +stock = ticker.history(interval="1d", start="2018-08-01", end="2018-08-31") +# Copy the DataFrame's index to a new column +stock["Date"] = stock.index +page = """ <|{stock}|chart|type=candlestick|x=Date|open=Open|close=Close|low=Low|high=High|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Candlestick - Simple") diff --git a/doc/gui/examples/charts/candlestick-styling.py b/doc/gui/examples/charts/candlestick-styling.py index 58b2de578a..fb9540d3d4 100644 --- a/doc/gui/examples/charts/candlestick-styling.py +++ b/doc/gui/examples/charts/candlestick-styling.py @@ -18,33 +18,31 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Extraction of a few days of stock historical data for AAPL using - # the yfinance package (see https://pypi.org/project/yfinance/). - # The returned value is a Pandas DataFrame. - ticker = yfinance.Ticker("AAPL") - stock = ticker.history(interval="1d", start="2018-08-18", end="2018-09-10") - # Copy the DataFrame index to a new column - stock["Date"] = stock.index +# Extraction of a few days of stock historical data for AAPL using +# the yfinance package (see https://pypi.org/project/yfinance/). +# The returned value is a Pandas DataFrame. +ticker = yfinance.Ticker("AAPL") +stock = ticker.history(interval="1d", start="2018-08-18", end="2018-09-10") +# Copy the DataFrame index to a new column +stock["Date"] = stock.index - options = { - # Candlesticks that show decreasing values are orange - "decreasing": {"line": {"color": "orange"}}, - # Candlesticks that show decreasing values are blue - "increasing": {"line": {"color": "blue"}}, - } +options = { + # Candlesticks that show decreasing values are orange + "decreasing": {"line": {"color": "orange"}}, + # Candlesticks that show decreasing values are blue + "increasing": {"line": {"color": "blue"}}, +} - layout = { - "xaxis": { - # Hide the range slider - "rangeslider": {"visible": False} - } +layout = { + "xaxis": { + # Hide the range slider + "rangeslider": {"visible": False} } +} - page = """ -# Candlestick - Styling - +page = """ <|{stock}|chart|type=candlestick|x=Date|open=Open|close=Close|low=Low|high=High|options={options}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Candlestick - Styling") diff --git a/doc/gui/examples/charts/candlestick-timeseries.py b/doc/gui/examples/charts/candlestick-timeseries.py index 69f9f46990..66b3d35f9a 100644 --- a/doc/gui/examples/charts/candlestick-timeseries.py +++ b/doc/gui/examples/charts/candlestick-timeseries.py @@ -17,47 +17,45 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Retrieved history: - # (Open, Close, Low, High) - stock_history = [ - (311.05, 311.00, 310.75, 311.33), - (308.53, 308.31, 307.72, 309.00), - (307.35, 306.24, 306.12, 307.46), - (306.35, 304.90, 304.34, 310.10), - (304.90, 302.99, 302.27, 307.00), - (303.03, 301.66, 301.20, 303.25), - (301.61, 299.58, 299.50, 301.89), - (299.58, 297.95, 297.80, 300.06), - (297.95, 299.03, 297.14, 299.67), - (299.03, 301.87, 296.71, 301.89), - (301.89, 299.40, 298.73, 302.93), - (299.50, 299.35, 298.83, 299.50), - (299.35, 299.20, 299.19, 299.68), - (299.42, 300.50, 299.42, 300.50), - (300.70, 300.65, 300.32, 300.75), - (300.65, 299.91, 299.91, 300.76), - ] - start_date = datetime.datetime(year=2022, month=10, day=21) - period = datetime.timedelta(seconds=4 * 60 * 60) # 4 hours - - data = { - # Compute date series - "Date": [start_date + n * period for n in range(0, len(stock_history))], - # Extract open values - "Open": [v[0] for v in stock_history], - # Extract close values - "Close": [v[1] for v in stock_history], - # Extract low values - "Low": [v[2] for v in stock_history], - # Extract high values - "High": [v[3] for v in stock_history], - } +# Retrieved history: +# (Open, Close, Low, High) +stock_history = [ + (311.05, 311.00, 310.75, 311.33), + (308.53, 308.31, 307.72, 309.00), + (307.35, 306.24, 306.12, 307.46), + (306.35, 304.90, 304.34, 310.10), + (304.90, 302.99, 302.27, 307.00), + (303.03, 301.66, 301.20, 303.25), + (301.61, 299.58, 299.50, 301.89), + (299.58, 297.95, 297.80, 300.06), + (297.95, 299.03, 297.14, 299.67), + (299.03, 301.87, 296.71, 301.89), + (301.89, 299.40, 298.73, 302.93), + (299.50, 299.35, 298.83, 299.50), + (299.35, 299.20, 299.19, 299.68), + (299.42, 300.50, 299.42, 300.50), + (300.70, 300.65, 300.32, 300.75), + (300.65, 299.91, 299.91, 300.76), +] +start_date = datetime.datetime(year=2022, month=10, day=21) +period = datetime.timedelta(seconds=4 * 60 * 60) # 4 hours - md = """ -# Candlestick - Timeline +data = { + # Compute date series + "Date": [start_date + n * period for n in range(0, len(stock_history))], + # Extract open values + "Open": [v[0] for v in stock_history], + # Extract close values + "Close": [v[1] for v in stock_history], + # Extract low values + "Low": [v[2] for v in stock_history], + # Extract high values + "High": [v[3] for v in stock_history], +} +md = """ <|{data}|chart|type=candlestick|x=Date|open=Open|close=Close|low=Low|high=High|> - """ +""" - Gui(md).run() +if __name__ == "__main__": + Gui(md).run(title="Chart - Candlestick - Timeline") diff --git a/doc/gui/examples/charts/continuous-error-multiple.py b/doc/gui/examples/charts/continuous-error-multiple.py index 21a62bfec8..0760b43cf8 100644 --- a/doc/gui/examples/charts/continuous-error-multiple.py +++ b/doc/gui/examples/charts/continuous-error-multiple.py @@ -20,98 +20,96 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Data is collected from January 1st, 2010, every month - start_date = datetime.datetime(year=2010, month=1, day=1) - period = dateutil.relativedelta.relativedelta(months=1) - - # Data - # All arrays have the same size (the number of months to track) - prices: Dict[str, List] = { - # Data for apples - "apples": [2.48, 2.47, 2.5, 2.47, 2.46, 2.38, 2.31, 2.25, 2.39, 2.41, 2.59, 2.61], - "apples_low": [1.58, 1.58, 1.59, 1.64, 1.79, 1.54, 1.53, 1.61, 1.65, 2.02, 1.92, 1.54], - "apples_high": [3.38, 3.32, 2.63, 2.82, 2.58, 2.53, 3.27, 3.15, 3.44, 3.42, 3.08, 2.86], - "bananas": [2.94, 2.50, 2.39, 2.77, 2.43, 2.32, 2.37, 1.90, 2.31, 2.71, 3.38, 1.92], - "bananas_low": [2.12, 1.90, 1.69, 2.44, 1.58, 1.81, 1.44, 1.00, 1.59, 1.74, 2.78, 0.96], - "bananas_high": [3.32, 2.70, 3.12, 3.25, 3.00, 2.63, 2.54, 2.37, 2.97, 3.69, 4.36, 2.95], - "cherries": [6.18, None, None, None, 3.69, 2.46, 2.31, 2.57, None, None, 6.50, 4.38], - "cherries_high": [7.00, None, None, None, 8.50, 6.27, 5.61, 4.36, None, None, 8.00, 7.23], - "cherries_low": [3.55, None, None, None, 1.20, 0.87, 1.08, 1.50, None, None, 5.00, 4.20], - } +# Data is collected from January 1st, 2010, every month +start_date = datetime.datetime(year=2010, month=1, day=1) +period = dateutil.relativedelta.relativedelta(months=1) - # Create monthly time series - months = [start_date + n * period for n in range(0, len(prices["apples"]))] +# Data +# All arrays have the same size (the number of months to track) +prices: Dict[str, List] = { + # Data for apples + "apples": [2.48, 2.47, 2.5, 2.47, 2.46, 2.38, 2.31, 2.25, 2.39, 2.41, 2.59, 2.61], + "apples_low": [1.58, 1.58, 1.59, 1.64, 1.79, 1.54, 1.53, 1.61, 1.65, 2.02, 1.92, 1.54], + "apples_high": [3.38, 3.32, 2.63, 2.82, 2.58, 2.53, 3.27, 3.15, 3.44, 3.42, 3.08, 2.86], + "bananas": [2.94, 2.50, 2.39, 2.77, 2.43, 2.32, 2.37, 1.90, 2.31, 2.71, 3.38, 1.92], + "bananas_low": [2.12, 1.90, 1.69, 2.44, 1.58, 1.81, 1.44, 1.00, 1.59, 1.74, 2.78, 0.96], + "bananas_high": [3.32, 2.70, 3.12, 3.25, 3.00, 2.63, 2.54, 2.37, 2.97, 3.69, 4.36, 2.95], + "cherries": [6.18, None, None, None, 3.69, 2.46, 2.31, 2.57, None, None, 6.50, 4.38], + "cherries_high": [7.00, None, None, None, 8.50, 6.27, 5.61, 4.36, None, None, 8.00, 7.23], + "cherries_low": [3.55, None, None, None, 1.20, 0.87, 1.08, 1.50, None, None, 5.00, 4.20], +} - data = [ - # Raw data - {"Months": months, "apples": prices["apples"], "bananas": prices["bananas"], "cherries": prices["cherries"]}, - # Range data (twice as many values) - { - "Months2": months + list(reversed(months)), - "apples": prices["apples_high"] + list(reversed(prices["apples_low"])), - "bananas": prices["bananas_high"] + list(reversed(prices["bananas_low"])), - "cherries": prices["cherries_high"] + list(reversed(prices["cherries_low"])), - }, - ] +# Create monthly time series +months = [start_date + n * period for n in range(0, len(prices["apples"]))] - properties = { - # First trace: reference for Apples - "x[1]": "0/Months", - "y[1]": "0/apples", - "color[1]": "rgb(0,200,80)", - # Hide line - "mode[1]": "markers", - # Show in the legend - "name[1]": "Apples", - # Second trace: reference for Bananas - "x[2]": "0/Months", - "y[2]": "0/bananas", - "color[2]": "rgb(0,100,240)", - # Hide line - "mode[2]": "markers", - # Show in the legend - "name[2]": "Bananas", - # Third trace: reference for Cherries - "x[3]": "0/Months", - "y[3]": "0/cherries", - "color[3]": "rgb(240,60,60)", - # Hide line - "mode[3]": "markers", - # Show in the legend - "name[3]": "Cherries", - # Fourth trace: range for Apples - "x[4]": "1/Months2", - "y[4]": "1/apples", - "options[4]": { - "fill": "tozerox", - "showlegend": False, - "fillcolor": "rgba(0,100,80,0.4)", - }, - # No surrounding stroke - "color[4]": "transparent", - # Fifth trace: range for Bananas - "x[5]": "1/Months2", - "y[5]": "1/bananas", - "options[5]": {"fill": "tozerox", "showlegend": False, "fillcolor": "rgba(0,180,250,0.4)"}, - # No surrounding stroke - "color[5]": "transparent", - # Sixth trace: range for Cherries - "x[6]": "1/Months2", - "y[6]": "1/cherries", - "options[6]": { - "fill": "tozerox", - "showlegend": False, - "fillcolor": "rgba(230,100,120,0.4)", - }, - # No surrounding stroke - "color[6]": "transparent", - } +data = [ + # Raw data + {"Months": months, "apples": prices["apples"], "bananas": prices["bananas"], "cherries": prices["cherries"]}, + # Range data (twice as many values) + { + "Months2": months + list(reversed(months)), + "apples": prices["apples_high"] + list(reversed(prices["apples_low"])), + "bananas": prices["bananas_high"] + list(reversed(prices["bananas_low"])), + "cherries": prices["cherries_high"] + list(reversed(prices["cherries_low"])), + }, +] - page = """ -# Continuous Error - Multiple traces +properties = { + # First trace: reference for Apples + "x[1]": "0/Months", + "y[1]": "0/apples", + "color[1]": "rgb(0,200,80)", + # Hide line + "mode[1]": "markers", + # Show in the legend + "name[1]": "Apples", + # Second trace: reference for Bananas + "x[2]": "0/Months", + "y[2]": "0/bananas", + "color[2]": "rgb(0,100,240)", + # Hide line + "mode[2]": "markers", + # Show in the legend + "name[2]": "Bananas", + # Third trace: reference for Cherries + "x[3]": "0/Months", + "y[3]": "0/cherries", + "color[3]": "rgb(240,60,60)", + # Hide line + "mode[3]": "markers", + # Show in the legend + "name[3]": "Cherries", + # Fourth trace: range for Apples + "x[4]": "1/Months2", + "y[4]": "1/apples", + "options[4]": { + "fill": "tozerox", + "showlegend": False, + "fillcolor": "rgba(0,100,80,0.4)", + }, + # No surrounding stroke + "color[4]": "transparent", + # Fifth trace: range for Bananas + "x[5]": "1/Months2", + "y[5]": "1/bananas", + "options[5]": {"fill": "tozerox", "showlegend": False, "fillcolor": "rgba(0,180,250,0.4)"}, + # No surrounding stroke + "color[5]": "transparent", + # Sixth trace: range for Cherries + "x[6]": "1/Months2", + "y[6]": "1/cherries", + "options[6]": { + "fill": "tozerox", + "showlegend": False, + "fillcolor": "rgba(230,100,120,0.4)", + }, + # No surrounding stroke + "color[6]": "transparent", +} +page = """ <|{data}|chart|properties={properties}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Continuous Error - Multiple traces") diff --git a/doc/gui/examples/charts/continuous-error-simple.py b/doc/gui/examples/charts/continuous-error-simple.py index 03d0925c57..13e2fac17d 100644 --- a/doc/gui/examples/charts/continuous-error-simple.py +++ b/doc/gui/examples/charts/continuous-error-simple.py @@ -17,59 +17,57 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Common axis for all data: [1..10] - x = list(range(1, 11)) - # Sample data - samples = [5, 7, 8, 4, 5, 9, 8, 8, 6, 5] - - # Generate error data - # Error that adds to the input data - error_plus = [3 * random.random() + 0.5 for _ in x] - # Error subtracted from to the input data - error_minus = [3 * random.random() + 0.5 for _ in x] +# Common axis for all data: [1..10] +x = list(range(1, 11)) +# Sample data +samples = [5, 7, 8, 4, 5, 9, 8, 8, 6, 5] - # Upper bound (y + error_plus) - error_upper = [y + e for (y, e) in zip(samples, error_plus)] - # Lower bound (y - error_minus) - error_lower = [y - e for (y, e) in zip(samples, error_minus)] +# Generate error data +# Error that adds to the input data +error_plus = [3 * random.random() + 0.5 for _ in x] +# Error subtracted from to the input data +error_minus = [3 * random.random() + 0.5 for _ in x] - data = [ - # Trace for samples - {"x": x, "y": samples}, - # Trace for error range - { - # Roundtrip around the error bounds: onward then return - "x": x + list(reversed(x)), - # The two error bounds, with lower bound reversed - "y": error_upper + list(reversed(error_lower)), - }, - ] +# Upper bound (y + error_plus) +error_upper = [y + e for (y, e) in zip(samples, error_plus)] +# Lower bound (y - error_minus) +error_lower = [y - e for (y, e) in zip(samples, error_minus)] - properties = { - # Error data - "x[1]": "1/x", - "y[1]": "1/y", - "options[1]": { - # Shows as filled area - "fill": "toself", - "fillcolor": "rgba(70,70,240,0.6)", - "showlegend": False, - }, - # Don't show surrounding stroke - "color[1]": "transparent", - # Raw data (displayed on top of the error band) - "x[2]": "0/x", - "y[2]": "0/y", - "color[2]": "rgb(140,50,50)", - # Shown in the legend - "name[2]": "Input", - } +data = [ + # Trace for samples + {"x": x, "y": samples}, + # Trace for error range + { + # Roundtrip around the error bounds: onward then return + "x": x + list(reversed(x)), + # The two error bounds, with lower bound reversed + "y": error_upper + list(reversed(error_lower)), + }, +] - page = """ -# Continuous Error - Simple +properties = { + # Error data + "x[1]": "1/x", + "y[1]": "1/y", + "options[1]": { + # Shows as filled area + "fill": "toself", + "fillcolor": "rgba(70,70,240,0.6)", + "showlegend": False, + }, + # Don't show surrounding stroke + "color[1]": "transparent", + # Raw data (displayed on top of the error band) + "x[2]": "0/x", + "y[2]": "0/y", + "color[2]": "rgb(140,50,50)", + # Shown in the legend + "name[2]": "Input", +} +page = """ <|{data}|chart|properties={properties}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Continuous Error - Simple") diff --git a/doc/gui/examples/charts/error-bars-asymmetric.py b/doc/gui/examples/charts/error-bars-asymmetric.py index 42b6ceabe6..005c4fb2c2 100644 --- a/doc/gui/examples/charts/error-bars-asymmetric.py +++ b/doc/gui/examples/charts/error-bars-asymmetric.py @@ -17,36 +17,34 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Number of samples - n_samples = 10 - # y values: [0..n_samples-1] - y = range(0, n_samples) +# Number of samples +n_samples = 10 +# y values: [0..n_samples-1] +y = range(0, n_samples) - data = { - # The x series is made of random numbers between 1 and 10 - "x": [random.uniform(1, 10) for _ in y], - "y": y, - } +data = { + # The x series is made of random numbers between 1 and 10 + "x": [random.uniform(1, 10) for _ in y], + "y": y, +} - options = { - "error_x": { - "type": "data", - # Allows for a 'plus' and a 'minus' error data - "symmetric": False, - # The 'plus' error data is a series of random numbers - "array": [random.uniform(0, 5) for _ in y], - # The 'minus' error data is a series of random numbers - "arrayminus": [random.uniform(0, 2) for _ in y], - # Color of the error bar - "color": "red", - } +options = { + "error_x": { + "type": "data", + # Allows for a 'plus' and a 'minus' error data + "symmetric": False, + # The 'plus' error data is a series of random numbers + "array": [random.uniform(0, 5) for _ in y], + # The 'minus' error data is a series of random numbers + "arrayminus": [random.uniform(0, 2) for _ in y], + # Color of the error bar + "color": "red", } +} - page = """ -# Error bars - Asymmetric - +page = """ <|{data}|chart|type=bar|x=x|y=y|orientation=h|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Error bars - Asymmetric") diff --git a/doc/gui/examples/charts/error-bars-simple.py b/doc/gui/examples/charts/error-bars-simple.py index aa1a3a154f..c9c37f4d5e 100644 --- a/doc/gui/examples/charts/error-bars-simple.py +++ b/doc/gui/examples/charts/error-bars-simple.py @@ -18,35 +18,33 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Number of samples - max_x = 20 - # x values: [0..max_x-1] - x = range(0, max_x) - # Generate random sampling error margins - error_ranges = [random.uniform(0, 5) for _ in x] - # Compute a perfect sine wave - perfect_y = [10 * math.sin(4 * math.pi * i / max_x) for i in x] - # Compute a sine wave impacted by the sampling error - # The error is between ±error_ranges[x]/2 - y = [perfect_y[i] + random.uniform(-error_ranges[i] / 2, error_ranges[i] / 2) for i in x] - - # The chart data is made of the three series - data = { - "x": x, - "y1": y, - "y2": perfect_y, - } +# Number of samples +max_x = 20 +# x values: [0..max_x-1] +x = range(0, max_x) +# Generate random sampling error margins +error_ranges = [random.uniform(0, 5) for _ in x] +# Compute a perfect sine wave +perfect_y = [10 * math.sin(4 * math.pi * i / max_x) for i in x] +# Compute a sine wave impacted by the sampling error +# The error is between ±error_ranges[x]/2 +y = [perfect_y[i] + random.uniform(-error_ranges[i] / 2, error_ranges[i] / 2) for i in x] - options = { - # Create the error bar information: - "error_y": {"type": "data", "array": error_ranges} - } +# The chart data is made of the three series +data = { + "x": x, + "y1": y, + "y2": perfect_y, +} - page = """ -# Error bars - Simple +options = { + # Create the error bar information: + "error_y": {"type": "data", "array": error_ranges} +} +page = """ <|{data}|chart|x=x|y[1]=y1|y[2]=y2|options[1]={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Error bars - Simple") diff --git a/doc/gui/examples/charts/example-rebuild.py b/doc/gui/examples/charts/example-rebuild.py index 1851df54f5..2002da144b 100644 --- a/doc/gui/examples/charts/example-rebuild.py +++ b/doc/gui/examples/charts/example-rebuild.py @@ -17,18 +17,18 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # x values: [-10..10] - x_range = range(-10, 11) - data = {"X": x_range, "Y": [x * x for x in x_range]} +# x values: [-10..10] +x_range = range(-10, 11) +data = {"X": x_range, "Y": [x * x for x in x_range]} - types = [("bar", "Bar"), ("line", "Line")] - selected_type = types[0] +types = [("bar", "Bar"), ("line", "Line")] +selected_type = types[0] - page = """ +page = """ <|{data}|chart|type={selected_type[0]}|x=X|y=Y|rebuild|> <|{selected_type}|toggle|lov={types}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Rebuild") diff --git a/doc/gui/examples/charts/filled-area-normalized.py b/doc/gui/examples/charts/filled-area-normalized.py index 0d36811041..b719bb9dc4 100644 --- a/doc/gui/examples/charts/filled-area-normalized.py +++ b/doc/gui/examples/charts/filled-area-normalized.py @@ -15,48 +15,46 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Products": [ - "Nail polish", - "Eyebrow pencil", - "Rouge", - "Lipstick", - "Eyeshadows", - "Eyeliner", - "Foundation", - "Lip gloss", - "Mascara", - ], - "USA": [12814, 13012, 11624, 8814, 12998, 12321, 10342, 22998, 11261], - "China": [3054, 5067, 7004, 9054, 12043, 15067, 10119, 12043, 10419], - "EU": [4376, 3987, 3574, 4376, 4572, 3417, 5231, 4572, 6134], - "Africa": [4229, 3932, 5221, 9256, 3308, 5432, 13701, 4008, 18712], - } - - # Order the different traces - ys = ["USA", "China", "EU", "Africa"] +data = { + "Products": [ + "Nail polish", + "Eyebrow pencil", + "Rouge", + "Lipstick", + "Eyeshadows", + "Eyeliner", + "Foundation", + "Lip gloss", + "Mascara", + ], + "USA": [12814, 13012, 11624, 8814, 12998, 12321, 10342, 22998, 11261], + "China": [3054, 5067, 7004, 9054, 12043, 15067, 10119, 12043, 10419], + "EU": [4376, 3987, 3574, 4376, 4572, 3417, 5231, 4572, 6134], + "Africa": [4229, 3932, 5221, 9256, 3308, 5432, 13701, 4008, 18712], +} - options = [ - # For the USA - {"stackgroup": "one", "groupnorm": "percent"}, - # For China - {"stackgroup": "one"}, - # For the EU - {"stackgroup": "one"}, - # For Africa - {"stackgroup": "one"}, - ] +# Order the different traces +ys = ["USA", "China", "EU", "Africa"] - layout = { - # Show all values when hovering on a data point - "hovermode": "x unified" - } +options = [ + # For the USA + {"stackgroup": "one", "groupnorm": "percent"}, + # For China + {"stackgroup": "one"}, + # For the EU + {"stackgroup": "one"}, + # For Africa + {"stackgroup": "one"}, +] - page = """ -# Filled Area - Stacked Normalized +layout = { + # Show all values when hovering on a data point + "hovermode": "x unified" +} +page = """ <|{data}|chart|mode=none|x=Products|y={ys}|options={options}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Filled Area - Stacked Normalized") diff --git a/doc/gui/examples/charts/filled-area-overlay.py b/doc/gui/examples/charts/filled-area-overlay.py index cd3c550fca..a132a260cc 100644 --- a/doc/gui/examples/charts/filled-area-overlay.py +++ b/doc/gui/examples/charts/filled-area-overlay.py @@ -15,25 +15,23 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"], - "Items": [32, 25, 86, 60, 70], - "Price": [80, 50, 140, 10, 70], - } - - options = [ - # For items - {"fill": "tozeroy"}, - # For price - # Using "tonexty" not to cover the first trace - {"fill": "tonexty"}, - ] +data = { + "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"], + "Items": [32, 25, 86, 60, 70], + "Price": [80, 50, 140, 10, 70], +} - page = """ -# Filled Area - Overlay +options = [ + # For items + {"fill": "tozeroy"}, + # For price + # Using "tonexty" not to cover the first trace + {"fill": "tonexty"}, +] +page = """ <|{data}|chart|mode=none|x=Day|y[1]=Items|y[2]=Price|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Filled Area - Overlay") diff --git a/doc/gui/examples/charts/filled-area-simple.py b/doc/gui/examples/charts/filled-area-simple.py index 6e2d6e3336..2efd7c8ad9 100644 --- a/doc/gui/examples/charts/filled-area-simple.py +++ b/doc/gui/examples/charts/filled-area-simple.py @@ -15,21 +15,19 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"], - "Items": [32, 25, 86, 60, 70], - } - - options = { - # Fill to x axis - "fill": "tozeroy" - } +data = { + "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"], + "Items": [32, 25, 86, 60, 70], +} - page = """ -# Filled Area - Simple +options = { + # Fill to x axis + "fill": "tozeroy" +} +page = """ <|{data}|chart|x=Day|y=Items|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Filled Area - Simple") diff --git a/doc/gui/examples/charts/filled-area-stacked.py b/doc/gui/examples/charts/filled-area-stacked.py index 234a247ece..9a84b2d6e2 100644 --- a/doc/gui/examples/charts/filled-area-stacked.py +++ b/doc/gui/examples/charts/filled-area-stacked.py @@ -15,26 +15,24 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], - "Milk": [80, 85, 95, 120, 140, 130, 145, 150, 120, 100, 90, 110], - "Bread": [100, 90, 85, 90, 100, 110, 105, 95, 100, 110, 120, 125], - "Apples": [50, 65, 70, 65, 70, 75, 85, 70, 60, 65, 70, 80], - } - - # Name of the three sets to trace - items = ["Milk", "Bread", "Apples"] +data = { + "Month": ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], + "Milk": [80, 85, 95, 120, 140, 130, 145, 150, 120, 100, 90, 110], + "Bread": [100, 90, 85, 90, 100, 110, 105, 95, 100, 110, 120, 125], + "Apples": [50, 65, 70, 65, 70, 75, 85, 70, 60, 65, 70, 80], +} - options = { - # Group all traces in the same stack group - "stackgroup": "first_group" - } +# Name of the three sets to trace +items = ["Milk", "Bread", "Apples"] - page = """ -# Filled Area - Stacked +options = { + # Group all traces in the same stack group + "stackgroup": "first_group" +} +page = """ <|{data}|chart|mode=none|x=Month|y={items}|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Filled Area - Stacked") diff --git a/doc/gui/examples/charts/funnel-area-multiple.py b/doc/gui/examples/charts/funnel-area-multiple.py index b6aad0f9cc..fc18cb32cc 100644 --- a/doc/gui/examples/charts/funnel-area-multiple.py +++ b/doc/gui/examples/charts/funnel-area-multiple.py @@ -15,80 +15,78 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "John_us": [500, 450, 340, 230, 220, 110], - "John_eu": [600, 500, 400, 300, 200, 100], - "Robert_us": [510, 480, 440, 330, 220, 100], - "Robert_eu": [360, 250, 240, 130, 120, 60], - } +data = { + "John_us": [500, 450, 340, 230, 220, 110], + "John_eu": [600, 500, 400, 300, 200, 100], + "Robert_us": [510, 480, 440, 330, 220, 100], + "Robert_eu": [360, 250, 240, 130, 120, 60], +} - # Values for each trace - values = ["John_us", "John_eu", "Robert_us", "Robert_eu"] +# Values for each trace +values = ["John_us", "John_eu", "Robert_us", "Robert_eu"] - options = [ - # For John/US - { - "scalegroup": "first", - "textinfo": "value", - "title": { - # "position": "top", - "text": "John in the U.S." - }, - # Lower-left corner - "domain": {"x": [0, 0.5], "y": [0, 0.5]}, +options = [ + # For John/US + { + "scalegroup": "first", + "textinfo": "value", + "title": { + # "position": "top", + "text": "John in the U.S." }, - # For John/EU - { - "scalegroup": "first", - "textinfo": "value", - "title": { - # "position": "top", - "text": "John in the E.U." - }, - # Upper-left corner - "domain": {"x": [0, 0.5], "y": [0.55, 1]}, + # Lower-left corner + "domain": {"x": [0, 0.5], "y": [0, 0.5]}, + }, + # For John/EU + { + "scalegroup": "first", + "textinfo": "value", + "title": { + # "position": "top", + "text": "John in the E.U." }, - # For Robert/US - { - "scalegroup": "second", - "textinfo": "value", - "title": { - # "position": "top", - "text": "Robert in the U.S." - }, - # Lower-right corner - "domain": {"x": [0.51, 1], "y": [0, 0.5]}, + # Upper-left corner + "domain": {"x": [0, 0.5], "y": [0.55, 1]}, + }, + # For Robert/US + { + "scalegroup": "second", + "textinfo": "value", + "title": { + # "position": "top", + "text": "Robert in the U.S." }, - # For Robert/EU - { - "scalegroup": "second", - "textinfo": "value", - "title": { - # "position": "top", - "text": "Robert in the E.U." - }, - # Upper-right corner - "domain": {"x": [0.51, 1], "y": [0.51, 1]}, + # Lower-right corner + "domain": {"x": [0.51, 1], "y": [0, 0.5]}, + }, + # For Robert/EU + { + "scalegroup": "second", + "textinfo": "value", + "title": { + # "position": "top", + "text": "Robert in the E.U." }, - ] - - layout = { - "title": "Sales per Salesman per Region", - "showlegend": False, - # Draw frames around each trace - "shapes": [ - {"x0": 0, "x1": 0.5, "y0": 0, "y1": 0.5}, - {"x0": 0, "x1": 0.5, "y0": 0.52, "y1": 1}, - {"x0": 0.52, "x1": 1, "y0": 0, "y1": 0.5}, - {"x0": 0.52, "x1": 1, "y0": 0.52, "y1": 1}, - ], - } + # Upper-right corner + "domain": {"x": [0.51, 1], "y": [0.51, 1]}, + }, +] - page = """ -# Funnel Area - Multiple Charts +layout = { + "title": "Sales per Salesman per Region", + "showlegend": False, + # Draw frames around each trace + "shapes": [ + {"x0": 0, "x1": 0.5, "y0": 0, "y1": 0.5}, + {"x0": 0, "x1": 0.5, "y0": 0.52, "y1": 1}, + {"x0": 0.52, "x1": 1, "y0": 0, "y1": 0.5}, + {"x0": 0.52, "x1": 1, "y0": 0.52, "y1": 1}, + ], +} +page = """ <|{data}|chart|type=funnelarea|values={values}|options={options}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Funnel Area - Multiple Charts") diff --git a/doc/gui/examples/charts/funnel-area.py b/doc/gui/examples/charts/funnel-area.py index 0654699036..b42591bfd1 100644 --- a/doc/gui/examples/charts/funnel-area.py +++ b/doc/gui/examples/charts/funnel-area.py @@ -15,23 +15,21 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Types": ["Visits", "Downloads", "Prospects", "Invoiced", "Closed"], - "Visits": [13873, 10533, 5443, 2703, 908], - } - - layout = { - # Stack the areas - "funnelmode": "stack", - # Hide the legend - "showlegend": False, - } +data = { + "Types": ["Visits", "Downloads", "Prospects", "Invoiced", "Closed"], + "Visits": [13873, 10533, 5443, 2703, 908], +} - page = """ -# Funnel - Area +layout = { + # Stack the areas + "funnelmode": "stack", + # Hide the legend + "showlegend": False, +} +page = """ <|{data}|chart|type=funnelarea|values=Visits|text=Types|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Funnel - Area") diff --git a/doc/gui/examples/charts/funnel-multiple.py b/doc/gui/examples/charts/funnel-multiple.py index 3a9f5dadbe..9157ba6553 100644 --- a/doc/gui/examples/charts/funnel-multiple.py +++ b/doc/gui/examples/charts/funnel-multiple.py @@ -15,24 +15,22 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Types": ["Website visit", "Downloads", "Prospects", "Invoice sent", "Closed"], - "Visits_us": [13873, 10533, 5443, 2703, 908], - "Visits_eu": [7063, 4533, 3443, 1003, 1208], - "Visits_ap": [6873, 2533, 3443, 1703, 508], - } - - # Columns for each trace - x = ["Visits_us", "Visits_eu", "Visits_ap"] +data = { + "Types": ["Website visit", "Downloads", "Prospects", "Invoice sent", "Closed"], + "Visits_us": [13873, 10533, 5443, 2703, 908], + "Visits_eu": [7063, 4533, 3443, 1003, 1208], + "Visits_ap": [6873, 2533, 3443, 1703, 508], +} - # Legend text for each trace - names = ["US", "EU", "AP"] +# Columns for each trace +x = ["Visits_us", "Visits_eu", "Visits_ap"] - page = """ -# Funnel - Multiple traces +# Legend text for each trace +names = ["US", "EU", "AP"] +page = """ <|{data}|chart|type=funnel|x={x}|y=Types|name={names}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Funnel - Multiple traces") diff --git a/doc/gui/examples/charts/funnel-simple.py b/doc/gui/examples/charts/funnel-simple.py index 0066ab6c7e..56d6ccdea8 100644 --- a/doc/gui/examples/charts/funnel-simple.py +++ b/doc/gui/examples/charts/funnel-simple.py @@ -15,14 +15,12 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Data set - data = {"Opps": ["Hot leads", "Doc sent", "Quote", "Closed Won"], "Visits": [316, 238, 125, 83]} - - page = """ -# Funnel Chart - Simple +# Data set +data = {"Opps": ["Hot leads", "Doc sent", "Quote", "Closed Won"], "Visits": [316, 238, 125, 83]} +page = """ <|{data}|chart|type=funnel|x=Visits|y=Opps|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Funnel - Simple") diff --git a/doc/gui/examples/charts/funnel-styling.py b/doc/gui/examples/charts/funnel-styling.py index 418169e1e5..201b818e26 100644 --- a/doc/gui/examples/charts/funnel-styling.py +++ b/doc/gui/examples/charts/funnel-styling.py @@ -15,28 +15,26 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Types": ["Website visit", "Downloads", "Prospects", "Invoice sent", "Closed"], - "Visits": [13873, 10533, 5443, 2703, 908], - } - - marker = { - # Boxes are filled with a blue gradient color - "color": ["hsl(210,50%,50%)", "hsl(210,60%,60%)", "hsl(210,70%,70%)", "hsl(210,80%,80%)", "hsl(210,90%,90%)"], - # Lines get thicker, with an orange-to-green gradient color - "line": {"width": [1, 1, 2, 3, 4], "color": ["f5720a", "f39c1d", "f0cc3d", "aadb12", "8cb709"]}, - } +data = { + "Types": ["Website visit", "Downloads", "Prospects", "Invoice sent", "Closed"], + "Visits": [13873, 10533, 5443, 2703, 908], +} - options = { - # Lines connecting boxes are thick, dotted and green - "connector": {"line": {"color": "green", "dash": "dot", "width": 4}} - } +marker = { + # Boxes are filled with a blue gradient color + "color": ["hsl(210,50%,50%)", "hsl(210,60%,60%)", "hsl(210,70%,70%)", "hsl(210,80%,80%)", "hsl(210,90%,90%)"], + # Lines get thicker, with an orange-to-green gradient color + "line": {"width": [1, 1, 2, 3, 4], "color": ["f5720a", "f39c1d", "f0cc3d", "aadb12", "8cb709"]}, +} - page = """ -# Funnel Chart - Custom markers +options = { + # Lines connecting boxes are thick, dotted and green + "connector": {"line": {"color": "green", "dash": "dot", "width": 4}} +} +page = """ <|{data}|chart|type=funnel|x=Visits|y=Types|marker={marker}|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Funnel - Custom markers") diff --git a/doc/gui/examples/charts/gantt-simple.py b/doc/gui/examples/charts/gantt-simple.py index 017a1c7d33..bdbfe923eb 100644 --- a/doc/gui/examples/charts/gantt-simple.py +++ b/doc/gui/examples/charts/gantt-simple.py @@ -17,43 +17,41 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Tasks definitions - tasks = ["Plan", "Research", "Design", "Implement", "Test", "Deliver"] - # Task durations, in days - durations = [50, 30, 30, 40, 15, 10] - # Planned start dates of tasks - start_dates = [ - datetime.date(2022, 10, 15), # Plan - datetime.date(2022, 11, 7), # Research - datetime.date(2022, 12, 1), # Design - datetime.date(2022, 12, 20), # Implement - datetime.date(2023, 1, 15), # Test - datetime.date(2023, 2, 1), # Deliver - ] - - epoch = datetime.date(1970, 1, 1) - - data = { - "start": start_dates, - "Task": tasks, - # Compute the time span as adatetime (relative to January 1st, 1970) - "Date": [epoch + datetime.timedelta(days=duration) for duration in durations], - } - - layout = { - "yaxis": { - # Sort tasks from top to bottom - "autorange": "reversed", - # Remove title - "title": {"text": ""}, - }, - } - - page = """ -# Gantt - Simple - +# Tasks definitions +tasks = ["Plan", "Research", "Design", "Implement", "Test", "Deliver"] +# Task durations, in days +durations = [50, 30, 30, 40, 15, 10] +# Planned start dates of tasks +start_dates = [ + datetime.date(2022, 10, 15), # Plan + datetime.date(2022, 11, 7), # Research + datetime.date(2022, 12, 1), # Design + datetime.date(2022, 12, 20), # Implement + datetime.date(2023, 1, 15), # Test + datetime.date(2023, 2, 1), # Deliver +] + +epoch = datetime.date(1970, 1, 1) + +data = { + "start": start_dates, + "Task": tasks, + # Compute the time span as adatetime (relative to January 1st, 1970) + "Date": [epoch + datetime.timedelta(days=duration) for duration in durations], +} + +layout = { + "yaxis": { + # Sort tasks from top to bottom + "autorange": "reversed", + # Remove title + "title": {"text": ""}, + }, +} + +page = """ <|{data}|chart|type=bar|orientation=h|y=Task|x=Date|base=start|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Gantt - Simple") diff --git a/doc/gui/examples/charts/heatmap-annotated.py b/doc/gui/examples/charts/heatmap-annotated.py index 4427594f0d..63c43dd6b0 100644 --- a/doc/gui/examples/charts/heatmap-annotated.py +++ b/doc/gui/examples/charts/heatmap-annotated.py @@ -17,57 +17,55 @@ from taipy.gui import Gui -if __name__ == "__main__": - data: Dict[str, List] = { - "Temperatures": [ - [17.2, 27.4, 28.6, 21.5], - [5.6, 15.1, 20.2, 8.1], - [26.6, 22.8, 21.8, 24.0], - [22.3, 15.5, 13.4, 19.6], - ], - "Cities": ["Hanoi", "Paris", "Rio", "Sydney"], - "Seasons": ["Winter", "Spring", "Summer", "Autumn"], - } - - layout = { - # This array contains the information we want to display in the cells - # These are filled later - "annotations": [], - # No ticks on the x axis, show labels on top the of the chart - "xaxis": {"ticks": "", "side": "top"}, - # No ticks on the y axis - # Add a space character for a small margin with the text - "yaxis": {"ticks": "", "ticksuffix": " "}, - } +data: Dict[str, List] = { + "Temperatures": [ + [17.2, 27.4, 28.6, 21.5], + [5.6, 15.1, 20.2, 8.1], + [26.6, 22.8, 21.8, 24.0], + [22.3, 15.5, 13.4, 19.6], + ], + "Cities": ["Hanoi", "Paris", "Rio", "Sydney"], + "Seasons": ["Winter", "Spring", "Summer", "Autumn"], +} - seasons = data["Seasons"] - cities = data["Cities"] - # Iterate over all cities - for city in range(len(cities)): - # Iterate over all seasons - for season in range(len(seasons)): - temperature = data["Temperatures"][city][season] - # Create the annotation - annotation = { - # The name of the season - "x": seasons[season], - # The name of the city - "y": cities[city], - # The temperature, as a formatted string - "text": f"{temperature}\N{DEGREE SIGN}C", - # Change the text color depending on the temperature - # so it results in a better contrast - "font": {"color": "white" if temperature < 14 else "black"}, - # Remove the annotation arrow - "showarrow": False, - } - # Add the annotation to the layout's annotations array - layout["annotations"].append(annotation) # type: ignore[attr-defined] +layout = { + # This array contains the information we want to display in the cells + # These are filled later + "annotations": [], + # No ticks on the x axis, show labels on top the of the chart + "xaxis": {"ticks": "", "side": "top"}, + # No ticks on the y axis + # Add a space character for a small margin with the text + "yaxis": {"ticks": "", "ticksuffix": " "}, +} - page = """ -## Heatmap - Annotated +seasons = data["Seasons"] +cities = data["Cities"] +# Iterate over all cities +for city in range(len(cities)): + # Iterate over all seasons + for season in range(len(seasons)): + temperature = data["Temperatures"][city][season] + # Create the annotation + annotation = { + # The name of the season + "x": seasons[season], + # The name of the city + "y": cities[city], + # The temperature, as a formatted string + "text": f"{temperature}\N{DEGREE SIGN}C", + # Change the text color depending on the temperature + # so it results in a better contrast + "font": {"color": "white" if temperature < 14 else "black"}, + # Remove the annotation arrow + "showarrow": False, + } + # Add the annotation to the layout's annotations array + layout["annotations"].append(annotation) # type: ignore[attr-defined] +page = """ <|{data}|chart|type=heatmap|z=Temperatures|x=Seasons|y=Cities|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Heatmap - Annotated") diff --git a/doc/gui/examples/charts/heatmap-colorscale.py b/doc/gui/examples/charts/heatmap-colorscale.py index 579187ef15..f811bffc0d 100644 --- a/doc/gui/examples/charts/heatmap-colorscale.py +++ b/doc/gui/examples/charts/heatmap-colorscale.py @@ -15,24 +15,22 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Temperatures": [ - [17.2, 27.4, 28.6, 21.5], - [5.6, 15.1, 20.2, 8.1], - [26.6, 22.8, 21.8, 24.0], - [22.3, 15.5, 13.4, 19.6], - ], - "Cities": ["Hanoi", "Paris", "Rio", "Sydney"], - "Seasons": ["Winter", "Spring", "Summer", "Autumn"], - } - - options = {"colorscale": "Portland"} +data = { + "Temperatures": [ + [17.2, 27.4, 28.6, 21.5], + [5.6, 15.1, 20.2, 8.1], + [26.6, 22.8, 21.8, 24.0], + [22.3, 15.5, 13.4, 19.6], + ], + "Cities": ["Hanoi", "Paris", "Rio", "Sydney"], + "Seasons": ["Winter", "Spring", "Summer", "Autumn"], +} - page = """ -# Heatmap - Colorscale +options = {"colorscale": "Portland"} +page = """ <|{data}|chart|type=heatmap|z=Temperatures|x=Seasons|y=Cities|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Heatmap - Colorscale") diff --git a/doc/gui/examples/charts/heatmap-drawing-on-top.py b/doc/gui/examples/charts/heatmap-drawing-on-top.py index 9a54903922..2bc4ac5299 100644 --- a/doc/gui/examples/charts/heatmap-drawing-on-top.py +++ b/doc/gui/examples/charts/heatmap-drawing-on-top.py @@ -26,67 +26,65 @@ def spiral(th): return (r * numpy.cos(th), r * numpy.sin(th)) -if __name__ == "__main__": - # Prepare Golden spiral data as a parametric curve - (x, y) = spiral(numpy.linspace(-numpy.pi / 13, 4 * numpy.pi, 1000)) - - # Prepare the heatmap x and y cell sizes along the axes - golden_ratio = (1 + numpy.sqrt(5)) / 2.0 # Golden ratio - grid_x = [0, 1, 1 + (1 / (golden_ratio**4)), 1 + (1 / (golden_ratio**3)), golden_ratio] - grid_y = [ - 0, - 1 / (golden_ratio**3), - 1 / golden_ratio**3 + 1 / golden_ratio**4, - 1 / (golden_ratio**2), - 1, - ] +# Prepare Golden spiral data as a parametric curve +(x, y) = spiral(numpy.linspace(-numpy.pi / 13, 4 * numpy.pi, 1000)) - # Main value is based on the Fibonacci sequence - z = [[13, 3, 3, 5], [13, 2, 1, 5], [13, 10, 11, 12], [13, 8, 8, 8]] +# Prepare the heatmap x and y cell sizes along the axes +golden_ratio = (1 + numpy.sqrt(5)) / 2.0 # Golden ratio +grid_x = [0, 1, 1 + (1 / (golden_ratio**4)), 1 + (1 / (golden_ratio**3)), golden_ratio] +grid_y = [ + 0, + 1 / (golden_ratio**3), + 1 / golden_ratio**3 + 1 / golden_ratio**4, + 1 / (golden_ratio**2), + 1, +] - # Group all data sets in a single array - data = [ - { - "z": z, - }, - {"x": numpy.sort(grid_x), "y": numpy.sort(grid_y)}, - { - "xSpiral": -x + x[0], - "ySpiral": y - y[0], - }, - ] +# Main value is based on the Fibonacci sequence +z = [[13, 3, 3, 5], [13, 2, 1, 5], [13, 10, 11, 12], [13, 8, 8, 8]] - # Axis template: hide all ticks, lines and labels - axis = { - "range": [0, 2.0], - "showgrid": False, - "zeroline": False, - "showticklabels": False, - "ticks": "", - "title": "", - } +# Group all data sets in a single array +data = [ + { + "z": z, + }, + {"x": numpy.sort(grid_x), "y": numpy.sort(grid_y)}, + { + "xSpiral": -x + x[0], + "ySpiral": y - y[0], + }, +] - layout = { - # Use the axis template for both x and y axes - "xaxis": axis, - "yaxis": axis, - } +# Axis template: hide all ticks, lines and labels +axis = { + "range": [0, 2.0], + "showgrid": False, + "zeroline": False, + "showticklabels": False, + "ticks": "", + "title": "", +} - options = { - # Hide the color scale of the heatmap - "showscale": False - } +layout = { + # Use the axis template for both x and y axes + "xaxis": axis, + "yaxis": axis, +} - # Chart holds two traces, with different types - types = ["heatmap", "scatter"] - # x and y values for both traces - xs = ["1/x", "2/xSpiral"] - ys = ["1/y", "2/ySpiral"] +options = { + # Hide the color scale of the heatmap + "showscale": False +} - page = """ -## Heatmap - Drawing on top +# Chart holds two traces, with different types +types = ["heatmap", "scatter"] +# x and y values for both traces +xs = ["1/x", "2/xSpiral"] +ys = ["1/y", "2/ySpiral"] +page = """ <|{data}|chart|type={types}|z[1]=0/z|x={xs}|y={ys}|layout={layout}|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Heatmap - Drawing on top") diff --git a/doc/gui/examples/charts/heatmap-simple.py b/doc/gui/examples/charts/heatmap-simple.py index b780e95904..298549563a 100644 --- a/doc/gui/examples/charts/heatmap-simple.py +++ b/doc/gui/examples/charts/heatmap-simple.py @@ -15,22 +15,20 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = { - "Temperatures": [ - [17.2, 27.4, 28.6, 21.5], - [5.6, 15.1, 20.2, 8.1], - [26.6, 22.8, 21.8, 24.0], - [22.3, 15.5, 13.4, 19.6], - ], - "Cities": ["Hanoi", "Paris", "Rio", "Sydney"], - "Seasons": ["Winter", "Spring", "Summer", "Autumn"], - } - - page = """ -# Heatmap - Basic +data = { + "Temperatures": [ + [17.2, 27.4, 28.6, 21.5], + [5.6, 15.1, 20.2, 8.1], + [26.6, 22.8, 21.8, 24.0], + [22.3, 15.5, 13.4, 19.6], + ], + "Cities": ["Hanoi", "Paris", "Rio", "Sydney"], + "Seasons": ["Winter", "Spring", "Summer", "Autumn"], +} +page = """ <|{data}|chart|type=heatmap|z=Temperatures|x=Seasons|y=Cities|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Heatmap - Basic") diff --git a/doc/gui/examples/charts/heatmap-unbalanced.py b/doc/gui/examples/charts/heatmap-unbalanced.py index a6ea7b17d9..9672954168 100644 --- a/doc/gui/examples/charts/heatmap-unbalanced.py +++ b/doc/gui/examples/charts/heatmap-unbalanced.py @@ -15,25 +15,23 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = [ - { - "Temperatures": [ - [17.2, 27.4, 28.6, 21.5], - [5.6, 15.1, 20.2, 8.1], - [26.6, 22.8, 21.8, 24.0], - [22.3, 15.5, 13.4, 19.6], - [3.9, 18.9, 25.7, 9.8], - ], - "Cities": ["Hanoi", "Paris", "Rio", "Sydney", "Washington"], - }, - {"Seasons": ["Winter", "Spring", "Summer", "Autumn"]}, - ] - - page = """ -# Heatmap - Unbalanced +data = [ + { + "Temperatures": [ + [17.2, 27.4, 28.6, 21.5], + [5.6, 15.1, 20.2, 8.1], + [26.6, 22.8, 21.8, 24.0], + [22.3, 15.5, 13.4, 19.6], + [3.9, 18.9, 25.7, 9.8], + ], + "Cities": ["Hanoi", "Paris", "Rio", "Sydney", "Washington"], + }, + {"Seasons": ["Winter", "Spring", "Summer", "Autumn"]}, +] +page = """ <|{data}|chart|type=heatmap|z=0/Temperatures|x=1/Seasons|y=0/Cities|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Heatmap - Unbalanced") diff --git a/doc/gui/examples/charts/heatmap-unequal-cell-sizes.py b/doc/gui/examples/charts/heatmap-unequal-cell-sizes.py index 69a9b1f5d9..18409485a4 100644 --- a/doc/gui/examples/charts/heatmap-unequal-cell-sizes.py +++ b/doc/gui/examples/charts/heatmap-unequal-cell-sizes.py @@ -19,48 +19,46 @@ from taipy.gui import Gui -if __name__ == "__main__": - grid_size = 10 - data = [ - { - # z is set to: - # - 0 if row+col is a multiple of 4 - # - 1 if row+col is a multiple of 2 - # - 0.5 otherwise - "z": [ - [0.0 if (row + col) % 4 == 0 else 1 if (row + col) % 2 == 0 else 0.5 for col in range(grid_size)] - for row in range(grid_size) - ] - }, - { - # A series of coordinates, growing exponentially - "x": [0] + list(accumulate(np.logspace(0, 1, grid_size))), - # A series of coordinates, shrinking exponentially - "y": [0] + list(accumulate(np.logspace(1, 0, grid_size))), - }, - ] - - # Axis template used in the layout object - axis_template = { - # Don't show any line or tick or label - "showgrid": False, - "zeroline": False, - "ticks": "", - "showticklabels": False, - "visible": False, - } +grid_size = 10 +data = [ + { + # z is set to: + # - 0 if row+col is a multiple of 4 + # - 1 if row+col is a multiple of 2 + # - 0.5 otherwise + "z": [ + [0.0 if (row + col) % 4 == 0 else 1 if (row + col) % 2 == 0 else 0.5 for col in range(grid_size)] + for row in range(grid_size) + ] + }, + { + # A series of coordinates, growing exponentially + "x": [0] + list(accumulate(np.logspace(0, 1, grid_size))), + # A series of coordinates, shrinking exponentially + "y": [0] + list(accumulate(np.logspace(1, 0, grid_size))), + }, +] - layout = {"xaxis": axis_template, "yaxis": axis_template} +# Axis template used in the layout object +axis_template = { + # Don't show any line or tick or label + "showgrid": False, + "zeroline": False, + "ticks": "", + "showticklabels": False, + "visible": False, +} - options = { - # Remove the color scale display - "showscale": False - } +layout = {"xaxis": axis_template, "yaxis": axis_template} - page = """ -## Heatmap - Unequal block sizes +options = { + # Remove the color scale display + "showscale": False +} +page = """ <|{data}|chart|type=heatmap|z=0/z|x=1/x|y=1/y|layout={layout}|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Heatmap - Unequal block sizes") diff --git a/doc/gui/examples/charts/histogram-binning-function.py b/doc/gui/examples/charts/histogram-binning-function.py index a5ce5f37ff..be764ba749 100644 --- a/doc/gui/examples/charts/histogram-binning-function.py +++ b/doc/gui/examples/charts/histogram-binning-function.py @@ -15,42 +15,40 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Initial data set. y = count_of(x) - samples = {"x": ["Apples", "Apples", "Apples", "Oranges", "Bananas", "Oranges"], "y": [5, 10, 3, 8, 5, 2]} - - # Create a data set array to allow for two traces - data = [samples, samples] +# Initial data set. y = count_of(x) +samples = {"x": ["Apples", "Apples", "Apples", "Oranges", "Bananas", "Oranges"], "y": [5, 10, 3, 8, 5, 2]} - # Gather those settings in a single dictionary - properties = { - # 'x' of the first trace is the 'x' data from the first element of data - "x[1]": "0/x", - # 'y' of the first trace is the 'y' data from the first element of data - "y[1]": "0/y", - # 'x' of the second trace is the 'x' data from the second element of data - "x[2]": "1/x", - # 'y' of the second trace is the 'y' data from the second element of data - "y[2]": "1/y", - # Data set colors - "color": ["#cd5c5c", "#505070"], - # Data set names (for the legend) - "name": ["Count", "Sum"], - # Configure the binning functions - "options": [ - # First trace: count the bins - {"histfunc": "count"}, - # Second trace: sum the bin occurrences - {"histfunc": "sum"}, - ], - # Set x axis name - "layout": {"xaxis": {"title": "Fruit"}}, - } +# Create a data set array to allow for two traces +data = [samples, samples] - page = """ -# Histogram - Binning function +# Gather those settings in a single dictionary +properties = { + # 'x' of the first trace is the 'x' data from the first element of data + "x[1]": "0/x", + # 'y' of the first trace is the 'y' data from the first element of data + "y[1]": "0/y", + # 'x' of the second trace is the 'x' data from the second element of data + "x[2]": "1/x", + # 'y' of the second trace is the 'y' data from the second element of data + "y[2]": "1/y", + # Data set colors + "color": ["#cd5c5c", "#505070"], + # Data set names (for the legend) + "name": ["Count", "Sum"], + # Configure the binning functions + "options": [ + # First trace: count the bins + {"histfunc": "count"}, + # Second trace: sum the bin occurrences + {"histfunc": "sum"}, + ], + # Set x axis name + "layout": {"xaxis": {"title": "Fruit"}}, +} +page = """ <|{data}|chart|type=histogram|properties={properties}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - Binning function") diff --git a/doc/gui/examples/charts/histogram-cumulative.py b/doc/gui/examples/charts/histogram-cumulative.py index a8c8bcebc7..fa366a1570 100644 --- a/doc/gui/examples/charts/histogram-cumulative.py +++ b/doc/gui/examples/charts/histogram-cumulative.py @@ -17,19 +17,17 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Random data set - data = [random.random() for _ in range(500)] - - options = { - # Enable the cumulative histogram - "cumulative": {"enabled": True} - } +# Random data set +data = [random.random() for _ in range(500)] - page = """ -# Histogram - Cumulative +options = { + # Enable the cumulative histogram + "cumulative": {"enabled": True} +} +page = """ <|{data}|chart|type=histogram|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - Cumulative") diff --git a/doc/gui/examples/charts/histogram-horizontal.py b/doc/gui/examples/charts/histogram-horizontal.py index a59546dc22..fdef32492e 100644 --- a/doc/gui/examples/charts/histogram-horizontal.py +++ b/doc/gui/examples/charts/histogram-horizontal.py @@ -17,14 +17,12 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Random data set - data = {"Count": [random.random() for _ in range(100)]} - - page = """ -# Histograms - Horizontal +# Random data set +data = {"Count": [random.random() for _ in range(100)]} +page = """ <|{data}|chart|type=histogram|y=Count|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Histograms - Horizontal") diff --git a/doc/gui/examples/charts/histogram-nbins.py b/doc/gui/examples/charts/histogram-nbins.py index 683b84b540..f4aef50a12 100644 --- a/doc/gui/examples/charts/histogram-nbins.py +++ b/doc/gui/examples/charts/histogram-nbins.py @@ -17,30 +17,29 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Random set of 100 samples - samples = {"x": [random.gauss(mu=0.0, sigma=1.0) for _ in range(100)]} - - # Use the same data for both traces - data = [samples, samples] +# Random set of 100 samples +samples = {"x": [random.gauss(mu=0.0, sigma=1.0) for _ in range(100)]} - options = [ - # First data set displayed as green-ish, and 5 bins - {"marker": {"color": "#4A4"}, "nbinsx": 5}, - # Second data set displayed as red-ish, and 25 bins - {"marker": {"color": "#A33"}, "nbinsx": 25}, - ] +# Use the same data for both traces +data = [samples, samples] - layout = { - # Overlay the two histograms - "barmode": "overlay", - # Hide the legend - "showlegend": False, - } +options = [ + # First data set displayed as green-ish, and 5 bins + {"marker": {"color": "#4A4"}, "nbinsx": 5}, + # Second data set displayed as red-ish, and 25 bins + {"marker": {"color": "#A33"}, "nbinsx": 25}, +] - page = """ -# Histogram - NBins +layout = { + # Overlay the two histograms + "barmode": "overlay", + # Hide the legend + "showlegend": False, +} +page = """ <|{data}|chart|type=histogram|options={options}|layout={layout}|> - """ - Gui(page).run() +""" + +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - NBins") diff --git a/doc/gui/examples/charts/histogram-normalized.py b/doc/gui/examples/charts/histogram-normalized.py index 198f4442a2..704134bc71 100644 --- a/doc/gui/examples/charts/histogram-normalized.py +++ b/doc/gui/examples/charts/histogram-normalized.py @@ -17,17 +17,15 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Random data set - data = [random.random() for _ in range(100)] - - # Normalize to show bin probabilities - options = {"histnorm": "probability"} +# Random data set +data = [random.random() for _ in range(100)] - page = """ -# Histogram - Normalized +# Normalize to show bin probabilities +options = {"histnorm": "probability"} +page = """ <|{data}|chart|type=histogram|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - Normalized") diff --git a/doc/gui/examples/charts/histogram-overlay.py b/doc/gui/examples/charts/histogram-overlay.py index 71fb6eec11..4dce8177ba 100644 --- a/doc/gui/examples/charts/histogram-overlay.py +++ b/doc/gui/examples/charts/histogram-overlay.py @@ -17,27 +17,27 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Data set made of two series of random numbers - data = [{"x": [random.random() + 1 for _ in range(100)]}, {"x": [random.random() + 1.1 for _ in range(100)]}] +# Data set made of two series of random numbers +data = [{"x": [random.random() + 1 for _ in range(100)]}, {"x": [random.random() + 1.1 for _ in range(100)]}] - options = [ - # First data set displayed as semi-transparent, green bars - {"opacity": 0.5, "marker": {"color": "green"}}, - # Second data set displayed as semi-transparent, gray bars - {"opacity": 0.5, "marker": {"color": "#888"}}, - ] +options = [ + # First data set displayed as semi-transparent, green bars + {"opacity": 0.5, "marker": {"color": "green"}}, + # Second data set displayed as semi-transparent, gray bars + {"opacity": 0.5, "marker": {"color": "#888"}}, +] - layout = { - # Overlay the two histograms - "barmode": "overlay", - # Hide the legend - "showlegend": False, - } +layout = { + # Overlay the two histograms + "barmode": "overlay", + # Hide the legend + "showlegend": False, +} - page = """ -# Histogram - Overlay +page = """ <|{data}|chart|type=histogram|options={options}|layout={layout}|> - """ - Gui(page).run() +""" + +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - Overlay") diff --git a/doc/gui/examples/charts/histogram-simple.py b/doc/gui/examples/charts/histogram-simple.py index 7c2d9fc37b..bec444003e 100644 --- a/doc/gui/examples/charts/histogram-simple.py +++ b/doc/gui/examples/charts/histogram-simple.py @@ -17,14 +17,12 @@ from taipy import Gui -if __name__ == "__main__": - # Random data set - data = [random.gauss(0, 5) for _ in range(1000)] - - page = """ -# Histogram - Simple +# Random data set +data = [random.gauss(0, 5) for _ in range(1000)] +page = """ <|{data}|chart|type=histogram|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - Simple") diff --git a/doc/gui/examples/charts/histogram-stacked.py b/doc/gui/examples/charts/histogram-stacked.py index 3ba9f75ec1..f350ba3e0d 100644 --- a/doc/gui/examples/charts/histogram-stacked.py +++ b/doc/gui/examples/charts/histogram-stacked.py @@ -17,22 +17,20 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Data set made of two series of random numbers - data = {"A": [random.random() for _ in range(200)], "B": [random.random() for _ in range(200)]} - - # Names of the two traces - names = ["A samples", "B samples"] +# Data set made of two series of random numbers +data = {"A": [random.random() for _ in range(200)], "B": [random.random() for _ in range(200)]} - layout = { - # Make the histogram stack the data sets - "barmode": "stack" - } +# Names of the two traces +names = ["A samples", "B samples"] - page = """ -# Histogram - Stacked +layout = { + # Make the histogram stack the data sets + "barmode": "stack" +} +page = """ <|{data}|chart|type=histogram|x[1]=A|x[2]=B|name={names}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Histogram - Stacked") diff --git a/doc/gui/examples/charts/line-style.py b/doc/gui/examples/charts/line-style.py index 2063e5b523..2c442ec0a3 100644 --- a/doc/gui/examples/charts/line-style.py +++ b/doc/gui/examples/charts/line-style.py @@ -17,1118 +17,1116 @@ from taipy.gui import Gui -if __name__ == "__main__": - dates = pandas.date_range("2023-01-01", periods=365, freq="D") - temp = [ - -11.33333333, - -6, - -0.111111111, - 1.444444444, - 2.388888889, - 4.555555556, - 4.333333333, - 0.666666667, - 9, - 9.611111111, - -0.555555556, - 1.833333333, - -0.444444444, - 2.166666667, - -4, - -12.05555556, - -2.722222222, - 5, - 9.888888889, - 6.611111111, - -2.833333333, - -3.277777778, - -1.611111111, - -1.388888889, - 5.777777778, - 2.166666667, - -1.055555556, - 1.777777778, - 1.5, - 8.444444444, - 6.222222222, - -2.5, - -0.388888889, - 6.111111111, - -1.5, - 2.666666667, - -2.5, - 0.611111111, - 8.222222222, - 2.333333333, - -9.333333333, - -7.666666667, - -6.277777778, - -0.611111111, - 7.722222222, - 6.111111111, - -4, - 3.388888889, - 9.333333333, - -6.333333333, - -15, - -12.94444444, - -8.722222222, - -6.222222222, - -2.833333333, - -2.5, - 1.5, - 3.444444444, - 2.666666667, - 0.888888889, - 7.555555556, - 12.66666667, - 12.83333333, - 1.777777778, - -0.111111111, - -1.055555556, - 4.611111111, - 11.16666667, - 8.5, - 0.5, - 2.111111111, - 4.722222222, - 8.277777778, - 10.66666667, - 5.833333333, - 5.555555556, - 6.944444444, - 1.722222222, - 2.444444444, - 6.111111111, - 12.11111111, - 15.55555556, - 9.944444444, - 10.27777778, - 5.888888889, - 1.388888889, - 3.555555556, - 1.222222222, - 4.055555556, - 7.833333333, - 0.666666667, - 10.05555556, - 6.444444444, - 4.555555556, - 11, - 3.555555556, - -0.555555556, - 11.83333333, - 7.222222222, - 10.16666667, - 17.5, - 14.55555556, - 6.777777778, - 3.611111111, - 5.888888889, - 10.05555556, - 16.61111111, - 5.5, - 7.055555556, - 10.5, - 1.555555556, - 6.166666667, - 11.05555556, - 5.111111111, - 6.055555556, - 11, - 11.05555556, - 14.72222222, - 19.16666667, - 16.5, - 12.61111111, - 8.277777778, - 6.611111111, - 10.38888889, - 15.38888889, - 17.22222222, - 18.27777778, - 18.72222222, - 17.05555556, - 19.72222222, - 16.83333333, - 12.66666667, - 11.66666667, - 12.88888889, - 14.77777778, - 18, - 19.44444444, - 16.5, - 9.722222222, - 7.888888889, - 13.72222222, - 17.55555556, - 18.27777778, - 20.11111111, - 21.66666667, - 23.38888889, - 23.5, - 16.94444444, - 16.27777778, - 18.61111111, - 20.83333333, - 24.61111111, - 18.27777778, - 17.88888889, - 22.27777778, - 25.94444444, - 25.27777778, - 24.72222222, - 25.61111111, - 23.94444444, - 26.33333333, - 22.05555556, - 20.83333333, - 24.5, - 27.83333333, - 25.61111111, - 23.11111111, - 19.27777778, - 16.44444444, - 19.44444444, - 17.22222222, - 19.44444444, - 22.16666667, - 21.77777778, - 17.38888889, - 17.22222222, - 23.88888889, - 28.44444444, - 29.44444444, - 29.61111111, - 21.05555556, - 18.55555556, - 25.27777778, - 26.55555556, - 24.55555556, - 23.38888889, - 22.55555556, - 27.05555556, - 27.66666667, - 26.66666667, - 27.61111111, - 26.66666667, - 24.77777778, - 23, - 26.5, - 23.11111111, - 19.83333333, - 22.27777778, - 24.61111111, - 27.05555556, - 27.05555556, - 27.94444444, - 27.33333333, - 22.05555556, - 21.5, - 22, - 19.72222222, - 20.27777778, - 17.88888889, - 18.55555556, - 18.94444444, - 20, - 22.05555556, - 23.22222222, - 24.38888889, - 24.5, - 24.5, - 21.22222222, - 20.83333333, - 20.61111111, - 22.05555556, - 23.77777778, - 24.16666667, - 24.22222222, - 21.83333333, - 21.33333333, - 21.88888889, - 22.44444444, - 23.11111111, - 20.44444444, - 16.88888889, - 15.77777778, - 17.44444444, - 17.72222222, - 23.11111111, - 24.55555556, - 24.88888889, - 25.11111111, - 25.27777778, - 19.5, - 19.55555556, - 24.05555556, - 24.27777778, - 21.05555556, - 19.88888889, - 20.66666667, - 20.27777778, - 17.66666667, - 16.44444444, - 15.88888889, - 18.44444444, - 22.44444444, - 23, - 24.72222222, - 24.16666667, - 25.94444444, - 24.44444444, - 23.33333333, - 25.22222222, - 25, - 23.88888889, - 23.72222222, - 18.94444444, - 16.22222222, - 19.5, - 21.22222222, - 19.72222222, - 13.22222222, - 11.88888889, - 16.55555556, - 10.05555556, - 12.16666667, - 11.5, - 10.22222222, - 17.27777778, - 21.72222222, - 13.83333333, - 13, - 6.944444444, - 6.388888889, - 4.222222222, - 2.5, - 1.111111111, - 3.055555556, - 6.388888889, - 10.44444444, - -2, - -2.222222222, - 4.388888889, - 8.333333333, - 11.11111111, - 12.66666667, - 10.88888889, - 12.83333333, - 14.16666667, - 12.55555556, - 12.05555556, - 11.22222222, - 12.44444444, - 14.38888889, - 12, - 15.83333333, - 6.722222222, - 2.5, - 4.833333333, - 7.5, - 8.888888889, - 4, - 7.388888889, - 3.888888889, - 1.611111111, - -0.333333333, - -2, - 4.833333333, - -1.055555556, - -5.611111111, - -2.388888889, - 5.722222222, - 8.444444444, - 5.277777778, - 0.5, - -2.5, - 1.111111111, - 2.111111111, - 5.777777778, - 7.555555556, - 7.555555556, - 4.111111111, - -0.388888889, - -1, - 4.944444444, - 9.444444444, - 4.722222222, - -0.166666667, - 0.5, - -2.444444444, - -2.722222222, - -2.888888889, - -1.111111111, - -4.944444444, - -3.111111111, - -1.444444444, - -0.833333333, - 2.333333333, - 6.833333333, - 4.722222222, - 0.888888889, - 0.666666667, - 4.611111111, - 4.666666667, - 4.444444444, - 6.777777778, - 5.833333333, - 0.5, - 4.888888889, - 1.444444444, - -2.111111111, - 2.444444444, - -0.111111111, - -2.555555556, - -4.611111111, - -8.666666667, - -8.055555556, - 1.555555556, - -4.777777778, - ] - min = [ - -14.33333333, - -12.9, - -3.311111111, - -4.955555556, - -3.611111111, - 0.555555556, - 1.133333333, - -5.133333333, - 2.3, - 3.911111111, - -7.055555556, - -1.366666667, - -4.844444444, - -3.333333333, - -6.1, - -17.15555556, - -4.822222222, - 0.4, - 3.488888889, - 4.211111111, - -6.433333333, - -7.577777778, - -7.111111111, - -7.088888889, - 1.577777778, - -3.433333333, - -4.355555556, - -0.722222222, - -2.1, - 2.044444444, - 2.222222222, - -4.7, - -2.388888889, - 4.111111111, - -5, - -0.133333333, - -5.3, - -2.288888889, - 6.022222222, - -1.766666667, - -15.53333333, - -13.46666667, - -9.277777778, - -3.211111111, - 3.122222222, - 1.411111111, - -6.8, - 1.388888889, - 5.333333333, - -9.833333333, - -22, - -19.74444444, - -14.62222222, - -9.622222222, - -8.433333333, - -8.5, - -2.8, - 0.144444444, - -3.233333333, - -3.411111111, - 5.355555556, - 8.366666667, - 7.333333333, - -0.322222222, - -6.911111111, - -4.955555556, - -1.588888889, - 4.966666667, - 2.5, - -4.3, - -1.888888889, - -1.777777778, - 2.477777778, - 3.766666667, - 0.533333333, - 1.755555556, - 2.944444444, - -4.977777778, - -4.055555556, - 1.711111111, - 6.011111111, - 13.15555556, - 5.044444444, - 6.577777778, - 3.388888889, - -1.011111111, - -0.244444444, - -2.477777778, - -1.444444444, - 2.533333333, - -6.333333333, - 4.255555556, - 1.944444444, - 0.855555556, - 5.4, - -1.244444444, - -2.855555556, - 4.833333333, - 2.722222222, - 6.466666667, - 14.5, - 9.855555556, - 2.277777778, - -3.188888889, - 0.788888889, - 4.155555556, - 13.41111111, - 2.3, - 0.855555556, - 8.4, - -0.444444444, - 1.166666667, - 7.755555556, - -0.288888889, - -0.244444444, - 8.7, - 5.555555556, - 8.222222222, - 16.26666667, - 14.4, - 5.711111111, - 5.177777778, - 4.511111111, - 5.988888889, - 10.08888889, - 10.52222222, - 15.37777778, - 12.42222222, - 14.95555556, - 15.22222222, - 11.93333333, - 6.866666667, - 6.866666667, - 9.688888889, - 11.57777778, - 12, - 13.34444444, - 11.3, - 6.222222222, - 2.088888889, - 8.322222222, - 14.05555556, - 13.77777778, - 16.91111111, - 16.86666667, - 16.68888889, - 18.5, - 12.54444444, - 12.27777778, - 15.91111111, - 15.03333333, - 22.11111111, - 15.77777778, - 13.68888889, - 17.87777778, - 19.94444444, - 18.57777778, - 18.62222222, - 20.11111111, - 17.14444444, - 20.43333333, - 15.75555556, - 17.33333333, - 20, - 23.03333333, - 19.61111111, - 18.51111111, - 15.27777778, - 11.44444444, - 13.64444444, - 11.42222222, - 16.14444444, - 19.76666667, - 18.77777778, - 11.88888889, - 12.32222222, - 20.78888889, - 25.04444444, - 25.34444444, - 23.81111111, - 18.35555556, - 11.85555556, - 18.37777778, - 23.15555556, - 21.55555556, - 17.48888889, - 19.05555556, - 20.25555556, - 23.86666667, - 23.86666667, - 21.41111111, - 21.16666667, - 18.67777778, - 18.1, - 24.4, - 19.01111111, - 17.13333333, - 18.27777778, - 21.71111111, - 22.85555556, - 22.65555556, - 25.14444444, - 24.13333333, - 17.95555556, - 14.7, - 15.1, - 16.02222222, - 14.27777778, - 11.18888889, - 13.65555556, - 16.74444444, - 16.7, - 17.65555556, - 16.62222222, - 21.68888889, - 19.6, - 18.6, - 15.52222222, - 18.53333333, - 17.01111111, - 17.75555556, - 20.47777778, - 17.76666667, - 22.22222222, - 18.23333333, - 17.83333333, - 15.38888889, - 19.64444444, - 17.81111111, - 15.44444444, - 14.88888889, - 13.07777778, - 15.24444444, - 11.82222222, - 20.81111111, - 21.45555556, - 18.98888889, - 19.71111111, - 19.27777778, - 12.7, - 15.05555556, - 19.15555556, - 20.77777778, - 15.35555556, - 17.68888889, - 18.26666667, - 15.47777778, - 12.76666667, - 10.54444444, - 13.38888889, - 12.54444444, - 19.84444444, - 19.5, - 21.92222222, - 17.86666667, - 22.44444444, - 19.64444444, - 20.73333333, - 22.02222222, - 19, - 20.48888889, - 19.02222222, - 16.44444444, - 14.22222222, - 16.3, - 16.42222222, - 17.22222222, - 8.322222222, - 8.288888889, - 13.95555556, - 5.555555556, - 5.666666667, - 7.7, - 4.022222222, - 11.77777778, - 16.42222222, - 11.83333333, - 9.7, - 0.044444444, - 3.688888889, - -2.077777778, - 0.1, - -5.388888889, - -3.244444444, - 0.688888889, - 5.744444444, - -7.7, - -7.022222222, - -0.211111111, - 4.833333333, - 8.111111111, - 5.766666667, - 7.888888889, - 10.43333333, - 11.56666667, - 10.15555556, - 7.155555556, - 4.522222222, - 7.144444444, - 10.88888889, - 9.5, - 12.13333333, - 4.022222222, - -3.9, - 1.433333333, - 0.7, - 3.188888889, - -1.7, - 3.588888889, - -0.111111111, - -2.788888889, - -7.133333333, - -5, - 0.733333333, - -7.555555556, - -12.51111111, - -8.188888889, - 3.122222222, - 2.944444444, - 0.477777778, - -3.2, - -9.2, - -4.788888889, - -0.288888889, - 1.077777778, - 4.755555556, - 5.455555556, - 0.511111111, - -3.888888889, - -7.4, - -1.355555556, - 5.144444444, - 0.122222222, - -5.166666667, - -5, - -5.144444444, - -8.822222222, - -6.388888889, - -6.811111111, - -8.944444444, - -10.11111111, - -7.144444444, - -5.133333333, - -1.166666667, - 1.833333333, - -1.477777778, - -1.811111111, - -2.433333333, - -1.188888889, - -2.333333333, - 0.744444444, - 1.877777778, - 1.333333333, - -1.7, - 0.888888889, - -3.855555556, - -8.211111111, - -1.055555556, - -4.211111111, - -7.355555556, - -8.111111111, - -10.96666667, - -13.05555556, - -4.644444444, - -7.577777778, - ] - max = [ - -7.233333333, - -1.6, - 5.488888889, - 7.744444444, - 6.188888889, - 6.555555556, - 10.53333333, - 6.766666667, - 14.1, - 14.11111111, - 2.044444444, - 4.633333333, - 2.055555556, - 8.666666667, - -1.4, - -5.555555556, - 4.177777778, - 11.8, - 15.58888889, - 12.31111111, - 3.666666667, - -0.977777778, - 1.288888889, - 4.211111111, - 9.377777778, - 5.266666667, - 2.144444444, - 3.977777778, - 7.2, - 11.94444444, - 11.32222222, - 4, - 6.611111111, - 8.211111111, - 3.5, - 8.866666667, - 3.6, - 3.711111111, - 13.12222222, - 7.833333333, - -3.333333333, - -2.166666667, - -2.877777778, - 5.188888889, - 13.12222222, - 12.11111111, - -0.7, - 6.688888889, - 14.03333333, - -2.433333333, - -8.6, - -8.244444444, - -2.122222222, - -2.722222222, - 1.266666667, - 2.8, - 5.7, - 6.944444444, - 5.066666667, - 5.688888889, - 13.35555556, - 16.66666667, - 17.33333333, - 7.277777778, - 6.388888889, - 1.344444444, - 9.111111111, - 17.96666667, - 12.8, - 5.8, - 6.911111111, - 6.822222222, - 11.87777778, - 13.16666667, - 9.233333333, - 8.655555556, - 10.04444444, - 7.022222222, - 7.644444444, - 8.311111111, - 16.71111111, - 18.85555556, - 12.14444444, - 13.27777778, - 11.18888889, - 7.088888889, - 8.255555556, - 7.522222222, - 9.955555556, - 9.933333333, - 4.866666667, - 15.25555556, - 9.244444444, - 9.755555556, - 14, - 8.955555556, - 2.344444444, - 17.43333333, - 12.12222222, - 13.46666667, - 23, - 18.45555556, - 12.77777778, - 7.211111111, - 8.588888889, - 14.35555556, - 19.01111111, - 12.4, - 9.155555556, - 15.6, - 4.955555556, - 8.966666667, - 16.95555556, - 9.511111111, - 10.15555556, - 16, - 14.45555556, - 21.02222222, - 25.76666667, - 20.5, - 15.71111111, - 11.67777778, - 12.81111111, - 12.88888889, - 17.58888889, - 23.12222222, - 21.77777778, - 24.42222222, - 20.05555556, - 24.32222222, - 18.83333333, - 19.56666667, - 14.96666667, - 19.68888889, - 18.57777778, - 23, - 23.34444444, - 20.7, - 11.82222222, - 11.48888889, - 17.52222222, - 22.55555556, - 20.47777778, - 23.01111111, - 27.86666667, - 30.28888889, - 30.3, - 22.94444444, - 18.57777778, - 25.51111111, - 24.13333333, - 30.01111111, - 24.77777778, - 20.28888889, - 28.67777778, - 32.74444444, - 31.37777778, - 28.52222222, - 31.81111111, - 27.24444444, - 32.53333333, - 26.15555556, - 24.63333333, - 28.3, - 31.23333333, - 32.21111111, - 28.21111111, - 23.07777778, - 21.64444444, - 24.34444444, - 19.62222222, - 25.14444444, - 24.46666667, - 23.87777778, - 21.28888889, - 20.22222222, - 29.98888889, - 32.04444444, - 36.44444444, - 36.01111111, - 24.85555556, - 23.45555556, - 29.17777778, - 32.25555556, - 28.75555556, - 30.28888889, - 28.85555556, - 30.45555556, - 31.26666667, - 28.86666667, - 33.31111111, - 30.66666667, - 28.67777778, - 27.4, - 32.2, - 25.41111111, - 22.23333333, - 26.67777778, - 30.21111111, - 29.15555556, - 29.65555556, - 31.94444444, - 31.43333333, - 28.35555556, - 24.8, - 25.5, - 25.42222222, - 24.17777778, - 20.88888889, - 24.35555556, - 25.54444444, - 22, - 27.95555556, - 29.42222222, - 28.88888889, - 26.8, - 28.2, - 26.92222222, - 24.13333333, - 22.61111111, - 26.15555556, - 30.57777778, - 30.86666667, - 29.92222222, - 27.33333333, - 23.43333333, - 24.68888889, - 26.94444444, - 28.81111111, - 25.54444444, - 22.48888889, - 21.67777778, - 19.74444444, - 23.82222222, - 25.91111111, - 30.85555556, - 28.48888889, - 29.21111111, - 28.37777778, - 22.4, - 25.55555556, - 27.35555556, - 30.67777778, - 27.95555556, - 25.98888889, - 23.46666667, - 25.37777778, - 20.46666667, - 22.54444444, - 20.18888889, - 22.24444444, - 26.84444444, - 25.8, - 29.62222222, - 26.36666667, - 32.24444444, - 29.84444444, - 28.33333333, - 31.22222222, - 29.9, - 29.98888889, - 27.42222222, - 25.54444444, - 20.22222222, - 24, - 24.52222222, - 25.02222222, - 16.12222222, - 17.58888889, - 23.25555556, - 15.75555556, - 18.66666667, - 18.4, - 12.52222222, - 20.07777778, - 28.62222222, - 17.23333333, - 16.6, - 13.34444444, - 10.98888889, - 9.522222222, - 5.8, - 6.811111111, - 6.555555556, - 12.18888889, - 12.64444444, - 4.2, - 3.577777778, - 8.888888889, - 15.23333333, - 16.11111111, - 18.36666667, - 16.98888889, - 15.63333333, - 16.46666667, - 15.55555556, - 15.65555556, - 17.42222222, - 18.74444444, - 19.48888889, - 15.9, - 19.73333333, - 13.02222222, - 8.1, - 8.933333333, - 11.3, - 12.38888889, - 8.3, - 12.38888889, - 6.388888889, - 4.211111111, - 4.666666667, - 0.7, - 7.133333333, - 2.344444444, - 1.088888889, - 0.111111111, - 11.62222222, - 10.84444444, - 8.777777778, - 3.5, - 3.4, - 7.211111111, - 5.711111111, - 9.677777778, - 12.25555556, - 10.15555556, - 6.511111111, - 4.911111111, - 1.5, - 11.44444444, - 15.54444444, - 8.122222222, - 6.233333333, - 7, - 4.355555556, - 0.277777778, - 3.711111111, - 2.888888889, - 1.555555556, - 3.888888889, - 4.555555556, - 5.666666667, - 7.833333333, - 9.833333333, - 10.02222222, - 6.288888889, - 5.366666667, - 11.41111111, - 9.566666667, - 9.744444444, - 13.57777778, - 9.433333333, - 3.1, - 11.08888889, - 3.844444444, - 2.488888889, - 7.544444444, - 4.488888889, - -0.455555556, - -2.111111111, - -3.566666667, - -1.955555556, - 3.955555556, - 1.222222222, - ] - - start = 50 - size = 100 - data = {"Date": dates[start:size], "Temp°C": temp[start:size], "Min": min[start:size], "Max": max[start:size]} +dates = pandas.date_range("2023-01-01", periods=365, freq="D") +temp = [ + -11.33333333, + -6, + -0.111111111, + 1.444444444, + 2.388888889, + 4.555555556, + 4.333333333, + 0.666666667, + 9, + 9.611111111, + -0.555555556, + 1.833333333, + -0.444444444, + 2.166666667, + -4, + -12.05555556, + -2.722222222, + 5, + 9.888888889, + 6.611111111, + -2.833333333, + -3.277777778, + -1.611111111, + -1.388888889, + 5.777777778, + 2.166666667, + -1.055555556, + 1.777777778, + 1.5, + 8.444444444, + 6.222222222, + -2.5, + -0.388888889, + 6.111111111, + -1.5, + 2.666666667, + -2.5, + 0.611111111, + 8.222222222, + 2.333333333, + -9.333333333, + -7.666666667, + -6.277777778, + -0.611111111, + 7.722222222, + 6.111111111, + -4, + 3.388888889, + 9.333333333, + -6.333333333, + -15, + -12.94444444, + -8.722222222, + -6.222222222, + -2.833333333, + -2.5, + 1.5, + 3.444444444, + 2.666666667, + 0.888888889, + 7.555555556, + 12.66666667, + 12.83333333, + 1.777777778, + -0.111111111, + -1.055555556, + 4.611111111, + 11.16666667, + 8.5, + 0.5, + 2.111111111, + 4.722222222, + 8.277777778, + 10.66666667, + 5.833333333, + 5.555555556, + 6.944444444, + 1.722222222, + 2.444444444, + 6.111111111, + 12.11111111, + 15.55555556, + 9.944444444, + 10.27777778, + 5.888888889, + 1.388888889, + 3.555555556, + 1.222222222, + 4.055555556, + 7.833333333, + 0.666666667, + 10.05555556, + 6.444444444, + 4.555555556, + 11, + 3.555555556, + -0.555555556, + 11.83333333, + 7.222222222, + 10.16666667, + 17.5, + 14.55555556, + 6.777777778, + 3.611111111, + 5.888888889, + 10.05555556, + 16.61111111, + 5.5, + 7.055555556, + 10.5, + 1.555555556, + 6.166666667, + 11.05555556, + 5.111111111, + 6.055555556, + 11, + 11.05555556, + 14.72222222, + 19.16666667, + 16.5, + 12.61111111, + 8.277777778, + 6.611111111, + 10.38888889, + 15.38888889, + 17.22222222, + 18.27777778, + 18.72222222, + 17.05555556, + 19.72222222, + 16.83333333, + 12.66666667, + 11.66666667, + 12.88888889, + 14.77777778, + 18, + 19.44444444, + 16.5, + 9.722222222, + 7.888888889, + 13.72222222, + 17.55555556, + 18.27777778, + 20.11111111, + 21.66666667, + 23.38888889, + 23.5, + 16.94444444, + 16.27777778, + 18.61111111, + 20.83333333, + 24.61111111, + 18.27777778, + 17.88888889, + 22.27777778, + 25.94444444, + 25.27777778, + 24.72222222, + 25.61111111, + 23.94444444, + 26.33333333, + 22.05555556, + 20.83333333, + 24.5, + 27.83333333, + 25.61111111, + 23.11111111, + 19.27777778, + 16.44444444, + 19.44444444, + 17.22222222, + 19.44444444, + 22.16666667, + 21.77777778, + 17.38888889, + 17.22222222, + 23.88888889, + 28.44444444, + 29.44444444, + 29.61111111, + 21.05555556, + 18.55555556, + 25.27777778, + 26.55555556, + 24.55555556, + 23.38888889, + 22.55555556, + 27.05555556, + 27.66666667, + 26.66666667, + 27.61111111, + 26.66666667, + 24.77777778, + 23, + 26.5, + 23.11111111, + 19.83333333, + 22.27777778, + 24.61111111, + 27.05555556, + 27.05555556, + 27.94444444, + 27.33333333, + 22.05555556, + 21.5, + 22, + 19.72222222, + 20.27777778, + 17.88888889, + 18.55555556, + 18.94444444, + 20, + 22.05555556, + 23.22222222, + 24.38888889, + 24.5, + 24.5, + 21.22222222, + 20.83333333, + 20.61111111, + 22.05555556, + 23.77777778, + 24.16666667, + 24.22222222, + 21.83333333, + 21.33333333, + 21.88888889, + 22.44444444, + 23.11111111, + 20.44444444, + 16.88888889, + 15.77777778, + 17.44444444, + 17.72222222, + 23.11111111, + 24.55555556, + 24.88888889, + 25.11111111, + 25.27777778, + 19.5, + 19.55555556, + 24.05555556, + 24.27777778, + 21.05555556, + 19.88888889, + 20.66666667, + 20.27777778, + 17.66666667, + 16.44444444, + 15.88888889, + 18.44444444, + 22.44444444, + 23, + 24.72222222, + 24.16666667, + 25.94444444, + 24.44444444, + 23.33333333, + 25.22222222, + 25, + 23.88888889, + 23.72222222, + 18.94444444, + 16.22222222, + 19.5, + 21.22222222, + 19.72222222, + 13.22222222, + 11.88888889, + 16.55555556, + 10.05555556, + 12.16666667, + 11.5, + 10.22222222, + 17.27777778, + 21.72222222, + 13.83333333, + 13, + 6.944444444, + 6.388888889, + 4.222222222, + 2.5, + 1.111111111, + 3.055555556, + 6.388888889, + 10.44444444, + -2, + -2.222222222, + 4.388888889, + 8.333333333, + 11.11111111, + 12.66666667, + 10.88888889, + 12.83333333, + 14.16666667, + 12.55555556, + 12.05555556, + 11.22222222, + 12.44444444, + 14.38888889, + 12, + 15.83333333, + 6.722222222, + 2.5, + 4.833333333, + 7.5, + 8.888888889, + 4, + 7.388888889, + 3.888888889, + 1.611111111, + -0.333333333, + -2, + 4.833333333, + -1.055555556, + -5.611111111, + -2.388888889, + 5.722222222, + 8.444444444, + 5.277777778, + 0.5, + -2.5, + 1.111111111, + 2.111111111, + 5.777777778, + 7.555555556, + 7.555555556, + 4.111111111, + -0.388888889, + -1, + 4.944444444, + 9.444444444, + 4.722222222, + -0.166666667, + 0.5, + -2.444444444, + -2.722222222, + -2.888888889, + -1.111111111, + -4.944444444, + -3.111111111, + -1.444444444, + -0.833333333, + 2.333333333, + 6.833333333, + 4.722222222, + 0.888888889, + 0.666666667, + 4.611111111, + 4.666666667, + 4.444444444, + 6.777777778, + 5.833333333, + 0.5, + 4.888888889, + 1.444444444, + -2.111111111, + 2.444444444, + -0.111111111, + -2.555555556, + -4.611111111, + -8.666666667, + -8.055555556, + 1.555555556, + -4.777777778, +] +min = [ + -14.33333333, + -12.9, + -3.311111111, + -4.955555556, + -3.611111111, + 0.555555556, + 1.133333333, + -5.133333333, + 2.3, + 3.911111111, + -7.055555556, + -1.366666667, + -4.844444444, + -3.333333333, + -6.1, + -17.15555556, + -4.822222222, + 0.4, + 3.488888889, + 4.211111111, + -6.433333333, + -7.577777778, + -7.111111111, + -7.088888889, + 1.577777778, + -3.433333333, + -4.355555556, + -0.722222222, + -2.1, + 2.044444444, + 2.222222222, + -4.7, + -2.388888889, + 4.111111111, + -5, + -0.133333333, + -5.3, + -2.288888889, + 6.022222222, + -1.766666667, + -15.53333333, + -13.46666667, + -9.277777778, + -3.211111111, + 3.122222222, + 1.411111111, + -6.8, + 1.388888889, + 5.333333333, + -9.833333333, + -22, + -19.74444444, + -14.62222222, + -9.622222222, + -8.433333333, + -8.5, + -2.8, + 0.144444444, + -3.233333333, + -3.411111111, + 5.355555556, + 8.366666667, + 7.333333333, + -0.322222222, + -6.911111111, + -4.955555556, + -1.588888889, + 4.966666667, + 2.5, + -4.3, + -1.888888889, + -1.777777778, + 2.477777778, + 3.766666667, + 0.533333333, + 1.755555556, + 2.944444444, + -4.977777778, + -4.055555556, + 1.711111111, + 6.011111111, + 13.15555556, + 5.044444444, + 6.577777778, + 3.388888889, + -1.011111111, + -0.244444444, + -2.477777778, + -1.444444444, + 2.533333333, + -6.333333333, + 4.255555556, + 1.944444444, + 0.855555556, + 5.4, + -1.244444444, + -2.855555556, + 4.833333333, + 2.722222222, + 6.466666667, + 14.5, + 9.855555556, + 2.277777778, + -3.188888889, + 0.788888889, + 4.155555556, + 13.41111111, + 2.3, + 0.855555556, + 8.4, + -0.444444444, + 1.166666667, + 7.755555556, + -0.288888889, + -0.244444444, + 8.7, + 5.555555556, + 8.222222222, + 16.26666667, + 14.4, + 5.711111111, + 5.177777778, + 4.511111111, + 5.988888889, + 10.08888889, + 10.52222222, + 15.37777778, + 12.42222222, + 14.95555556, + 15.22222222, + 11.93333333, + 6.866666667, + 6.866666667, + 9.688888889, + 11.57777778, + 12, + 13.34444444, + 11.3, + 6.222222222, + 2.088888889, + 8.322222222, + 14.05555556, + 13.77777778, + 16.91111111, + 16.86666667, + 16.68888889, + 18.5, + 12.54444444, + 12.27777778, + 15.91111111, + 15.03333333, + 22.11111111, + 15.77777778, + 13.68888889, + 17.87777778, + 19.94444444, + 18.57777778, + 18.62222222, + 20.11111111, + 17.14444444, + 20.43333333, + 15.75555556, + 17.33333333, + 20, + 23.03333333, + 19.61111111, + 18.51111111, + 15.27777778, + 11.44444444, + 13.64444444, + 11.42222222, + 16.14444444, + 19.76666667, + 18.77777778, + 11.88888889, + 12.32222222, + 20.78888889, + 25.04444444, + 25.34444444, + 23.81111111, + 18.35555556, + 11.85555556, + 18.37777778, + 23.15555556, + 21.55555556, + 17.48888889, + 19.05555556, + 20.25555556, + 23.86666667, + 23.86666667, + 21.41111111, + 21.16666667, + 18.67777778, + 18.1, + 24.4, + 19.01111111, + 17.13333333, + 18.27777778, + 21.71111111, + 22.85555556, + 22.65555556, + 25.14444444, + 24.13333333, + 17.95555556, + 14.7, + 15.1, + 16.02222222, + 14.27777778, + 11.18888889, + 13.65555556, + 16.74444444, + 16.7, + 17.65555556, + 16.62222222, + 21.68888889, + 19.6, + 18.6, + 15.52222222, + 18.53333333, + 17.01111111, + 17.75555556, + 20.47777778, + 17.76666667, + 22.22222222, + 18.23333333, + 17.83333333, + 15.38888889, + 19.64444444, + 17.81111111, + 15.44444444, + 14.88888889, + 13.07777778, + 15.24444444, + 11.82222222, + 20.81111111, + 21.45555556, + 18.98888889, + 19.71111111, + 19.27777778, + 12.7, + 15.05555556, + 19.15555556, + 20.77777778, + 15.35555556, + 17.68888889, + 18.26666667, + 15.47777778, + 12.76666667, + 10.54444444, + 13.38888889, + 12.54444444, + 19.84444444, + 19.5, + 21.92222222, + 17.86666667, + 22.44444444, + 19.64444444, + 20.73333333, + 22.02222222, + 19, + 20.48888889, + 19.02222222, + 16.44444444, + 14.22222222, + 16.3, + 16.42222222, + 17.22222222, + 8.322222222, + 8.288888889, + 13.95555556, + 5.555555556, + 5.666666667, + 7.7, + 4.022222222, + 11.77777778, + 16.42222222, + 11.83333333, + 9.7, + 0.044444444, + 3.688888889, + -2.077777778, + 0.1, + -5.388888889, + -3.244444444, + 0.688888889, + 5.744444444, + -7.7, + -7.022222222, + -0.211111111, + 4.833333333, + 8.111111111, + 5.766666667, + 7.888888889, + 10.43333333, + 11.56666667, + 10.15555556, + 7.155555556, + 4.522222222, + 7.144444444, + 10.88888889, + 9.5, + 12.13333333, + 4.022222222, + -3.9, + 1.433333333, + 0.7, + 3.188888889, + -1.7, + 3.588888889, + -0.111111111, + -2.788888889, + -7.133333333, + -5, + 0.733333333, + -7.555555556, + -12.51111111, + -8.188888889, + 3.122222222, + 2.944444444, + 0.477777778, + -3.2, + -9.2, + -4.788888889, + -0.288888889, + 1.077777778, + 4.755555556, + 5.455555556, + 0.511111111, + -3.888888889, + -7.4, + -1.355555556, + 5.144444444, + 0.122222222, + -5.166666667, + -5, + -5.144444444, + -8.822222222, + -6.388888889, + -6.811111111, + -8.944444444, + -10.11111111, + -7.144444444, + -5.133333333, + -1.166666667, + 1.833333333, + -1.477777778, + -1.811111111, + -2.433333333, + -1.188888889, + -2.333333333, + 0.744444444, + 1.877777778, + 1.333333333, + -1.7, + 0.888888889, + -3.855555556, + -8.211111111, + -1.055555556, + -4.211111111, + -7.355555556, + -8.111111111, + -10.96666667, + -13.05555556, + -4.644444444, + -7.577777778, +] +max = [ + -7.233333333, + -1.6, + 5.488888889, + 7.744444444, + 6.188888889, + 6.555555556, + 10.53333333, + 6.766666667, + 14.1, + 14.11111111, + 2.044444444, + 4.633333333, + 2.055555556, + 8.666666667, + -1.4, + -5.555555556, + 4.177777778, + 11.8, + 15.58888889, + 12.31111111, + 3.666666667, + -0.977777778, + 1.288888889, + 4.211111111, + 9.377777778, + 5.266666667, + 2.144444444, + 3.977777778, + 7.2, + 11.94444444, + 11.32222222, + 4, + 6.611111111, + 8.211111111, + 3.5, + 8.866666667, + 3.6, + 3.711111111, + 13.12222222, + 7.833333333, + -3.333333333, + -2.166666667, + -2.877777778, + 5.188888889, + 13.12222222, + 12.11111111, + -0.7, + 6.688888889, + 14.03333333, + -2.433333333, + -8.6, + -8.244444444, + -2.122222222, + -2.722222222, + 1.266666667, + 2.8, + 5.7, + 6.944444444, + 5.066666667, + 5.688888889, + 13.35555556, + 16.66666667, + 17.33333333, + 7.277777778, + 6.388888889, + 1.344444444, + 9.111111111, + 17.96666667, + 12.8, + 5.8, + 6.911111111, + 6.822222222, + 11.87777778, + 13.16666667, + 9.233333333, + 8.655555556, + 10.04444444, + 7.022222222, + 7.644444444, + 8.311111111, + 16.71111111, + 18.85555556, + 12.14444444, + 13.27777778, + 11.18888889, + 7.088888889, + 8.255555556, + 7.522222222, + 9.955555556, + 9.933333333, + 4.866666667, + 15.25555556, + 9.244444444, + 9.755555556, + 14, + 8.955555556, + 2.344444444, + 17.43333333, + 12.12222222, + 13.46666667, + 23, + 18.45555556, + 12.77777778, + 7.211111111, + 8.588888889, + 14.35555556, + 19.01111111, + 12.4, + 9.155555556, + 15.6, + 4.955555556, + 8.966666667, + 16.95555556, + 9.511111111, + 10.15555556, + 16, + 14.45555556, + 21.02222222, + 25.76666667, + 20.5, + 15.71111111, + 11.67777778, + 12.81111111, + 12.88888889, + 17.58888889, + 23.12222222, + 21.77777778, + 24.42222222, + 20.05555556, + 24.32222222, + 18.83333333, + 19.56666667, + 14.96666667, + 19.68888889, + 18.57777778, + 23, + 23.34444444, + 20.7, + 11.82222222, + 11.48888889, + 17.52222222, + 22.55555556, + 20.47777778, + 23.01111111, + 27.86666667, + 30.28888889, + 30.3, + 22.94444444, + 18.57777778, + 25.51111111, + 24.13333333, + 30.01111111, + 24.77777778, + 20.28888889, + 28.67777778, + 32.74444444, + 31.37777778, + 28.52222222, + 31.81111111, + 27.24444444, + 32.53333333, + 26.15555556, + 24.63333333, + 28.3, + 31.23333333, + 32.21111111, + 28.21111111, + 23.07777778, + 21.64444444, + 24.34444444, + 19.62222222, + 25.14444444, + 24.46666667, + 23.87777778, + 21.28888889, + 20.22222222, + 29.98888889, + 32.04444444, + 36.44444444, + 36.01111111, + 24.85555556, + 23.45555556, + 29.17777778, + 32.25555556, + 28.75555556, + 30.28888889, + 28.85555556, + 30.45555556, + 31.26666667, + 28.86666667, + 33.31111111, + 30.66666667, + 28.67777778, + 27.4, + 32.2, + 25.41111111, + 22.23333333, + 26.67777778, + 30.21111111, + 29.15555556, + 29.65555556, + 31.94444444, + 31.43333333, + 28.35555556, + 24.8, + 25.5, + 25.42222222, + 24.17777778, + 20.88888889, + 24.35555556, + 25.54444444, + 22, + 27.95555556, + 29.42222222, + 28.88888889, + 26.8, + 28.2, + 26.92222222, + 24.13333333, + 22.61111111, + 26.15555556, + 30.57777778, + 30.86666667, + 29.92222222, + 27.33333333, + 23.43333333, + 24.68888889, + 26.94444444, + 28.81111111, + 25.54444444, + 22.48888889, + 21.67777778, + 19.74444444, + 23.82222222, + 25.91111111, + 30.85555556, + 28.48888889, + 29.21111111, + 28.37777778, + 22.4, + 25.55555556, + 27.35555556, + 30.67777778, + 27.95555556, + 25.98888889, + 23.46666667, + 25.37777778, + 20.46666667, + 22.54444444, + 20.18888889, + 22.24444444, + 26.84444444, + 25.8, + 29.62222222, + 26.36666667, + 32.24444444, + 29.84444444, + 28.33333333, + 31.22222222, + 29.9, + 29.98888889, + 27.42222222, + 25.54444444, + 20.22222222, + 24, + 24.52222222, + 25.02222222, + 16.12222222, + 17.58888889, + 23.25555556, + 15.75555556, + 18.66666667, + 18.4, + 12.52222222, + 20.07777778, + 28.62222222, + 17.23333333, + 16.6, + 13.34444444, + 10.98888889, + 9.522222222, + 5.8, + 6.811111111, + 6.555555556, + 12.18888889, + 12.64444444, + 4.2, + 3.577777778, + 8.888888889, + 15.23333333, + 16.11111111, + 18.36666667, + 16.98888889, + 15.63333333, + 16.46666667, + 15.55555556, + 15.65555556, + 17.42222222, + 18.74444444, + 19.48888889, + 15.9, + 19.73333333, + 13.02222222, + 8.1, + 8.933333333, + 11.3, + 12.38888889, + 8.3, + 12.38888889, + 6.388888889, + 4.211111111, + 4.666666667, + 0.7, + 7.133333333, + 2.344444444, + 1.088888889, + 0.111111111, + 11.62222222, + 10.84444444, + 8.777777778, + 3.5, + 3.4, + 7.211111111, + 5.711111111, + 9.677777778, + 12.25555556, + 10.15555556, + 6.511111111, + 4.911111111, + 1.5, + 11.44444444, + 15.54444444, + 8.122222222, + 6.233333333, + 7, + 4.355555556, + 0.277777778, + 3.711111111, + 2.888888889, + 1.555555556, + 3.888888889, + 4.555555556, + 5.666666667, + 7.833333333, + 9.833333333, + 10.02222222, + 6.288888889, + 5.366666667, + 11.41111111, + 9.566666667, + 9.744444444, + 13.57777778, + 9.433333333, + 3.1, + 11.08888889, + 3.844444444, + 2.488888889, + 7.544444444, + 4.488888889, + -0.455555556, + -2.111111111, + -3.566666667, + -1.955555556, + 3.955555556, + 1.222222222, +] - page = """ -# Line - Style +start = 50 +size = 100 +data = {"Date": dates[start:size], "Temp°C": temp[start:size], "Min": min[start:size], "Max": max[start:size]} +page = """ <|{data}|chart|mode=lines|x=Date|y[1]=Temp°C|y[2]=Min|y[3]=Max|line[1]=dash|color[2]=blue|color[3]=red|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Line - Style") diff --git a/doc/gui/examples/charts/line-texts.py b/doc/gui/examples/charts/line-texts.py index a9329862ea..20872039fe 100644 --- a/doc/gui/examples/charts/line-texts.py +++ b/doc/gui/examples/charts/line-texts.py @@ -18,1124 +18,1122 @@ from taipy.gui import Gui -if __name__ == "__main__": - dates = pandas.date_range("2023-01-01", periods=365, freq="D") - temp = [ - -11.33333333, - -6, - -0.111111111, - 1.444444444, - 2.388888889, - 4.555555556, - 4.333333333, - 0.666666667, - 9, - 9.611111111, - -0.555555556, - 1.833333333, - -0.444444444, - 2.166666667, - -4, - -12.05555556, - -2.722222222, - 5, - 9.888888889, - 6.611111111, - -2.833333333, - -3.277777778, - -1.611111111, - -1.388888889, - 5.777777778, - 2.166666667, - -1.055555556, - 1.777777778, - 1.5, - 8.444444444, - 6.222222222, - -2.5, - -0.388888889, - 6.111111111, - -1.5, - 2.666666667, - -2.5, - 0.611111111, - 8.222222222, - 2.333333333, - -9.333333333, - -7.666666667, - -6.277777778, - -0.611111111, - 7.722222222, - 6.111111111, - -4, - 3.388888889, - 9.333333333, - -6.333333333, - -15, - -12.94444444, - -8.722222222, - -6.222222222, - -2.833333333, - -2.5, - 1.5, - 3.444444444, - 2.666666667, - 0.888888889, - 7.555555556, - 12.66666667, - 12.83333333, - 1.777777778, - -0.111111111, - -1.055555556, - 4.611111111, - 11.16666667, - 8.5, - 0.5, - 2.111111111, - 4.722222222, - 8.277777778, - 10.66666667, - 5.833333333, - 5.555555556, - 6.944444444, - 1.722222222, - 2.444444444, - 6.111111111, - 12.11111111, - 15.55555556, - 9.944444444, - 10.27777778, - 5.888888889, - 1.388888889, - 3.555555556, - 1.222222222, - 4.055555556, - 7.833333333, - 0.666666667, - 10.05555556, - 6.444444444, - 4.555555556, - 11, - 3.555555556, - -0.555555556, - 11.83333333, - 7.222222222, - 10.16666667, - 17.5, - 14.55555556, - 6.777777778, - 3.611111111, - 5.888888889, - 10.05555556, - 16.61111111, - 5.5, - 7.055555556, - 10.5, - 1.555555556, - 6.166666667, - 11.05555556, - 5.111111111, - 6.055555556, - 11, - 11.05555556, - 14.72222222, - 19.16666667, - 16.5, - 12.61111111, - 8.277777778, - 6.611111111, - 10.38888889, - 15.38888889, - 17.22222222, - 18.27777778, - 18.72222222, - 17.05555556, - 19.72222222, - 16.83333333, - 12.66666667, - 11.66666667, - 12.88888889, - 14.77777778, - 18, - 19.44444444, - 16.5, - 9.722222222, - 7.888888889, - 13.72222222, - 17.55555556, - 18.27777778, - 20.11111111, - 21.66666667, - 23.38888889, - 23.5, - 16.94444444, - 16.27777778, - 18.61111111, - 20.83333333, - 24.61111111, - 18.27777778, - 17.88888889, - 22.27777778, - 25.94444444, - 25.27777778, - 24.72222222, - 25.61111111, - 23.94444444, - 26.33333333, - 22.05555556, - 20.83333333, - 24.5, - 27.83333333, - 25.61111111, - 23.11111111, - 19.27777778, - 16.44444444, - 19.44444444, - 17.22222222, - 19.44444444, - 22.16666667, - 21.77777778, - 17.38888889, - 17.22222222, - 23.88888889, - 28.44444444, - 29.44444444, - 29.61111111, - 21.05555556, - 18.55555556, - 25.27777778, - 26.55555556, - 24.55555556, - 23.38888889, - 22.55555556, - 27.05555556, - 27.66666667, - 26.66666667, - 27.61111111, - 26.66666667, - 24.77777778, - 23, - 26.5, - 23.11111111, - 19.83333333, - 22.27777778, - 24.61111111, - 27.05555556, - 27.05555556, - 27.94444444, - 27.33333333, - 22.05555556, - 21.5, - 22, - 19.72222222, - 20.27777778, - 17.88888889, - 18.55555556, - 18.94444444, - 20, - 22.05555556, - 23.22222222, - 24.38888889, - 24.5, - 24.5, - 21.22222222, - 20.83333333, - 20.61111111, - 22.05555556, - 23.77777778, - 24.16666667, - 24.22222222, - 21.83333333, - 21.33333333, - 21.88888889, - 22.44444444, - 23.11111111, - 20.44444444, - 16.88888889, - 15.77777778, - 17.44444444, - 17.72222222, - 23.11111111, - 24.55555556, - 24.88888889, - 25.11111111, - 25.27777778, - 19.5, - 19.55555556, - 24.05555556, - 24.27777778, - 21.05555556, - 19.88888889, - 20.66666667, - 20.27777778, - 17.66666667, - 16.44444444, - 15.88888889, - 18.44444444, - 22.44444444, - 23, - 24.72222222, - 24.16666667, - 25.94444444, - 24.44444444, - 23.33333333, - 25.22222222, - 25, - 23.88888889, - 23.72222222, - 18.94444444, - 16.22222222, - 19.5, - 21.22222222, - 19.72222222, - 13.22222222, - 11.88888889, - 16.55555556, - 10.05555556, - 12.16666667, - 11.5, - 10.22222222, - 17.27777778, - 21.72222222, - 13.83333333, - 13, - 6.944444444, - 6.388888889, - 4.222222222, - 2.5, - 1.111111111, - 3.055555556, - 6.388888889, - 10.44444444, - -2, - -2.222222222, - 4.388888889, - 8.333333333, - 11.11111111, - 12.66666667, - 10.88888889, - 12.83333333, - 14.16666667, - 12.55555556, - 12.05555556, - 11.22222222, - 12.44444444, - 14.38888889, - 12, - 15.83333333, - 6.722222222, - 2.5, - 4.833333333, - 7.5, - 8.888888889, - 4, - 7.388888889, - 3.888888889, - 1.611111111, - -0.333333333, - -2, - 4.833333333, - -1.055555556, - -5.611111111, - -2.388888889, - 5.722222222, - 8.444444444, - 5.277777778, - 0.5, - -2.5, - 1.111111111, - 2.111111111, - 5.777777778, - 7.555555556, - 7.555555556, - 4.111111111, - -0.388888889, - -1, - 4.944444444, - 9.444444444, - 4.722222222, - -0.166666667, - 0.5, - -2.444444444, - -2.722222222, - -2.888888889, - -1.111111111, - -4.944444444, - -3.111111111, - -1.444444444, - -0.833333333, - 2.333333333, - 6.833333333, - 4.722222222, - 0.888888889, - 0.666666667, - 4.611111111, - 4.666666667, - 4.444444444, - 6.777777778, - 5.833333333, - 0.5, - 4.888888889, - 1.444444444, - -2.111111111, - 2.444444444, - -0.111111111, - -2.555555556, - -4.611111111, - -8.666666667, - -8.055555556, - 1.555555556, - -4.777777778, - ] - min = [ - -14.33333333, - -12.9, - -3.311111111, - -4.955555556, - -3.611111111, - 0.555555556, - 1.133333333, - -5.133333333, - 2.3, - 3.911111111, - -7.055555556, - -1.366666667, - -4.844444444, - -3.333333333, - -6.1, - -17.15555556, - -4.822222222, - 0.4, - 3.488888889, - 4.211111111, - -6.433333333, - -7.577777778, - -7.111111111, - -7.088888889, - 1.577777778, - -3.433333333, - -4.355555556, - -0.722222222, - -2.1, - 2.044444444, - 2.222222222, - -4.7, - -2.388888889, - 4.111111111, - -5, - -0.133333333, - -5.3, - -2.288888889, - 6.022222222, - -1.766666667, - -15.53333333, - -13.46666667, - -9.277777778, - -3.211111111, - 3.122222222, - 1.411111111, - -6.8, - 1.388888889, - 5.333333333, - -9.833333333, - -22, - -19.74444444, - -14.62222222, - -9.622222222, - -8.433333333, - -8.5, - -2.8, - 0.144444444, - -3.233333333, - -3.411111111, - 5.355555556, - 8.366666667, - 7.333333333, - -0.322222222, - -6.911111111, - -4.955555556, - -1.588888889, - 4.966666667, - 2.5, - -4.3, - -1.888888889, - -1.777777778, - 2.477777778, - 3.766666667, - 0.533333333, - 1.755555556, - 2.944444444, - -4.977777778, - -4.055555556, - 1.711111111, - 6.011111111, - 13.15555556, - 5.044444444, - 6.577777778, - 3.388888889, - -1.011111111, - -0.244444444, - -2.477777778, - -1.444444444, - 2.533333333, - -6.333333333, - 4.255555556, - 1.944444444, - 0.855555556, - 5.4, - -1.244444444, - -2.855555556, - 4.833333333, - 2.722222222, - 6.466666667, - 14.5, - 9.855555556, - 2.277777778, - -3.188888889, - 0.788888889, - 4.155555556, - 13.41111111, - 2.3, - 0.855555556, - 8.4, - -0.444444444, - 1.166666667, - 7.755555556, - -0.288888889, - -0.244444444, - 8.7, - 5.555555556, - 8.222222222, - 16.26666667, - 14.4, - 5.711111111, - 5.177777778, - 4.511111111, - 5.988888889, - 10.08888889, - 10.52222222, - 15.37777778, - 12.42222222, - 14.95555556, - 15.22222222, - 11.93333333, - 6.866666667, - 6.866666667, - 9.688888889, - 11.57777778, - 12, - 13.34444444, - 11.3, - 6.222222222, - 2.088888889, - 8.322222222, - 14.05555556, - 13.77777778, - 16.91111111, - 16.86666667, - 16.68888889, - 18.5, - 12.54444444, - 12.27777778, - 15.91111111, - 15.03333333, - 22.11111111, - 15.77777778, - 13.68888889, - 17.87777778, - 19.94444444, - 18.57777778, - 18.62222222, - 20.11111111, - 17.14444444, - 20.43333333, - 15.75555556, - 17.33333333, - 20, - 23.03333333, - 19.61111111, - 18.51111111, - 15.27777778, - 11.44444444, - 13.64444444, - 11.42222222, - 16.14444444, - 19.76666667, - 18.77777778, - 11.88888889, - 12.32222222, - 20.78888889, - 25.04444444, - 25.34444444, - 23.81111111, - 18.35555556, - 11.85555556, - 18.37777778, - 23.15555556, - 21.55555556, - 17.48888889, - 19.05555556, - 20.25555556, - 23.86666667, - 23.86666667, - 21.41111111, - 21.16666667, - 18.67777778, - 18.1, - 24.4, - 19.01111111, - 17.13333333, - 18.27777778, - 21.71111111, - 22.85555556, - 22.65555556, - 25.14444444, - 24.13333333, - 17.95555556, - 14.7, - 15.1, - 16.02222222, - 14.27777778, - 11.18888889, - 13.65555556, - 16.74444444, - 16.7, - 17.65555556, - 16.62222222, - 21.68888889, - 19.6, - 18.6, - 15.52222222, - 18.53333333, - 17.01111111, - 17.75555556, - 20.47777778, - 17.76666667, - 22.22222222, - 18.23333333, - 17.83333333, - 15.38888889, - 19.64444444, - 17.81111111, - 15.44444444, - 14.88888889, - 13.07777778, - 15.24444444, - 11.82222222, - 20.81111111, - 21.45555556, - 18.98888889, - 19.71111111, - 19.27777778, - 12.7, - 15.05555556, - 19.15555556, - 20.77777778, - 15.35555556, - 17.68888889, - 18.26666667, - 15.47777778, - 12.76666667, - 10.54444444, - 13.38888889, - 12.54444444, - 19.84444444, - 19.5, - 21.92222222, - 17.86666667, - 22.44444444, - 19.64444444, - 20.73333333, - 22.02222222, - 19, - 20.48888889, - 19.02222222, - 16.44444444, - 14.22222222, - 16.3, - 16.42222222, - 17.22222222, - 8.322222222, - 8.288888889, - 13.95555556, - 5.555555556, - 5.666666667, - 7.7, - 4.022222222, - 11.77777778, - 16.42222222, - 11.83333333, - 9.7, - 0.044444444, - 3.688888889, - -2.077777778, - 0.1, - -5.388888889, - -3.244444444, - 0.688888889, - 5.744444444, - -7.7, - -7.022222222, - -0.211111111, - 4.833333333, - 8.111111111, - 5.766666667, - 7.888888889, - 10.43333333, - 11.56666667, - 10.15555556, - 7.155555556, - 4.522222222, - 7.144444444, - 10.88888889, - 9.5, - 12.13333333, - 4.022222222, - -3.9, - 1.433333333, - 0.7, - 3.188888889, - -1.7, - 3.588888889, - -0.111111111, - -2.788888889, - -7.133333333, - -5, - 0.733333333, - -7.555555556, - -12.51111111, - -8.188888889, - 3.122222222, - 2.944444444, - 0.477777778, - -3.2, - -9.2, - -4.788888889, - -0.288888889, - 1.077777778, - 4.755555556, - 5.455555556, - 0.511111111, - -3.888888889, - -7.4, - -1.355555556, - 5.144444444, - 0.122222222, - -5.166666667, - -5, - -5.144444444, - -8.822222222, - -6.388888889, - -6.811111111, - -8.944444444, - -10.11111111, - -7.144444444, - -5.133333333, - -1.166666667, - 1.833333333, - -1.477777778, - -1.811111111, - -2.433333333, - -1.188888889, - -2.333333333, - 0.744444444, - 1.877777778, - 1.333333333, - -1.7, - 0.888888889, - -3.855555556, - -8.211111111, - -1.055555556, - -4.211111111, - -7.355555556, - -8.111111111, - -10.96666667, - -13.05555556, - -4.644444444, - -7.577777778, - ] - max = [ - -7.233333333, - -1.6, - 5.488888889, - 7.744444444, - 6.188888889, - 6.555555556, - 10.53333333, - 6.766666667, - 14.1, - 14.11111111, - 2.044444444, - 4.633333333, - 2.055555556, - 8.666666667, - -1.4, - -5.555555556, - 4.177777778, - 11.8, - 15.58888889, - 12.31111111, - 3.666666667, - -0.977777778, - 1.288888889, - 4.211111111, - 9.377777778, - 5.266666667, - 2.144444444, - 3.977777778, - 7.2, - 11.94444444, - 11.32222222, - 4, - 6.611111111, - 8.211111111, - 3.5, - 8.866666667, - 3.6, - 3.711111111, - 13.12222222, - 7.833333333, - -3.333333333, - -2.166666667, - -2.877777778, - 5.188888889, - 13.12222222, - 12.11111111, - -0.7, - 6.688888889, - 14.03333333, - -2.433333333, - -8.6, - -8.244444444, - -2.122222222, - -2.722222222, - 1.266666667, - 2.8, - 5.7, - 6.944444444, - 5.066666667, - 5.688888889, - 13.35555556, - 16.66666667, - 17.33333333, - 7.277777778, - 6.388888889, - 1.344444444, - 9.111111111, - 17.96666667, - 12.8, - 5.8, - 6.911111111, - 6.822222222, - 11.87777778, - 13.16666667, - 9.233333333, - 8.655555556, - 10.04444444, - 7.022222222, - 7.644444444, - 8.311111111, - 16.71111111, - 18.85555556, - 12.14444444, - 13.27777778, - 11.18888889, - 7.088888889, - 8.255555556, - 7.522222222, - 9.955555556, - 9.933333333, - 4.866666667, - 15.25555556, - 9.244444444, - 9.755555556, - 14, - 8.955555556, - 2.344444444, - 17.43333333, - 12.12222222, - 13.46666667, - 23, - 18.45555556, - 12.77777778, - 7.211111111, - 8.588888889, - 14.35555556, - 19.01111111, - 12.4, - 9.155555556, - 15.6, - 4.955555556, - 8.966666667, - 16.95555556, - 9.511111111, - 10.15555556, - 16, - 14.45555556, - 21.02222222, - 25.76666667, - 20.5, - 15.71111111, - 11.67777778, - 12.81111111, - 12.88888889, - 17.58888889, - 23.12222222, - 21.77777778, - 24.42222222, - 20.05555556, - 24.32222222, - 18.83333333, - 19.56666667, - 14.96666667, - 19.68888889, - 18.57777778, - 23, - 23.34444444, - 20.7, - 11.82222222, - 11.48888889, - 17.52222222, - 22.55555556, - 20.47777778, - 23.01111111, - 27.86666667, - 30.28888889, - 30.3, - 22.94444444, - 18.57777778, - 25.51111111, - 24.13333333, - 30.01111111, - 24.77777778, - 20.28888889, - 28.67777778, - 32.74444444, - 31.37777778, - 28.52222222, - 31.81111111, - 27.24444444, - 32.53333333, - 26.15555556, - 24.63333333, - 28.3, - 31.23333333, - 32.21111111, - 28.21111111, - 23.07777778, - 21.64444444, - 24.34444444, - 19.62222222, - 25.14444444, - 24.46666667, - 23.87777778, - 21.28888889, - 20.22222222, - 29.98888889, - 32.04444444, - 36.44444444, - 36.01111111, - 24.85555556, - 23.45555556, - 29.17777778, - 32.25555556, - 28.75555556, - 30.28888889, - 28.85555556, - 30.45555556, - 31.26666667, - 28.86666667, - 33.31111111, - 30.66666667, - 28.67777778, - 27.4, - 32.2, - 25.41111111, - 22.23333333, - 26.67777778, - 30.21111111, - 29.15555556, - 29.65555556, - 31.94444444, - 31.43333333, - 28.35555556, - 24.8, - 25.5, - 25.42222222, - 24.17777778, - 20.88888889, - 24.35555556, - 25.54444444, - 22, - 27.95555556, - 29.42222222, - 28.88888889, - 26.8, - 28.2, - 26.92222222, - 24.13333333, - 22.61111111, - 26.15555556, - 30.57777778, - 30.86666667, - 29.92222222, - 27.33333333, - 23.43333333, - 24.68888889, - 26.94444444, - 28.81111111, - 25.54444444, - 22.48888889, - 21.67777778, - 19.74444444, - 23.82222222, - 25.91111111, - 30.85555556, - 28.48888889, - 29.21111111, - 28.37777778, - 22.4, - 25.55555556, - 27.35555556, - 30.67777778, - 27.95555556, - 25.98888889, - 23.46666667, - 25.37777778, - 20.46666667, - 22.54444444, - 20.18888889, - 22.24444444, - 26.84444444, - 25.8, - 29.62222222, - 26.36666667, - 32.24444444, - 29.84444444, - 28.33333333, - 31.22222222, - 29.9, - 29.98888889, - 27.42222222, - 25.54444444, - 20.22222222, - 24, - 24.52222222, - 25.02222222, - 16.12222222, - 17.58888889, - 23.25555556, - 15.75555556, - 18.66666667, - 18.4, - 12.52222222, - 20.07777778, - 28.62222222, - 17.23333333, - 16.6, - 13.34444444, - 10.98888889, - 9.522222222, - 5.8, - 6.811111111, - 6.555555556, - 12.18888889, - 12.64444444, - 4.2, - 3.577777778, - 8.888888889, - 15.23333333, - 16.11111111, - 18.36666667, - 16.98888889, - 15.63333333, - 16.46666667, - 15.55555556, - 15.65555556, - 17.42222222, - 18.74444444, - 19.48888889, - 15.9, - 19.73333333, - 13.02222222, - 8.1, - 8.933333333, - 11.3, - 12.38888889, - 8.3, - 12.38888889, - 6.388888889, - 4.211111111, - 4.666666667, - 0.7, - 7.133333333, - 2.344444444, - 1.088888889, - 0.111111111, - 11.62222222, - 10.84444444, - 8.777777778, - 3.5, - 3.4, - 7.211111111, - 5.711111111, - 9.677777778, - 12.25555556, - 10.15555556, - 6.511111111, - 4.911111111, - 1.5, - 11.44444444, - 15.54444444, - 8.122222222, - 6.233333333, - 7, - 4.355555556, - 0.277777778, - 3.711111111, - 2.888888889, - 1.555555556, - 3.888888889, - 4.555555556, - 5.666666667, - 7.833333333, - 9.833333333, - 10.02222222, - 6.288888889, - 5.366666667, - 11.41111111, - 9.566666667, - 9.744444444, - 13.57777778, - 9.433333333, - 3.1, - 11.08888889, - 3.844444444, - 2.488888889, - 7.544444444, - 4.488888889, - -0.455555556, - -2.111111111, - -3.566666667, - -1.955555556, - 3.955555556, - 1.222222222, - ] - week_number = [f"W{i//7}" if i % 7 == 0 else None for i in range(0, 365)] - - start = 50 - size = 100 - data = { - "Date": dates[start:size], - "Temp°C": temp[start:size], - "Week": numpy.array(max[start:size]) + 5, - "WeekN": week_number[start:size], - } +dates = pandas.date_range("2023-01-01", periods=365, freq="D") +temp = [ + -11.33333333, + -6, + -0.111111111, + 1.444444444, + 2.388888889, + 4.555555556, + 4.333333333, + 0.666666667, + 9, + 9.611111111, + -0.555555556, + 1.833333333, + -0.444444444, + 2.166666667, + -4, + -12.05555556, + -2.722222222, + 5, + 9.888888889, + 6.611111111, + -2.833333333, + -3.277777778, + -1.611111111, + -1.388888889, + 5.777777778, + 2.166666667, + -1.055555556, + 1.777777778, + 1.5, + 8.444444444, + 6.222222222, + -2.5, + -0.388888889, + 6.111111111, + -1.5, + 2.666666667, + -2.5, + 0.611111111, + 8.222222222, + 2.333333333, + -9.333333333, + -7.666666667, + -6.277777778, + -0.611111111, + 7.722222222, + 6.111111111, + -4, + 3.388888889, + 9.333333333, + -6.333333333, + -15, + -12.94444444, + -8.722222222, + -6.222222222, + -2.833333333, + -2.5, + 1.5, + 3.444444444, + 2.666666667, + 0.888888889, + 7.555555556, + 12.66666667, + 12.83333333, + 1.777777778, + -0.111111111, + -1.055555556, + 4.611111111, + 11.16666667, + 8.5, + 0.5, + 2.111111111, + 4.722222222, + 8.277777778, + 10.66666667, + 5.833333333, + 5.555555556, + 6.944444444, + 1.722222222, + 2.444444444, + 6.111111111, + 12.11111111, + 15.55555556, + 9.944444444, + 10.27777778, + 5.888888889, + 1.388888889, + 3.555555556, + 1.222222222, + 4.055555556, + 7.833333333, + 0.666666667, + 10.05555556, + 6.444444444, + 4.555555556, + 11, + 3.555555556, + -0.555555556, + 11.83333333, + 7.222222222, + 10.16666667, + 17.5, + 14.55555556, + 6.777777778, + 3.611111111, + 5.888888889, + 10.05555556, + 16.61111111, + 5.5, + 7.055555556, + 10.5, + 1.555555556, + 6.166666667, + 11.05555556, + 5.111111111, + 6.055555556, + 11, + 11.05555556, + 14.72222222, + 19.16666667, + 16.5, + 12.61111111, + 8.277777778, + 6.611111111, + 10.38888889, + 15.38888889, + 17.22222222, + 18.27777778, + 18.72222222, + 17.05555556, + 19.72222222, + 16.83333333, + 12.66666667, + 11.66666667, + 12.88888889, + 14.77777778, + 18, + 19.44444444, + 16.5, + 9.722222222, + 7.888888889, + 13.72222222, + 17.55555556, + 18.27777778, + 20.11111111, + 21.66666667, + 23.38888889, + 23.5, + 16.94444444, + 16.27777778, + 18.61111111, + 20.83333333, + 24.61111111, + 18.27777778, + 17.88888889, + 22.27777778, + 25.94444444, + 25.27777778, + 24.72222222, + 25.61111111, + 23.94444444, + 26.33333333, + 22.05555556, + 20.83333333, + 24.5, + 27.83333333, + 25.61111111, + 23.11111111, + 19.27777778, + 16.44444444, + 19.44444444, + 17.22222222, + 19.44444444, + 22.16666667, + 21.77777778, + 17.38888889, + 17.22222222, + 23.88888889, + 28.44444444, + 29.44444444, + 29.61111111, + 21.05555556, + 18.55555556, + 25.27777778, + 26.55555556, + 24.55555556, + 23.38888889, + 22.55555556, + 27.05555556, + 27.66666667, + 26.66666667, + 27.61111111, + 26.66666667, + 24.77777778, + 23, + 26.5, + 23.11111111, + 19.83333333, + 22.27777778, + 24.61111111, + 27.05555556, + 27.05555556, + 27.94444444, + 27.33333333, + 22.05555556, + 21.5, + 22, + 19.72222222, + 20.27777778, + 17.88888889, + 18.55555556, + 18.94444444, + 20, + 22.05555556, + 23.22222222, + 24.38888889, + 24.5, + 24.5, + 21.22222222, + 20.83333333, + 20.61111111, + 22.05555556, + 23.77777778, + 24.16666667, + 24.22222222, + 21.83333333, + 21.33333333, + 21.88888889, + 22.44444444, + 23.11111111, + 20.44444444, + 16.88888889, + 15.77777778, + 17.44444444, + 17.72222222, + 23.11111111, + 24.55555556, + 24.88888889, + 25.11111111, + 25.27777778, + 19.5, + 19.55555556, + 24.05555556, + 24.27777778, + 21.05555556, + 19.88888889, + 20.66666667, + 20.27777778, + 17.66666667, + 16.44444444, + 15.88888889, + 18.44444444, + 22.44444444, + 23, + 24.72222222, + 24.16666667, + 25.94444444, + 24.44444444, + 23.33333333, + 25.22222222, + 25, + 23.88888889, + 23.72222222, + 18.94444444, + 16.22222222, + 19.5, + 21.22222222, + 19.72222222, + 13.22222222, + 11.88888889, + 16.55555556, + 10.05555556, + 12.16666667, + 11.5, + 10.22222222, + 17.27777778, + 21.72222222, + 13.83333333, + 13, + 6.944444444, + 6.388888889, + 4.222222222, + 2.5, + 1.111111111, + 3.055555556, + 6.388888889, + 10.44444444, + -2, + -2.222222222, + 4.388888889, + 8.333333333, + 11.11111111, + 12.66666667, + 10.88888889, + 12.83333333, + 14.16666667, + 12.55555556, + 12.05555556, + 11.22222222, + 12.44444444, + 14.38888889, + 12, + 15.83333333, + 6.722222222, + 2.5, + 4.833333333, + 7.5, + 8.888888889, + 4, + 7.388888889, + 3.888888889, + 1.611111111, + -0.333333333, + -2, + 4.833333333, + -1.055555556, + -5.611111111, + -2.388888889, + 5.722222222, + 8.444444444, + 5.277777778, + 0.5, + -2.5, + 1.111111111, + 2.111111111, + 5.777777778, + 7.555555556, + 7.555555556, + 4.111111111, + -0.388888889, + -1, + 4.944444444, + 9.444444444, + 4.722222222, + -0.166666667, + 0.5, + -2.444444444, + -2.722222222, + -2.888888889, + -1.111111111, + -4.944444444, + -3.111111111, + -1.444444444, + -0.833333333, + 2.333333333, + 6.833333333, + 4.722222222, + 0.888888889, + 0.666666667, + 4.611111111, + 4.666666667, + 4.444444444, + 6.777777778, + 5.833333333, + 0.5, + 4.888888889, + 1.444444444, + -2.111111111, + 2.444444444, + -0.111111111, + -2.555555556, + -4.611111111, + -8.666666667, + -8.055555556, + 1.555555556, + -4.777777778, +] +min = [ + -14.33333333, + -12.9, + -3.311111111, + -4.955555556, + -3.611111111, + 0.555555556, + 1.133333333, + -5.133333333, + 2.3, + 3.911111111, + -7.055555556, + -1.366666667, + -4.844444444, + -3.333333333, + -6.1, + -17.15555556, + -4.822222222, + 0.4, + 3.488888889, + 4.211111111, + -6.433333333, + -7.577777778, + -7.111111111, + -7.088888889, + 1.577777778, + -3.433333333, + -4.355555556, + -0.722222222, + -2.1, + 2.044444444, + 2.222222222, + -4.7, + -2.388888889, + 4.111111111, + -5, + -0.133333333, + -5.3, + -2.288888889, + 6.022222222, + -1.766666667, + -15.53333333, + -13.46666667, + -9.277777778, + -3.211111111, + 3.122222222, + 1.411111111, + -6.8, + 1.388888889, + 5.333333333, + -9.833333333, + -22, + -19.74444444, + -14.62222222, + -9.622222222, + -8.433333333, + -8.5, + -2.8, + 0.144444444, + -3.233333333, + -3.411111111, + 5.355555556, + 8.366666667, + 7.333333333, + -0.322222222, + -6.911111111, + -4.955555556, + -1.588888889, + 4.966666667, + 2.5, + -4.3, + -1.888888889, + -1.777777778, + 2.477777778, + 3.766666667, + 0.533333333, + 1.755555556, + 2.944444444, + -4.977777778, + -4.055555556, + 1.711111111, + 6.011111111, + 13.15555556, + 5.044444444, + 6.577777778, + 3.388888889, + -1.011111111, + -0.244444444, + -2.477777778, + -1.444444444, + 2.533333333, + -6.333333333, + 4.255555556, + 1.944444444, + 0.855555556, + 5.4, + -1.244444444, + -2.855555556, + 4.833333333, + 2.722222222, + 6.466666667, + 14.5, + 9.855555556, + 2.277777778, + -3.188888889, + 0.788888889, + 4.155555556, + 13.41111111, + 2.3, + 0.855555556, + 8.4, + -0.444444444, + 1.166666667, + 7.755555556, + -0.288888889, + -0.244444444, + 8.7, + 5.555555556, + 8.222222222, + 16.26666667, + 14.4, + 5.711111111, + 5.177777778, + 4.511111111, + 5.988888889, + 10.08888889, + 10.52222222, + 15.37777778, + 12.42222222, + 14.95555556, + 15.22222222, + 11.93333333, + 6.866666667, + 6.866666667, + 9.688888889, + 11.57777778, + 12, + 13.34444444, + 11.3, + 6.222222222, + 2.088888889, + 8.322222222, + 14.05555556, + 13.77777778, + 16.91111111, + 16.86666667, + 16.68888889, + 18.5, + 12.54444444, + 12.27777778, + 15.91111111, + 15.03333333, + 22.11111111, + 15.77777778, + 13.68888889, + 17.87777778, + 19.94444444, + 18.57777778, + 18.62222222, + 20.11111111, + 17.14444444, + 20.43333333, + 15.75555556, + 17.33333333, + 20, + 23.03333333, + 19.61111111, + 18.51111111, + 15.27777778, + 11.44444444, + 13.64444444, + 11.42222222, + 16.14444444, + 19.76666667, + 18.77777778, + 11.88888889, + 12.32222222, + 20.78888889, + 25.04444444, + 25.34444444, + 23.81111111, + 18.35555556, + 11.85555556, + 18.37777778, + 23.15555556, + 21.55555556, + 17.48888889, + 19.05555556, + 20.25555556, + 23.86666667, + 23.86666667, + 21.41111111, + 21.16666667, + 18.67777778, + 18.1, + 24.4, + 19.01111111, + 17.13333333, + 18.27777778, + 21.71111111, + 22.85555556, + 22.65555556, + 25.14444444, + 24.13333333, + 17.95555556, + 14.7, + 15.1, + 16.02222222, + 14.27777778, + 11.18888889, + 13.65555556, + 16.74444444, + 16.7, + 17.65555556, + 16.62222222, + 21.68888889, + 19.6, + 18.6, + 15.52222222, + 18.53333333, + 17.01111111, + 17.75555556, + 20.47777778, + 17.76666667, + 22.22222222, + 18.23333333, + 17.83333333, + 15.38888889, + 19.64444444, + 17.81111111, + 15.44444444, + 14.88888889, + 13.07777778, + 15.24444444, + 11.82222222, + 20.81111111, + 21.45555556, + 18.98888889, + 19.71111111, + 19.27777778, + 12.7, + 15.05555556, + 19.15555556, + 20.77777778, + 15.35555556, + 17.68888889, + 18.26666667, + 15.47777778, + 12.76666667, + 10.54444444, + 13.38888889, + 12.54444444, + 19.84444444, + 19.5, + 21.92222222, + 17.86666667, + 22.44444444, + 19.64444444, + 20.73333333, + 22.02222222, + 19, + 20.48888889, + 19.02222222, + 16.44444444, + 14.22222222, + 16.3, + 16.42222222, + 17.22222222, + 8.322222222, + 8.288888889, + 13.95555556, + 5.555555556, + 5.666666667, + 7.7, + 4.022222222, + 11.77777778, + 16.42222222, + 11.83333333, + 9.7, + 0.044444444, + 3.688888889, + -2.077777778, + 0.1, + -5.388888889, + -3.244444444, + 0.688888889, + 5.744444444, + -7.7, + -7.022222222, + -0.211111111, + 4.833333333, + 8.111111111, + 5.766666667, + 7.888888889, + 10.43333333, + 11.56666667, + 10.15555556, + 7.155555556, + 4.522222222, + 7.144444444, + 10.88888889, + 9.5, + 12.13333333, + 4.022222222, + -3.9, + 1.433333333, + 0.7, + 3.188888889, + -1.7, + 3.588888889, + -0.111111111, + -2.788888889, + -7.133333333, + -5, + 0.733333333, + -7.555555556, + -12.51111111, + -8.188888889, + 3.122222222, + 2.944444444, + 0.477777778, + -3.2, + -9.2, + -4.788888889, + -0.288888889, + 1.077777778, + 4.755555556, + 5.455555556, + 0.511111111, + -3.888888889, + -7.4, + -1.355555556, + 5.144444444, + 0.122222222, + -5.166666667, + -5, + -5.144444444, + -8.822222222, + -6.388888889, + -6.811111111, + -8.944444444, + -10.11111111, + -7.144444444, + -5.133333333, + -1.166666667, + 1.833333333, + -1.477777778, + -1.811111111, + -2.433333333, + -1.188888889, + -2.333333333, + 0.744444444, + 1.877777778, + 1.333333333, + -1.7, + 0.888888889, + -3.855555556, + -8.211111111, + -1.055555556, + -4.211111111, + -7.355555556, + -8.111111111, + -10.96666667, + -13.05555556, + -4.644444444, + -7.577777778, +] +max = [ + -7.233333333, + -1.6, + 5.488888889, + 7.744444444, + 6.188888889, + 6.555555556, + 10.53333333, + 6.766666667, + 14.1, + 14.11111111, + 2.044444444, + 4.633333333, + 2.055555556, + 8.666666667, + -1.4, + -5.555555556, + 4.177777778, + 11.8, + 15.58888889, + 12.31111111, + 3.666666667, + -0.977777778, + 1.288888889, + 4.211111111, + 9.377777778, + 5.266666667, + 2.144444444, + 3.977777778, + 7.2, + 11.94444444, + 11.32222222, + 4, + 6.611111111, + 8.211111111, + 3.5, + 8.866666667, + 3.6, + 3.711111111, + 13.12222222, + 7.833333333, + -3.333333333, + -2.166666667, + -2.877777778, + 5.188888889, + 13.12222222, + 12.11111111, + -0.7, + 6.688888889, + 14.03333333, + -2.433333333, + -8.6, + -8.244444444, + -2.122222222, + -2.722222222, + 1.266666667, + 2.8, + 5.7, + 6.944444444, + 5.066666667, + 5.688888889, + 13.35555556, + 16.66666667, + 17.33333333, + 7.277777778, + 6.388888889, + 1.344444444, + 9.111111111, + 17.96666667, + 12.8, + 5.8, + 6.911111111, + 6.822222222, + 11.87777778, + 13.16666667, + 9.233333333, + 8.655555556, + 10.04444444, + 7.022222222, + 7.644444444, + 8.311111111, + 16.71111111, + 18.85555556, + 12.14444444, + 13.27777778, + 11.18888889, + 7.088888889, + 8.255555556, + 7.522222222, + 9.955555556, + 9.933333333, + 4.866666667, + 15.25555556, + 9.244444444, + 9.755555556, + 14, + 8.955555556, + 2.344444444, + 17.43333333, + 12.12222222, + 13.46666667, + 23, + 18.45555556, + 12.77777778, + 7.211111111, + 8.588888889, + 14.35555556, + 19.01111111, + 12.4, + 9.155555556, + 15.6, + 4.955555556, + 8.966666667, + 16.95555556, + 9.511111111, + 10.15555556, + 16, + 14.45555556, + 21.02222222, + 25.76666667, + 20.5, + 15.71111111, + 11.67777778, + 12.81111111, + 12.88888889, + 17.58888889, + 23.12222222, + 21.77777778, + 24.42222222, + 20.05555556, + 24.32222222, + 18.83333333, + 19.56666667, + 14.96666667, + 19.68888889, + 18.57777778, + 23, + 23.34444444, + 20.7, + 11.82222222, + 11.48888889, + 17.52222222, + 22.55555556, + 20.47777778, + 23.01111111, + 27.86666667, + 30.28888889, + 30.3, + 22.94444444, + 18.57777778, + 25.51111111, + 24.13333333, + 30.01111111, + 24.77777778, + 20.28888889, + 28.67777778, + 32.74444444, + 31.37777778, + 28.52222222, + 31.81111111, + 27.24444444, + 32.53333333, + 26.15555556, + 24.63333333, + 28.3, + 31.23333333, + 32.21111111, + 28.21111111, + 23.07777778, + 21.64444444, + 24.34444444, + 19.62222222, + 25.14444444, + 24.46666667, + 23.87777778, + 21.28888889, + 20.22222222, + 29.98888889, + 32.04444444, + 36.44444444, + 36.01111111, + 24.85555556, + 23.45555556, + 29.17777778, + 32.25555556, + 28.75555556, + 30.28888889, + 28.85555556, + 30.45555556, + 31.26666667, + 28.86666667, + 33.31111111, + 30.66666667, + 28.67777778, + 27.4, + 32.2, + 25.41111111, + 22.23333333, + 26.67777778, + 30.21111111, + 29.15555556, + 29.65555556, + 31.94444444, + 31.43333333, + 28.35555556, + 24.8, + 25.5, + 25.42222222, + 24.17777778, + 20.88888889, + 24.35555556, + 25.54444444, + 22, + 27.95555556, + 29.42222222, + 28.88888889, + 26.8, + 28.2, + 26.92222222, + 24.13333333, + 22.61111111, + 26.15555556, + 30.57777778, + 30.86666667, + 29.92222222, + 27.33333333, + 23.43333333, + 24.68888889, + 26.94444444, + 28.81111111, + 25.54444444, + 22.48888889, + 21.67777778, + 19.74444444, + 23.82222222, + 25.91111111, + 30.85555556, + 28.48888889, + 29.21111111, + 28.37777778, + 22.4, + 25.55555556, + 27.35555556, + 30.67777778, + 27.95555556, + 25.98888889, + 23.46666667, + 25.37777778, + 20.46666667, + 22.54444444, + 20.18888889, + 22.24444444, + 26.84444444, + 25.8, + 29.62222222, + 26.36666667, + 32.24444444, + 29.84444444, + 28.33333333, + 31.22222222, + 29.9, + 29.98888889, + 27.42222222, + 25.54444444, + 20.22222222, + 24, + 24.52222222, + 25.02222222, + 16.12222222, + 17.58888889, + 23.25555556, + 15.75555556, + 18.66666667, + 18.4, + 12.52222222, + 20.07777778, + 28.62222222, + 17.23333333, + 16.6, + 13.34444444, + 10.98888889, + 9.522222222, + 5.8, + 6.811111111, + 6.555555556, + 12.18888889, + 12.64444444, + 4.2, + 3.577777778, + 8.888888889, + 15.23333333, + 16.11111111, + 18.36666667, + 16.98888889, + 15.63333333, + 16.46666667, + 15.55555556, + 15.65555556, + 17.42222222, + 18.74444444, + 19.48888889, + 15.9, + 19.73333333, + 13.02222222, + 8.1, + 8.933333333, + 11.3, + 12.38888889, + 8.3, + 12.38888889, + 6.388888889, + 4.211111111, + 4.666666667, + 0.7, + 7.133333333, + 2.344444444, + 1.088888889, + 0.111111111, + 11.62222222, + 10.84444444, + 8.777777778, + 3.5, + 3.4, + 7.211111111, + 5.711111111, + 9.677777778, + 12.25555556, + 10.15555556, + 6.511111111, + 4.911111111, + 1.5, + 11.44444444, + 15.54444444, + 8.122222222, + 6.233333333, + 7, + 4.355555556, + 0.277777778, + 3.711111111, + 2.888888889, + 1.555555556, + 3.888888889, + 4.555555556, + 5.666666667, + 7.833333333, + 9.833333333, + 10.02222222, + 6.288888889, + 5.366666667, + 11.41111111, + 9.566666667, + 9.744444444, + 13.57777778, + 9.433333333, + 3.1, + 11.08888889, + 3.844444444, + 2.488888889, + 7.544444444, + 4.488888889, + -0.455555556, + -2.111111111, + -3.566666667, + -1.955555556, + 3.955555556, + 1.222222222, +] +week_number = [f"W{i//7}" if i % 7 == 0 else None for i in range(0, 365)] - page = """ -# Line - Texts +start = 50 +size = 100 +data = { + "Date": dates[start:size], + "Temp°C": temp[start:size], + "Week": numpy.array(max[start:size]) + 5, + "WeekN": week_number[start:size], +} +page = """ <|{data}|chart|x=Date|y[1]=Temp°C|y[2]=Week|mode[2]=text|text[2]=WeekN|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Line - Texts") diff --git a/doc/gui/examples/charts/map-bubbles.py b/doc/gui/examples/charts/map-bubbles.py index 491dbebb50..8506d66f61 100644 --- a/doc/gui/examples/charts/map-bubbles.py +++ b/doc/gui/examples/charts/map-bubbles.py @@ -18,136 +18,134 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Largest cities: name, location and population - # Source: https://simplemaps.com/data/world-cities - cities = [ - {"name": "Tokyo", "lat": 35.6839, "lon": 139.7744, "population": 39105000}, - {"name": "Jakarta", "lat": -6.2146, "lon": 106.8451, "population": 35362000}, - {"name": "Delhi", "lat": 28.6667, "lon": 77.2167, "population": 31870000}, - {"name": "Manila", "lat": 14.6, "lon": 120.9833, "population": 23971000}, - {"name": "São Paulo", "lat": -23.5504, "lon": -46.6339, "population": 22495000}, - {"name": "Seoul", "lat": 37.56, "lon": 126.99, "population": 22394000}, - {"name": "Mumbai", "lat": 19.0758, "lon": 72.8775, "population": 22186000}, - {"name": "Shanghai", "lat": 31.1667, "lon": 121.4667, "population": 22118000}, - {"name": "Mexico City", "lat": 19.4333, "lon": -99.1333, "population": 21505000}, - {"name": "Guangzhou", "lat": 23.1288, "lon": 113.259, "population": 21489000}, - {"name": "Cairo", "lat": 30.0444, "lon": 31.2358, "population": 19787000}, - {"name": "Beijing", "lat": 39.904, "lon": 116.4075, "population": 19437000}, - {"name": "New York", "lat": 40.6943, "lon": -73.9249, "population": 18713220}, - {"name": "Kolkāta", "lat": 22.5727, "lon": 88.3639, "population": 18698000}, - {"name": "Moscow", "lat": 55.7558, "lon": 37.6178, "population": 17693000}, - {"name": "Bangkok", "lat": 13.75, "lon": 100.5167, "population": 17573000}, - {"name": "Dhaka", "lat": 23.7289, "lon": 90.3944, "population": 16839000}, - {"name": "Buenos Aires", "lat": -34.5997, "lon": -58.3819, "population": 16216000}, - {"name": "Ōsaka", "lat": 34.752, "lon": 135.4582, "population": 15490000}, - {"name": "Lagos", "lat": 6.45, "lon": 3.4, "population": 15487000}, - {"name": "Istanbul", "lat": 41.01, "lon": 28.9603, "population": 15311000}, - {"name": "Karachi", "lat": 24.86, "lon": 67.01, "population": 15292000}, - {"name": "Kinshasa", "lat": -4.3317, "lon": 15.3139, "population": 15056000}, - {"name": "Shenzhen", "lat": 22.535, "lon": 114.054, "population": 14678000}, - {"name": "Bangalore", "lat": 12.9791, "lon": 77.5913, "population": 13999000}, - {"name": "Ho Chi Minh City", "lat": 10.8167, "lon": 106.6333, "population": 13954000}, - {"name": "Tehran", "lat": 35.7, "lon": 51.4167, "population": 13819000}, - {"name": "Los Angeles", "lat": 34.1139, "lon": -118.4068, "population": 12750807}, - {"name": "Rio de Janeiro", "lat": -22.9083, "lon": -43.1964, "population": 12486000}, - {"name": "Chengdu", "lat": 30.66, "lon": 104.0633, "population": 11920000}, - {"name": "Baoding", "lat": 38.8671, "lon": 115.4845, "population": 11860000}, - {"name": "Chennai", "lat": 13.0825, "lon": 80.275, "population": 11564000}, - {"name": "Lahore", "lat": 31.5497, "lon": 74.3436, "population": 11148000}, - {"name": "London", "lat": 51.5072, "lon": -0.1275, "population": 11120000}, - {"name": "Paris", "lat": 48.8566, "lon": 2.3522, "population": 11027000}, - {"name": "Tianjin", "lat": 39.1467, "lon": 117.2056, "population": 10932000}, - {"name": "Linyi", "lat": 35.0606, "lon": 118.3425, "population": 10820000}, - {"name": "Shijiazhuang", "lat": 38.0422, "lon": 114.5086, "population": 10784600}, - {"name": "Zhengzhou", "lat": 34.7492, "lon": 113.6605, "population": 10136000}, - {"name": "Nanyang", "lat": 32.9987, "lon": 112.5292, "population": 10013600}, - {"name": "Hyderābād", "lat": 17.3617, "lon": 78.4747, "population": 9840000}, - {"name": "Wuhan", "lat": 30.5872, "lon": 114.2881, "population": 9729000}, - {"name": "Handan", "lat": 36.6116, "lon": 114.4894, "population": 9549700}, - {"name": "Nagoya", "lat": 35.1167, "lon": 136.9333, "population": 9522000}, - {"name": "Weifang", "lat": 36.7167, "lon": 119.1, "population": 9373000}, - {"name": "Lima", "lat": -12.06, "lon": -77.0375, "population": 8992000}, - {"name": "Zhoukou", "lat": 33.625, "lon": 114.6418, "population": 8953172}, - {"name": "Luanda", "lat": -8.8383, "lon": 13.2344, "population": 8883000}, - {"name": "Ganzhou", "lat": 25.8292, "lon": 114.9336, "population": 8677600}, - {"name": "Tongshan", "lat": 34.261, "lon": 117.1859, "population": 8669000}, - {"name": "Kuala Lumpur", "lat": 3.1478, "lon": 101.6953, "population": 8639000}, - {"name": "Chicago", "lat": 41.8373, "lon": -87.6862, "population": 8604203}, - {"name": "Heze", "lat": 35.2333, "lon": 115.4333, "population": 8287693}, - {"name": "Chongqing", "lat": 29.55, "lon": 106.5069, "population": 8261000}, - {"name": "Hanoi", "lat": 21.0245, "lon": 105.8412, "population": 8246600}, - {"name": "Fuyang", "lat": 32.8986, "lon": 115.8045, "population": 8200264}, - {"name": "Changsha", "lat": 28.1987, "lon": 112.9709, "population": 8154700}, - {"name": "Dongguan", "lat": 23.0475, "lon": 113.7493, "population": 8142000}, - {"name": "Jining", "lat": 35.4, "lon": 116.5667, "population": 8081905}, - {"name": "Jinan", "lat": 36.6667, "lon": 116.9833, "population": 7967400}, - {"name": "Pune", "lat": 18.5196, "lon": 73.8553, "population": 7948000}, - {"name": "Foshan", "lat": 23.0292, "lon": 113.1056, "population": 7905700}, - {"name": "Bogotá", "lat": 4.6126, "lon": -74.0705, "population": 7743955}, - {"name": "Ahmedabad", "lat": 23.03, "lon": 72.58, "population": 7717000}, - {"name": "Nanjing", "lat": 32.05, "lon": 118.7667, "population": 7729000}, - {"name": "Changchun", "lat": 43.9, "lon": 125.2, "population": 7674439}, - {"name": "Tangshan", "lat": 39.6292, "lon": 118.1742, "population": 7577289}, - {"name": "Cangzhou", "lat": 38.3037, "lon": 116.8452, "population": 7544300}, - {"name": "Dar es Salaam", "lat": -6.8, "lon": 39.2833, "population": 7461000}, - {"name": "Hefei", "lat": 31.8639, "lon": 117.2808, "population": 7457027}, - {"name": "Hong Kong", "lat": 22.3069, "lon": 114.1831, "population": 7398000}, - {"name": "Shaoyang", "lat": 27.2418, "lon": 111.4725, "population": 7370500}, - {"name": "Zhanjiang", "lat": 21.1967, "lon": 110.4031, "population": 7332000}, - {"name": "Shangqiu", "lat": 34.4259, "lon": 115.6467, "population": 7325300}, - {"name": "Nantong", "lat": 31.9829, "lon": 120.8873, "population": 7283622}, - {"name": "Yancheng", "lat": 33.3936, "lon": 120.1339, "population": 7260240}, - {"name": "Nanning", "lat": 22.8192, "lon": 108.315, "population": 7254100}, - {"name": "Hengyang", "lat": 26.8968, "lon": 112.5857, "population": 7243400}, - {"name": "Zhumadian", "lat": 32.9773, "lon": 114.0253, "population": 7231234}, - {"name": "Shenyang", "lat": 41.8039, "lon": 123.4258, "population": 7208000}, - {"name": "Xingtai", "lat": 37.0659, "lon": 114.4753, "population": 7104103}, - {"name": "Xi’an", "lat": 34.2667, "lon": 108.9, "population": 7090000}, - {"name": "Santiago", "lat": -33.45, "lon": -70.6667, "population": 7026000}, - {"name": "Yantai", "lat": 37.3997, "lon": 121.2664, "population": 6968202}, - {"name": "Riyadh", "lat": 24.65, "lon": 46.71, "population": 6889000}, - {"name": "Luoyang", "lat": 34.6587, "lon": 112.4245, "population": 6888500}, - {"name": "Kunming", "lat": 25.0433, "lon": 102.7061, "population": 6850000}, - {"name": "Shangrao", "lat": 28.4419, "lon": 117.9633, "population": 6810700}, - {"name": "Hangzhou", "lat": 30.25, "lon": 120.1675, "population": 6713000}, - {"name": "Bijie", "lat": 27.3019, "lon": 105.2863, "population": 6686100}, - {"name": "Quanzhou", "lat": 24.9139, "lon": 118.5858, "population": 6480000}, - {"name": "Miami", "lat": 25.7839, "lon": -80.2102, "population": 6445545}, - {"name": "Wuxi", "lat": 31.5667, "lon": 120.2833, "population": 6372624}, - {"name": "Huanggang", "lat": 30.45, "lon": 114.875, "population": 6333000}, - {"name": "Maoming", "lat": 21.6618, "lon": 110.9178, "population": 6313200}, - {"name": "Nanchong", "lat": 30.7991, "lon": 106.0784, "population": 6278614}, - {"name": "Zunyi", "lat": 27.705, "lon": 106.9336, "population": 6270700}, - {"name": "Qujing", "lat": 25.5102, "lon": 103.8029, "population": 6155400}, - {"name": "Baghdad", "lat": 33.35, "lon": 44.4167, "population": 6107000}, - {"name": "Xinyang", "lat": 32.1264, "lon": 114.0672, "population": 6109106}, - ] - - # Convert to Pandas DataFrame - data = pandas.DataFrame(cities) +# Largest cities: name, location and population +# Source: https://simplemaps.com/data/world-cities +cities = [ + {"name": "Tokyo", "lat": 35.6839, "lon": 139.7744, "population": 39105000}, + {"name": "Jakarta", "lat": -6.2146, "lon": 106.8451, "population": 35362000}, + {"name": "Delhi", "lat": 28.6667, "lon": 77.2167, "population": 31870000}, + {"name": "Manila", "lat": 14.6, "lon": 120.9833, "population": 23971000}, + {"name": "São Paulo", "lat": -23.5504, "lon": -46.6339, "population": 22495000}, + {"name": "Seoul", "lat": 37.56, "lon": 126.99, "population": 22394000}, + {"name": "Mumbai", "lat": 19.0758, "lon": 72.8775, "population": 22186000}, + {"name": "Shanghai", "lat": 31.1667, "lon": 121.4667, "population": 22118000}, + {"name": "Mexico City", "lat": 19.4333, "lon": -99.1333, "population": 21505000}, + {"name": "Guangzhou", "lat": 23.1288, "lon": 113.259, "population": 21489000}, + {"name": "Cairo", "lat": 30.0444, "lon": 31.2358, "population": 19787000}, + {"name": "Beijing", "lat": 39.904, "lon": 116.4075, "population": 19437000}, + {"name": "New York", "lat": 40.6943, "lon": -73.9249, "population": 18713220}, + {"name": "Kolkāta", "lat": 22.5727, "lon": 88.3639, "population": 18698000}, + {"name": "Moscow", "lat": 55.7558, "lon": 37.6178, "population": 17693000}, + {"name": "Bangkok", "lat": 13.75, "lon": 100.5167, "population": 17573000}, + {"name": "Dhaka", "lat": 23.7289, "lon": 90.3944, "population": 16839000}, + {"name": "Buenos Aires", "lat": -34.5997, "lon": -58.3819, "population": 16216000}, + {"name": "Ōsaka", "lat": 34.752, "lon": 135.4582, "population": 15490000}, + {"name": "Lagos", "lat": 6.45, "lon": 3.4, "population": 15487000}, + {"name": "Istanbul", "lat": 41.01, "lon": 28.9603, "population": 15311000}, + {"name": "Karachi", "lat": 24.86, "lon": 67.01, "population": 15292000}, + {"name": "Kinshasa", "lat": -4.3317, "lon": 15.3139, "population": 15056000}, + {"name": "Shenzhen", "lat": 22.535, "lon": 114.054, "population": 14678000}, + {"name": "Bangalore", "lat": 12.9791, "lon": 77.5913, "population": 13999000}, + {"name": "Ho Chi Minh City", "lat": 10.8167, "lon": 106.6333, "population": 13954000}, + {"name": "Tehran", "lat": 35.7, "lon": 51.4167, "population": 13819000}, + {"name": "Los Angeles", "lat": 34.1139, "lon": -118.4068, "population": 12750807}, + {"name": "Rio de Janeiro", "lat": -22.9083, "lon": -43.1964, "population": 12486000}, + {"name": "Chengdu", "lat": 30.66, "lon": 104.0633, "population": 11920000}, + {"name": "Baoding", "lat": 38.8671, "lon": 115.4845, "population": 11860000}, + {"name": "Chennai", "lat": 13.0825, "lon": 80.275, "population": 11564000}, + {"name": "Lahore", "lat": 31.5497, "lon": 74.3436, "population": 11148000}, + {"name": "London", "lat": 51.5072, "lon": -0.1275, "population": 11120000}, + {"name": "Paris", "lat": 48.8566, "lon": 2.3522, "population": 11027000}, + {"name": "Tianjin", "lat": 39.1467, "lon": 117.2056, "population": 10932000}, + {"name": "Linyi", "lat": 35.0606, "lon": 118.3425, "population": 10820000}, + {"name": "Shijiazhuang", "lat": 38.0422, "lon": 114.5086, "population": 10784600}, + {"name": "Zhengzhou", "lat": 34.7492, "lon": 113.6605, "population": 10136000}, + {"name": "Nanyang", "lat": 32.9987, "lon": 112.5292, "population": 10013600}, + {"name": "Hyderābād", "lat": 17.3617, "lon": 78.4747, "population": 9840000}, + {"name": "Wuhan", "lat": 30.5872, "lon": 114.2881, "population": 9729000}, + {"name": "Handan", "lat": 36.6116, "lon": 114.4894, "population": 9549700}, + {"name": "Nagoya", "lat": 35.1167, "lon": 136.9333, "population": 9522000}, + {"name": "Weifang", "lat": 36.7167, "lon": 119.1, "population": 9373000}, + {"name": "Lima", "lat": -12.06, "lon": -77.0375, "population": 8992000}, + {"name": "Zhoukou", "lat": 33.625, "lon": 114.6418, "population": 8953172}, + {"name": "Luanda", "lat": -8.8383, "lon": 13.2344, "population": 8883000}, + {"name": "Ganzhou", "lat": 25.8292, "lon": 114.9336, "population": 8677600}, + {"name": "Tongshan", "lat": 34.261, "lon": 117.1859, "population": 8669000}, + {"name": "Kuala Lumpur", "lat": 3.1478, "lon": 101.6953, "population": 8639000}, + {"name": "Chicago", "lat": 41.8373, "lon": -87.6862, "population": 8604203}, + {"name": "Heze", "lat": 35.2333, "lon": 115.4333, "population": 8287693}, + {"name": "Chongqing", "lat": 29.55, "lon": 106.5069, "population": 8261000}, + {"name": "Hanoi", "lat": 21.0245, "lon": 105.8412, "population": 8246600}, + {"name": "Fuyang", "lat": 32.8986, "lon": 115.8045, "population": 8200264}, + {"name": "Changsha", "lat": 28.1987, "lon": 112.9709, "population": 8154700}, + {"name": "Dongguan", "lat": 23.0475, "lon": 113.7493, "population": 8142000}, + {"name": "Jining", "lat": 35.4, "lon": 116.5667, "population": 8081905}, + {"name": "Jinan", "lat": 36.6667, "lon": 116.9833, "population": 7967400}, + {"name": "Pune", "lat": 18.5196, "lon": 73.8553, "population": 7948000}, + {"name": "Foshan", "lat": 23.0292, "lon": 113.1056, "population": 7905700}, + {"name": "Bogotá", "lat": 4.6126, "lon": -74.0705, "population": 7743955}, + {"name": "Ahmedabad", "lat": 23.03, "lon": 72.58, "population": 7717000}, + {"name": "Nanjing", "lat": 32.05, "lon": 118.7667, "population": 7729000}, + {"name": "Changchun", "lat": 43.9, "lon": 125.2, "population": 7674439}, + {"name": "Tangshan", "lat": 39.6292, "lon": 118.1742, "population": 7577289}, + {"name": "Cangzhou", "lat": 38.3037, "lon": 116.8452, "population": 7544300}, + {"name": "Dar es Salaam", "lat": -6.8, "lon": 39.2833, "population": 7461000}, + {"name": "Hefei", "lat": 31.8639, "lon": 117.2808, "population": 7457027}, + {"name": "Hong Kong", "lat": 22.3069, "lon": 114.1831, "population": 7398000}, + {"name": "Shaoyang", "lat": 27.2418, "lon": 111.4725, "population": 7370500}, + {"name": "Zhanjiang", "lat": 21.1967, "lon": 110.4031, "population": 7332000}, + {"name": "Shangqiu", "lat": 34.4259, "lon": 115.6467, "population": 7325300}, + {"name": "Nantong", "lat": 31.9829, "lon": 120.8873, "population": 7283622}, + {"name": "Yancheng", "lat": 33.3936, "lon": 120.1339, "population": 7260240}, + {"name": "Nanning", "lat": 22.8192, "lon": 108.315, "population": 7254100}, + {"name": "Hengyang", "lat": 26.8968, "lon": 112.5857, "population": 7243400}, + {"name": "Zhumadian", "lat": 32.9773, "lon": 114.0253, "population": 7231234}, + {"name": "Shenyang", "lat": 41.8039, "lon": 123.4258, "population": 7208000}, + {"name": "Xingtai", "lat": 37.0659, "lon": 114.4753, "population": 7104103}, + {"name": "Xi’an", "lat": 34.2667, "lon": 108.9, "population": 7090000}, + {"name": "Santiago", "lat": -33.45, "lon": -70.6667, "population": 7026000}, + {"name": "Yantai", "lat": 37.3997, "lon": 121.2664, "population": 6968202}, + {"name": "Riyadh", "lat": 24.65, "lon": 46.71, "population": 6889000}, + {"name": "Luoyang", "lat": 34.6587, "lon": 112.4245, "population": 6888500}, + {"name": "Kunming", "lat": 25.0433, "lon": 102.7061, "population": 6850000}, + {"name": "Shangrao", "lat": 28.4419, "lon": 117.9633, "population": 6810700}, + {"name": "Hangzhou", "lat": 30.25, "lon": 120.1675, "population": 6713000}, + {"name": "Bijie", "lat": 27.3019, "lon": 105.2863, "population": 6686100}, + {"name": "Quanzhou", "lat": 24.9139, "lon": 118.5858, "population": 6480000}, + {"name": "Miami", "lat": 25.7839, "lon": -80.2102, "population": 6445545}, + {"name": "Wuxi", "lat": 31.5667, "lon": 120.2833, "population": 6372624}, + {"name": "Huanggang", "lat": 30.45, "lon": 114.875, "population": 6333000}, + {"name": "Maoming", "lat": 21.6618, "lon": 110.9178, "population": 6313200}, + {"name": "Nanchong", "lat": 30.7991, "lon": 106.0784, "population": 6278614}, + {"name": "Zunyi", "lat": 27.705, "lon": 106.9336, "population": 6270700}, + {"name": "Qujing", "lat": 25.5102, "lon": 103.8029, "population": 6155400}, + {"name": "Baghdad", "lat": 33.35, "lon": 44.4167, "population": 6107000}, + {"name": "Xinyang", "lat": 32.1264, "lon": 114.0672, "population": 6109106}, +] - # Add a column holding the bubble size: - # Min(population) -> size = 5 - # Max(population) -> size = 60 - solve = numpy.linalg.solve([[data["population"].min(), 1], [data["population"].max(), 1]], [5, 60]) - data["size"] = data["population"].apply(lambda p: p * solve[0] + solve[1]) +# Convert to Pandas DataFrame +data = pandas.DataFrame(cities) - # Add a column holding the bubble hover texts - # Format is " []" - data["text"] = data.apply(lambda row: f"{row['name']} [{row['population']}]", axis=1) +# Add a column holding the bubble size: +# Min(population) -> size = 5 +# Max(population) -> size = 60 +solve = numpy.linalg.solve([[data["population"].min(), 1], [data["population"].max(), 1]], [5, 60]) +data["size"] = data["population"].apply(lambda p: p * solve[0] + solve[1]) - marker = { - # Use the "size" column to set the bubble size - "size": "size" - } +# Add a column holding the bubble hover texts +# Format is " []" +data["text"] = data.apply(lambda row: f"{row['name']} [{row['population']}]", axis=1) - layout = {"geo": {"showland": True, "landcolor": "4A4"}} +marker = { + # Use the "size" column to set the bubble size + "size": "size" +} - page = """ -# Maps - Bubbles +layout = {"geo": {"showland": True, "landcolor": "4A4"}} +page = """ <|{data}|chart|type=scattergeo|lat=lat|lon=lon|mode=markers|marker={marker}|text=text|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Maps - Bubbles") diff --git a/doc/gui/examples/charts/map-lines.py b/doc/gui/examples/charts/map-lines.py index a0166ae6d5..dcbbf1324f 100644 --- a/doc/gui/examples/charts/map-lines.py +++ b/doc/gui/examples/charts/map-lines.py @@ -17,163 +17,161 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Busiest US airports - # Source: https://en.wikipedia.org/wiki/List_of_busiest_airports_by_passenger_traffic - airports: Dict[str, Dict[str, float]] = { - "AMS": {"lat": 52.31047296675518, "lon": 4.76819929439927}, - "ATL": {"lat": 33.64086185344307, "lon": -84.43600501711686}, - "AYT": {"lat": 36.90419539293911, "lon": 30.801855337974292}, - "BOS": {"lat": 42.36556559649881, "lon": -71.00960311751096}, - "CAN": {"lat": 23.38848323741897, "lon": 113.30277713668413}, - "CDG": {"lat": 49.008029034119915, "lon": 2.550879924581871}, - "CJU": {"lat": 33.51035978854847, "lon": 126.4913319405336}, - "CKG": {"lat": 29.71931573810283, "lon": 106.64211731662628}, - "CLT": {"lat": 35.214730980190616, "lon": -80.9474735034797}, - "CSX": {"lat": 28.196638298182446, "lon": 113.22083329905352}, - "CTU": {"lat": 30.567492917634063, "lon": 103.94912193845805}, - "CUN": {"lat": 21.04160313837335, "lon": -86.87407057500725}, - "DEL": {"lat": 28.556426221725868, "lon": 77.10031185913002}, - "DEN": {"lat": 39.85589532386815, "lon": -104.67329901305273}, - "DFW": {"lat": 32.89998507111719, "lon": -97.04044513206443}, - "DME": {"lat": 55.41032513421412, "lon": 37.902386927376234}, - "DTW": {"lat": 42.216145762248594, "lon": -83.35541784824225}, - "DXB": {"lat": 25.253155060720765, "lon": 55.365672799304534}, - "EWR": {"lat": 40.68951508829295, "lon": -74.17446240095387}, - "FLL": {"lat": 26.072469069499288, "lon": -80.1502073285754}, - "FRA": {"lat": 50.037870541116, "lon": 8.562119610188235}, - "GMP": {"lat": 37.558628944763534, "lon": 126.79445244110332}, - "GRU": {"lat": -23.430691200492866, "lon": -46.473107371367846}, - "HGH": {"lat": 30.2359856421667, "lon": 120.43880486944619}, - "HND": {"lat": 35.54938443207139, "lon": 139.77979568388005}, - "IAH": {"lat": 29.98997826322153, "lon": -95.33684707873988}, - "IST": {"lat": 41.27696594578831, "lon": 28.73004303446375}, - "JFK": {"lat": 40.64129497654287, "lon": -73.77813830094803}, - "KMG": {"lat": 24.99723271310971, "lon": 102.74030761670535}, - "LAS": {"lat": 36.08256046166282, "lon": -115.15700045025673}, - "LAX": {"lat": 33.94157995977848, "lon": -118.40848708486908}, - "MAD": {"lat": 40.49832400063489, "lon": -3.5676196584173754}, - "MCO": {"lat": 28.419119921670067, "lon": -81.30451008534465}, - "MEX": {"lat": 19.436096410278736, "lon": -99.07204777544095}, - "MIA": {"lat": 25.795823878101675, "lon": -80.28701871639629}, - "MSP": {"lat": 44.88471735079015, "lon": -93.22233824616785}, - "ORD": {"lat": 41.98024003208415, "lon": -87.9089657513565}, - "PEK": {"lat": 40.079816213451416, "lon": 116.60309064055198}, - "PHX": {"lat": 33.43614430802288, "lon": -112.01128270596944}, - "PKX": {"lat": 39.50978840400886, "lon": 116.41050689906415}, - "PVG": {"lat": 31.144398958515847, "lon": 121.80823008537978}, - "SAW": {"lat": 40.9053709590178, "lon": 29.316838841845318}, - "SEA": {"lat": 47.448024349661814, "lon": -122.30897973141963}, - "SFO": {"lat": 37.62122788155908, "lon": -122.37901977603573}, - "SHA": {"lat": 31.192227319334787, "lon": 121.33425408454256}, - "SLC": {"lat": 40.78985913031307, "lon": -111.97911351851535}, - "SVO": {"lat": 55.97381026156798, "lon": 37.412288430689664}, - "SZX": {"lat": 22.636827890877626, "lon": 113.81454162446936}, - "WUH": {"lat": 30.776589409566686, "lon": 114.21244949898504}, - "XIY": {"lat": 34.437119809208546, "lon": 108.7573508575816}, - } - - # Inter US airports flights - # Source: https://www.faa.gov/air_traffic/by_the_numbers - flights: List[Dict[str, Any]] = [ - {"from": "ATL", "to": "DFW", "traffic": 580}, - {"from": "ATL", "to": "MIA", "traffic": 224}, - {"from": "BOS", "to": "LAX", "traffic": 168}, - {"from": "DEN", "to": "DFW", "traffic": 558}, - {"from": "DFW", "to": "BOS", "traffic": 422}, - {"from": "DFW", "to": "CLT", "traffic": 360}, - {"from": "DFW", "to": "JFK", "traffic": 56}, - {"from": "DFW", "to": "LAS", "traffic": 569}, - {"from": "DFW", "to": "SEA", "traffic": 392}, - {"from": "DTW", "to": "DFW", "traffic": 260}, - {"from": "EWR", "to": "DFW", "traffic": 310}, - {"from": "EWR", "to": "ORD", "traffic": 168}, - {"from": "FLL", "to": "DFW", "traffic": 336}, - {"from": "FLL", "to": "ORD", "traffic": 168}, - {"from": "IAH", "to": "DFW", "traffic": 324}, - {"from": "JFK", "to": "FLL", "traffic": 112}, - {"from": "JFK", "to": "LAS", "traffic": 112}, - {"from": "JFK", "to": "LAX", "traffic": 548}, - {"from": "JFK", "to": "ORD", "traffic": 56}, - {"from": "LAS", "to": "MIA", "traffic": 168}, - {"from": "LAX", "to": "DFW", "traffic": 914}, - {"from": "LAX", "to": "EWR", "traffic": 54}, - {"from": "LAX", "to": "LAS", "traffic": 222}, - {"from": "LAX", "to": "MCO", "traffic": 56}, - {"from": "LAX", "to": "MIA", "traffic": 392}, - {"from": "LAX", "to": "SFO", "traffic": 336}, - {"from": "MCO", "to": "DFW", "traffic": 500}, - {"from": "MCO", "to": "JFK", "traffic": 224}, - {"from": "MCO", "to": "ORD", "traffic": 224}, - {"from": "MIA", "to": "BOS", "traffic": 392}, - {"from": "MIA", "to": "DEN", "traffic": 112}, - {"from": "MIA", "to": "DFW", "traffic": 560}, - {"from": "MIA", "to": "DTW", "traffic": 112}, - {"from": "MIA", "to": "EWR", "traffic": 168}, - {"from": "MIA", "to": "IAH", "traffic": 168}, - {"from": "MIA", "to": "JFK", "traffic": 392}, - {"from": "MIA", "to": "MCO", "traffic": 448}, - {"from": "MSP", "to": "DFW", "traffic": 326}, - {"from": "MSP", "to": "MIA", "traffic": 56}, - {"from": "ORD", "to": "BOS", "traffic": 430}, - {"from": "ORD", "to": "DEN", "traffic": 112}, - {"from": "ORD", "to": "DFW", "traffic": 825}, - {"from": "ORD", "to": "LAS", "traffic": 280}, - {"from": "ORD", "to": "LAX", "traffic": 496}, - {"from": "ORD", "to": "MIA", "traffic": 505}, - {"from": "ORD", "to": "MSP", "traffic": 160}, - {"from": "ORD", "to": "PHX", "traffic": 280}, - {"from": "ORD", "to": "SEA", "traffic": 214}, - {"from": "ORD", "to": "SFO", "traffic": 326}, - {"from": "PHX", "to": "DFW", "traffic": 550}, - {"from": "PHX", "to": "MIA", "traffic": 56}, - {"from": "SEA", "to": "JFK", "traffic": 56}, - {"from": "SFO", "to": "DFW", "traffic": 526}, - {"from": "SFO", "to": "JFK", "traffic": 278}, - {"from": "SFO", "to": "MIA", "traffic": 168}, - {"from": "SLC", "to": "DFW", "traffic": 280}, - ] +# Busiest US airports +# Source: https://en.wikipedia.org/wiki/List_of_busiest_airports_by_passenger_traffic +airports: Dict[str, Dict[str, float]] = { + "AMS": {"lat": 52.31047296675518, "lon": 4.76819929439927}, + "ATL": {"lat": 33.64086185344307, "lon": -84.43600501711686}, + "AYT": {"lat": 36.90419539293911, "lon": 30.801855337974292}, + "BOS": {"lat": 42.36556559649881, "lon": -71.00960311751096}, + "CAN": {"lat": 23.38848323741897, "lon": 113.30277713668413}, + "CDG": {"lat": 49.008029034119915, "lon": 2.550879924581871}, + "CJU": {"lat": 33.51035978854847, "lon": 126.4913319405336}, + "CKG": {"lat": 29.71931573810283, "lon": 106.64211731662628}, + "CLT": {"lat": 35.214730980190616, "lon": -80.9474735034797}, + "CSX": {"lat": 28.196638298182446, "lon": 113.22083329905352}, + "CTU": {"lat": 30.567492917634063, "lon": 103.94912193845805}, + "CUN": {"lat": 21.04160313837335, "lon": -86.87407057500725}, + "DEL": {"lat": 28.556426221725868, "lon": 77.10031185913002}, + "DEN": {"lat": 39.85589532386815, "lon": -104.67329901305273}, + "DFW": {"lat": 32.89998507111719, "lon": -97.04044513206443}, + "DME": {"lat": 55.41032513421412, "lon": 37.902386927376234}, + "DTW": {"lat": 42.216145762248594, "lon": -83.35541784824225}, + "DXB": {"lat": 25.253155060720765, "lon": 55.365672799304534}, + "EWR": {"lat": 40.68951508829295, "lon": -74.17446240095387}, + "FLL": {"lat": 26.072469069499288, "lon": -80.1502073285754}, + "FRA": {"lat": 50.037870541116, "lon": 8.562119610188235}, + "GMP": {"lat": 37.558628944763534, "lon": 126.79445244110332}, + "GRU": {"lat": -23.430691200492866, "lon": -46.473107371367846}, + "HGH": {"lat": 30.2359856421667, "lon": 120.43880486944619}, + "HND": {"lat": 35.54938443207139, "lon": 139.77979568388005}, + "IAH": {"lat": 29.98997826322153, "lon": -95.33684707873988}, + "IST": {"lat": 41.27696594578831, "lon": 28.73004303446375}, + "JFK": {"lat": 40.64129497654287, "lon": -73.77813830094803}, + "KMG": {"lat": 24.99723271310971, "lon": 102.74030761670535}, + "LAS": {"lat": 36.08256046166282, "lon": -115.15700045025673}, + "LAX": {"lat": 33.94157995977848, "lon": -118.40848708486908}, + "MAD": {"lat": 40.49832400063489, "lon": -3.5676196584173754}, + "MCO": {"lat": 28.419119921670067, "lon": -81.30451008534465}, + "MEX": {"lat": 19.436096410278736, "lon": -99.07204777544095}, + "MIA": {"lat": 25.795823878101675, "lon": -80.28701871639629}, + "MSP": {"lat": 44.88471735079015, "lon": -93.22233824616785}, + "ORD": {"lat": 41.98024003208415, "lon": -87.9089657513565}, + "PEK": {"lat": 40.079816213451416, "lon": 116.60309064055198}, + "PHX": {"lat": 33.43614430802288, "lon": -112.01128270596944}, + "PKX": {"lat": 39.50978840400886, "lon": 116.41050689906415}, + "PVG": {"lat": 31.144398958515847, "lon": 121.80823008537978}, + "SAW": {"lat": 40.9053709590178, "lon": 29.316838841845318}, + "SEA": {"lat": 47.448024349661814, "lon": -122.30897973141963}, + "SFO": {"lat": 37.62122788155908, "lon": -122.37901977603573}, + "SHA": {"lat": 31.192227319334787, "lon": 121.33425408454256}, + "SLC": {"lat": 40.78985913031307, "lon": -111.97911351851535}, + "SVO": {"lat": 55.97381026156798, "lon": 37.412288430689664}, + "SZX": {"lat": 22.636827890877626, "lon": 113.81454162446936}, + "WUH": {"lat": 30.776589409566686, "lon": 114.21244949898504}, + "XIY": {"lat": 34.437119809208546, "lon": 108.7573508575816}, +} - data = [] - max_traffic = 0 - for flight in flights: - airport_from = airports[flight["from"]] - airport_to = airports[flight["to"]] - # Define data source to plot this flight - data.append({"lat": [airport_from["lat"], airport_to["lat"]], "lon": [airport_from["lon"], airport_to["lon"]]}) - # Store the maximum traffic - if flight["traffic"] > max_traffic: - max_traffic = flight["traffic"] +# Inter US airports flights +# Source: https://www.faa.gov/air_traffic/by_the_numbers +flights: List[Dict[str, Any]] = [ + {"from": "ATL", "to": "DFW", "traffic": 580}, + {"from": "ATL", "to": "MIA", "traffic": 224}, + {"from": "BOS", "to": "LAX", "traffic": 168}, + {"from": "DEN", "to": "DFW", "traffic": 558}, + {"from": "DFW", "to": "BOS", "traffic": 422}, + {"from": "DFW", "to": "CLT", "traffic": 360}, + {"from": "DFW", "to": "JFK", "traffic": 56}, + {"from": "DFW", "to": "LAS", "traffic": 569}, + {"from": "DFW", "to": "SEA", "traffic": 392}, + {"from": "DTW", "to": "DFW", "traffic": 260}, + {"from": "EWR", "to": "DFW", "traffic": 310}, + {"from": "EWR", "to": "ORD", "traffic": 168}, + {"from": "FLL", "to": "DFW", "traffic": 336}, + {"from": "FLL", "to": "ORD", "traffic": 168}, + {"from": "IAH", "to": "DFW", "traffic": 324}, + {"from": "JFK", "to": "FLL", "traffic": 112}, + {"from": "JFK", "to": "LAS", "traffic": 112}, + {"from": "JFK", "to": "LAX", "traffic": 548}, + {"from": "JFK", "to": "ORD", "traffic": 56}, + {"from": "LAS", "to": "MIA", "traffic": 168}, + {"from": "LAX", "to": "DFW", "traffic": 914}, + {"from": "LAX", "to": "EWR", "traffic": 54}, + {"from": "LAX", "to": "LAS", "traffic": 222}, + {"from": "LAX", "to": "MCO", "traffic": 56}, + {"from": "LAX", "to": "MIA", "traffic": 392}, + {"from": "LAX", "to": "SFO", "traffic": 336}, + {"from": "MCO", "to": "DFW", "traffic": 500}, + {"from": "MCO", "to": "JFK", "traffic": 224}, + {"from": "MCO", "to": "ORD", "traffic": 224}, + {"from": "MIA", "to": "BOS", "traffic": 392}, + {"from": "MIA", "to": "DEN", "traffic": 112}, + {"from": "MIA", "to": "DFW", "traffic": 560}, + {"from": "MIA", "to": "DTW", "traffic": 112}, + {"from": "MIA", "to": "EWR", "traffic": 168}, + {"from": "MIA", "to": "IAH", "traffic": 168}, + {"from": "MIA", "to": "JFK", "traffic": 392}, + {"from": "MIA", "to": "MCO", "traffic": 448}, + {"from": "MSP", "to": "DFW", "traffic": 326}, + {"from": "MSP", "to": "MIA", "traffic": 56}, + {"from": "ORD", "to": "BOS", "traffic": 430}, + {"from": "ORD", "to": "DEN", "traffic": 112}, + {"from": "ORD", "to": "DFW", "traffic": 825}, + {"from": "ORD", "to": "LAS", "traffic": 280}, + {"from": "ORD", "to": "LAX", "traffic": 496}, + {"from": "ORD", "to": "MIA", "traffic": 505}, + {"from": "ORD", "to": "MSP", "traffic": 160}, + {"from": "ORD", "to": "PHX", "traffic": 280}, + {"from": "ORD", "to": "SEA", "traffic": 214}, + {"from": "ORD", "to": "SFO", "traffic": 326}, + {"from": "PHX", "to": "DFW", "traffic": 550}, + {"from": "PHX", "to": "MIA", "traffic": 56}, + {"from": "SEA", "to": "JFK", "traffic": 56}, + {"from": "SFO", "to": "DFW", "traffic": 526}, + {"from": "SFO", "to": "JFK", "traffic": 278}, + {"from": "SFO", "to": "MIA", "traffic": 168}, + {"from": "SLC", "to": "DFW", "traffic": 280}, +] - properties = { - # Chart data - "data": data, - # Chart type - "type": "scattergeo", - # Keep lines only - "mode": "lines", - # Flights display as redish lines - "line": {"width": 2, "color": "E22"}, - "layout": { - # Focus on the USA region - "geo": {"scope": "usa"} - }, - } +data = [] +max_traffic = 0 +for flight in flights: + airport_from = airports[flight["from"]] + airport_to = airports[flight["to"]] + # Define data source to plot this flight + data.append({"lat": [airport_from["lat"], airport_to["lat"]], "lon": [airport_from["lon"], airport_to["lon"]]}) + # Store the maximum traffic + if flight["traffic"] > max_traffic: + max_traffic = flight["traffic"] - # Set the proper data source and opacity for each trace - for i, flight in enumerate(flights): - # lat[trace_index] = "[index_in_data]/lat" - properties[f"lat[{i+1}]"] = f"{i}/lat" - # lon[trace_index] = "[index_in_data]/lon" - properties[f"lon[{i+1}]"] = f"{i}/lon" - # Set flight opacity (max traffic -> max opacity) - # Hide legend for all flights - properties[f"options[{i+1}]"] = {"opacity": flight["traffic"] / max_traffic, "showlegend": False} +properties = { + # Chart data + "data": data, + # Chart type + "type": "scattergeo", + # Keep lines only + "mode": "lines", + # Flights display as redish lines + "line": {"width": 2, "color": "E22"}, + "layout": { + # Focus on the USA region + "geo": {"scope": "usa"} + }, +} - page = """ -# Maps - Multiple Lines +# Set the proper data source and opacity for each trace +for i, flight in enumerate(flights): + # lat[trace_index] = "[index_in_data]/lat" + properties[f"lat[{i+1}]"] = f"{i}/lat" + # lon[trace_index] = "[index_in_data]/lon" + properties[f"lon[{i+1}]"] = f"{i}/lon" + # Set flight opacity (max traffic -> max opacity) + # Hide legend for all flights + properties[f"options[{i+1}]"] = {"opacity": flight["traffic"] / max_traffic, "showlegend": False} +page = """ <|chart|properties={properties}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Maps - Multiple Lines") diff --git a/doc/gui/examples/charts/map-simple.py b/doc/gui/examples/charts/map-simple.py index fd0815d613..a05d70a514 100644 --- a/doc/gui/examples/charts/map-simple.py +++ b/doc/gui/examples/charts/map-simple.py @@ -15,40 +15,38 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Flight start and end locations - data = { - # Hartsfield-Jackson Atlanta International Airport - # to - # Aéroport de Paris-Charles de Gaulle - "lat": [33.64, 49.01], - "lon": [-84.44, 2.55], - } - - layout = { - # Chart title - "title": "ATL to CDG", - # Hide legend - "showlegend": False, - # Focus on relevant area - "geo": { - "resolution": 50, - "showland": True, - "showocean": True, - "landcolor": "4a4", - "oceancolor": "77d", - "lataxis": {"range": [20, 60]}, - "lonaxis": {"range": [-100, 20]}, - }, - } +# Flight start and end locations +data = { + # Hartsfield-Jackson Atlanta International Airport + # to + # Aéroport de Paris-Charles de Gaulle + "lat": [33.64, 49.01], + "lon": [-84.44, 2.55], +} - # Flight displayed as a thick, red plot - line = {"width": 5, "color": "red"} +layout = { + # Chart title + "title": "ATL to CDG", + # Hide legend + "showlegend": False, + # Focus on relevant area + "geo": { + "resolution": 50, + "showland": True, + "showocean": True, + "landcolor": "4a4", + "oceancolor": "77d", + "lataxis": {"range": [20, 60]}, + "lonaxis": {"range": [-100, 20]}, + }, +} - page = """ -# Maps - Simple +# Flight displayed as a thick, red plot +line = {"width": 5, "color": "red"} +page = """ <|{data}|chart|type=scattergeo|mode=lines|lat=lat|lon=lon|line={line}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Maps - Simple") diff --git a/doc/gui/examples/charts/pie-multiple.py b/doc/gui/examples/charts/pie-multiple.py index bd1b66a921..5c95100e3a 100644 --- a/doc/gui/examples/charts/pie-multiple.py +++ b/doc/gui/examples/charts/pie-multiple.py @@ -15,77 +15,75 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # List of countries, used as labels in the pie charts - countries = ["US", "China", "European Union", "Russian Federation", "Brazil", "India", "Rest of World"] +# List of countries, used as labels in the pie charts +countries = ["US", "China", "European Union", "Russian Federation", "Brazil", "India", "Rest of World"] - data = [ - { - # Values for GHG Emissions - "values": [16, 15, 12, 6, 5, 4, 42], - "labels": countries, - }, - { - # Values for CO2 Emissions - "values": [27, 11, 25, 8, 1, 3, 25], - "labels": countries, - }, - ] +data = [ + { + # Values for GHG Emissions + "values": [16, 15, 12, 6, 5, 4, 42], + "labels": countries, + }, + { + # Values for CO2 Emissions + "values": [27, 11, 25, 8, 1, 3, 25], + "labels": countries, + }, +] - options = [ - # First pie chart +options = [ + # First pie chart + { + # Show label value on hover + "hoverinfo": "label", + # Leave a hole in the middle of the chart + "hole": 0.4, + # Place the trace on the left side + "domain": {"column": 0}, + }, + # Second pie chart + { + # Show label value on hover + "hoverinfo": "label", + # Leave a hole in the middle of the chart + "hole": 0.4, + # Place the trace on the right side + "domain": {"column": 1}, + }, +] + +layout = { + # Chart title + "title": "Global Emissions 1990-2011", + # Show traces in a 1x2 grid + "grid": {"rows": 1, "columns": 2}, + "annotations": [ + # Annotation for the first trace { - # Show label value on hover - "hoverinfo": "label", - # Leave a hole in the middle of the chart - "hole": 0.4, - # Place the trace on the left side - "domain": {"column": 0}, + "text": "GHG", + "font": {"size": 20}, + # Hide annotation arrow + "showarrow": False, + # Move to the center of the trace + "x": 0.18, + "y": 0.5, }, - # Second pie chart + # Annotation for the second trace { - # Show label value on hover - "hoverinfo": "label", - # Leave a hole in the middle of the chart - "hole": 0.4, - # Place the trace on the right side - "domain": {"column": 1}, + "text": "CO2", + "font": {"size": 20}, + "showarrow": False, + # Move to the center of the trace + "x": 0.81, + "y": 0.5, }, - ] - - layout = { - # Chart title - "title": "Global Emissions 1990-2011", - # Show traces in a 1x2 grid - "grid": {"rows": 1, "columns": 2}, - "annotations": [ - # Annotation for the first trace - { - "text": "GHG", - "font": {"size": 20}, - # Hide annotation arrow - "showarrow": False, - # Move to the center of the trace - "x": 0.18, - "y": 0.5, - }, - # Annotation for the second trace - { - "text": "CO2", - "font": {"size": 20}, - "showarrow": False, - # Move to the center of the trace - "x": 0.81, - "y": 0.5, - }, - ], - "showlegend": False, - } - - page = """ -# Pie - Multiple + ], + "showlegend": False, +} +page = """ <|{data}|chart|type=pie|x[1]=0/values|x[2]=1/values|options={options}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Pie - Multiple") diff --git a/doc/gui/examples/charts/pie-simple.py b/doc/gui/examples/charts/pie-simple.py index d3dd2acb0c..ce2e7146af 100644 --- a/doc/gui/examples/charts/pie-simple.py +++ b/doc/gui/examples/charts/pie-simple.py @@ -15,28 +15,26 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Source https://www.fao.org/faostat/en/#data/SDGB - data = { - "Country": [ - "Rest of the world", - "Russian Federation", - "Brazil", - "Canada", - "United States of America", - "China", - "Australia", - "Democratic Republic of the Congo", - "Indonesia", - "Peru", - ], - "Area": [1445674.66, 815312, 496620, 346928, 309795, 219978, 134005, 126155, 92133.2, 72330.4], - } - - page = """ -# Pie - Simple +# Source https://www.fao.org/faostat/en/#data/SDGB +data = { + "Country": [ + "Rest of the world", + "Russian Federation", + "Brazil", + "Canada", + "United States of America", + "China", + "Australia", + "Democratic Republic of the Congo", + "Indonesia", + "Peru", + ], + "Area": [1445674.66, 815312, 496620, 346928, 309795, 219978, 134005, 126155, 92133.2, 72330.4], +} +page = """ <|{data}|chart|type=pie|values=Area|label=Country|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Pie - Simple") diff --git a/doc/gui/examples/charts/pie-styling.py b/doc/gui/examples/charts/pie-styling.py index 540bbfb383..09d1ed832f 100644 --- a/doc/gui/examples/charts/pie-styling.py +++ b/doc/gui/examples/charts/pie-styling.py @@ -15,31 +15,31 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - n_slices = 20 - # List: [1..n_slices] - # Slices are bigger and bigger - values = list(range(1, n_slices + 1)) +n_slices = 20 +# List: [1..n_slices] +# Slices are bigger and bigger +values = list(range(1, n_slices + 1)) - marker = { - # Colors move around the Hue color disk - "colors": [f"hsl({360 * (i - 1)/(n_slices - 1)},90%,60%)" for i in values] - } +marker = { + # Colors move around the Hue color disk + "colors": [f"hsl({360 * (i - 1)/(n_slices - 1)},90%,60%)" for i in values] +} - layout = { - # Hide the legend - "showlegend": False - } +layout = { + # Hide the legend + "showlegend": False +} - options = { - # Hide the texts - "textinfo": "none" - } +options = { + # Hide the texts + "textinfo": "none" +} - page = """ -# Pie - Style +page = """ +# <|{values}|chart|type=pie|marker={marker}|options={options}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Pie - Style") diff --git a/doc/gui/examples/charts/polar-angular-axis.py b/doc/gui/examples/charts/polar-angular-axis.py index cf78bb5df8..83e2b48aff 100644 --- a/doc/gui/examples/charts/polar-angular-axis.py +++ b/doc/gui/examples/charts/polar-angular-axis.py @@ -15,42 +15,40 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Create a star shape - data = {"r": [3, 1] * 5 + [3], "theta": list(range(0, 360, 36)) + [0]} +# Create a star shape +data = {"r": [3, 1] * 5 + [3], "theta": list(range(0, 360, 36)) + [0]} - options = [ - # First plot is filled with a yellow-ish color - {"subplot": "polar", "fill": "toself", "fillcolor": "#E4FF87"}, - # Second plot is filled with a blue-ish color - {"fill": "toself", "subplot": "polar2", "fillcolor": "#709BFF"}, - ] +options = [ + # First plot is filled with a yellow-ish color + {"subplot": "polar", "fill": "toself", "fillcolor": "#E4FF87"}, + # Second plot is filled with a blue-ish color + {"fill": "toself", "subplot": "polar2", "fillcolor": "#709BFF"}, +] - layout = { - "polar": { - # This actually is the default value - "angularaxis": { - "direction": "counterclockwise", - }, +layout = { + "polar": { + # This actually is the default value + "angularaxis": { + "direction": "counterclockwise", }, - "polar2": { - "angularaxis": { - # Rotate the axis 180° (0 is on the left) - "rotation": 180, - # Orient the axis clockwise - "direction": "clockwise", - # Show the angles as radians - "thetaunit": "radians", - }, + }, + "polar2": { + "angularaxis": { + # Rotate the axis 180° (0 is on the left) + "rotation": 180, + # Orient the axis clockwise + "direction": "clockwise", + # Show the angles as radians + "thetaunit": "radians", }, - # Hide the legend - "showlegend": False, - } - - page = """ -# Polar Charts - Direction + }, + # Hide the legend + "showlegend": False, +} +page = """ <|{data}|chart|type=scatterpolar|layout={layout}|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Polar - Direction") diff --git a/doc/gui/examples/charts/polar-area.py b/doc/gui/examples/charts/polar-area.py index c26dca5fe7..c0e68f0dc6 100644 --- a/doc/gui/examples/charts/polar-area.py +++ b/doc/gui/examples/charts/polar-area.py @@ -25,33 +25,31 @@ def draw_heart(angle): return 2 - 2 * sa + sa * (math.sqrt(math.fabs(math.cos(a))) / (sa + 1.4)) -if __name__ == "__main__": - # One data point for each degree - theta = range(0, 360) - - data = { - # Create the heart shape - "r": [draw_heart(angle) for angle in theta], - "theta": theta, - } - - options = {"fill": "toself"} - - layout = { - # Hide the legend - "showlegend": False, - "polar": { - # Hide the angular axis - "angularaxis": {"visible": False}, - # Hide the radial axis - "radialaxis": {"visible": False}, - }, - } - - page = """ -# Polar - Area - +# One data point for each degree +theta = range(0, 360) + +data = { + # Create the heart shape + "r": [draw_heart(angle) for angle in theta], + "theta": theta, +} + +options = {"fill": "toself"} + +layout = { + # Hide the legend + "showlegend": False, + "polar": { + # Hide the angular axis + "angularaxis": {"visible": False}, + # Hide the radial axis + "radialaxis": {"visible": False}, + }, +} + +page = """ <|{data}|chart|type=scatterpolar|mode=none|layout={layout}|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Polar - Area") diff --git a/doc/gui/examples/charts/polar-multiple.py b/doc/gui/examples/charts/polar-multiple.py index 5e7def4640..c0f75bac5f 100644 --- a/doc/gui/examples/charts/polar-multiple.py +++ b/doc/gui/examples/charts/polar-multiple.py @@ -23,30 +23,28 @@ def create_rose(n_petals): return [math.cos(math.radians(n_petals * angle)) for angle in theta] -if __name__ == "__main__": - # One data point for each degree - theta = range(0, 360) - - data = {"theta": theta, "r1": create_rose(2), "r2": create_rose(3), "r3": create_rose(4)} - - # We want three traces in the same chart - r = ["r1", "r2", "r3"] - - layout = { - # Hide the legend - "showlegend": False, - "polar": { - # Hide the angular axis - "angularaxis": {"visible": False}, - # Hide the radial axis - "radialaxis": {"visible": False}, - }, - } - - page = """ -# Polar - Multiple - +# One data point for each degree +theta = range(0, 360) + +data = {"theta": theta, "r1": create_rose(2), "r2": create_rose(3), "r3": create_rose(4)} + +# We want three traces in the same chart +r = ["r1", "r2", "r3"] + +layout = { + # Hide the legend + "showlegend": False, + "polar": { + # Hide the angular axis + "angularaxis": {"visible": False}, + # Hide the radial axis + "radialaxis": {"visible": False}, + }, +} + +page = """ <|{data}|chart|type=scatterpolar|mode=lines|r={r}|theta=theta|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Polar - Multiple") diff --git a/doc/gui/examples/charts/polar-sectors.py b/doc/gui/examples/charts/polar-sectors.py index 5b27e02703..c040bc3583 100644 --- a/doc/gui/examples/charts/polar-sectors.py +++ b/doc/gui/examples/charts/polar-sectors.py @@ -15,36 +15,34 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Sample small plot definition - trace = { - "r": [1, 2, 3, 4, 1], - "theta": [0, 40, 80, 120, 160], - } - - # The same data is used in both traces - data = [trace, trace] +# Sample small plot definition +trace = { + "r": [1, 2, 3, 4, 1], + "theta": [0, 40, 80, 120, 160], +} - # Naming the subplot is mandatory to get them both in - # the same chart - options = [ - { - "subplot": "polar", - }, - {"subplot": "polar2"}, - ] +# The same data is used in both traces +data = [trace, trace] - layout = { - # Hide the legend - "showlegend": False, - # Restrict the angular values for second trace - "polar2": {"sector": [30, 130]}, - } +# Naming the subplot is mandatory to get them both in +# the same chart +options = [ + { + "subplot": "polar", + }, + {"subplot": "polar2"}, +] - md = """ -# Polar - Sectors +layout = { + # Hide the legend + "showlegend": False, + # Restrict the angular values for second trace + "polar2": {"sector": [30, 130]}, +} +md = """ <|{data}|chart|type=scatterpolar|layout={layout}|options={options}|> - """ +""" - Gui(md).run() +if __name__ == "__main__": + Gui(md).run(title="Chart - Polar - Sectors") diff --git a/doc/gui/examples/charts/polar-simple.py b/doc/gui/examples/charts/polar-simple.py index cad9118af9..084ca05999 100644 --- a/doc/gui/examples/charts/polar-simple.py +++ b/doc/gui/examples/charts/polar-simple.py @@ -25,20 +25,18 @@ def draw_heart(angle): return 2 - 2 * sa + sa * (math.sqrt(math.fabs(math.cos(a))) / (sa + 1.4)) -if __name__ == "__main__": - # One data point for each degree - theta = range(0, 360) - - data = { - # Create the heart shape - "r": [draw_heart(angle) for angle in theta], - "theta": theta, - } +# One data point for each degree +theta = range(0, 360) - page = """ -# Polar - Simple +data = { + # Create the heart shape + "r": [draw_heart(angle) for angle in theta], + "theta": theta, +} +page = """ <|{data}|chart|type=scatterpolar|mode=lines|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Polar - Simple") diff --git a/doc/gui/examples/charts/polar-tick-texts.py b/doc/gui/examples/charts/polar-tick-texts.py index e02ecdf5f2..78bec19691 100644 --- a/doc/gui/examples/charts/polar-tick-texts.py +++ b/doc/gui/examples/charts/polar-tick-texts.py @@ -51,61 +51,60 @@ def on_navigate(state, page): return page -if __name__ == "__main__": - # Initialize the data set with the current time - data = generate_hand_shapes() - - layout = { - "polar": { - "angularaxis": { - "rotation": 90, - "direction": "clockwise", - # One tick every 30 degrees - "tickvals": list(numpy.arange(0.0, 360.0, 30)), - # Text value for every tick - "ticktext": ["XII", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI"], - }, - "radialaxis": {"angle": 90, "visible": False, "range": [0, 12]}, +# Initialize the data set with the current time +data = generate_hand_shapes() + +layout = { + "polar": { + "angularaxis": { + "rotation": 90, + "direction": "clockwise", + # One tick every 30 degrees + "tickvals": list(numpy.arange(0.0, 360.0, 30)), + # Text value for every tick + "ticktext": ["XII", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X", "XI"], }, - "showlegend": False, - } - - # Options to be used for all three traces - base_opts = {"fill": "toself"} - # Specific for hours - hours_opts = dict(base_opts) - hours_opts["fillcolor"] = "#FF0000" - # Specific for minutes - minutes_opts = dict(base_opts) - minutes_opts["fillcolor"] = "#00FF00" - # Specific for seconds - seconds_opts = dict(base_opts) - seconds_opts["fillcolor"] = "#0000FF" - - # Store all the chart control properties in a single object - properties = { - # Don't show data point markers - "mode": "lines", - # Data for the hours - "theta[1]": "0/a", - "r[1]": "0/r", - # Data for the minutes - "theta[2]": "1/a", - "r[2]": "1/r", - # Data for the seconds - "theta[3]": "2/a", - "r[3]": "2/r", - # Options for the three traces - "options[1]": hours_opts, - "options[2]": minutes_opts, - "options[3]": seconds_opts, - "line": {"color": "black"}, - "layout": layout, - } - - page = """ -# Polar - Tick texts - + "radialaxis": {"angle": 90, "visible": False, "range": [0, 12]}, + }, + "showlegend": False, +} + +# Options to be used for all three traces +base_opts = {"fill": "toself"} +# Specific for hours +hours_opts = dict(base_opts) +hours_opts["fillcolor"] = "#FF0000" +# Specific for minutes +minutes_opts = dict(base_opts) +minutes_opts["fillcolor"] = "#00FF00" +# Specific for seconds +seconds_opts = dict(base_opts) +seconds_opts["fillcolor"] = "#0000FF" + +# Store all the chart control properties in a single object +properties = { + # Don't show data point markers + "mode": "lines", + # Data for the hours + "theta[1]": "0/a", + "r[1]": "0/r", + # Data for the minutes + "theta[2]": "1/a", + "r[2]": "1/r", + # Data for the seconds + "theta[3]": "2/a", + "r[3]": "2/r", + # Options for the three traces + "options[1]": hours_opts, + "options[2]": minutes_opts, + "options[3]": seconds_opts, + "line": {"color": "black"}, + "layout": layout, +} + +page = """ <|{data}|chart|type=scatterpolar|properties={properties}|> - """ - Gui(page).run() +""" + +if __name__ == "__main__": + Gui(page).run(title="Chart - Polar - Tick texts") diff --git a/doc/gui/examples/charts/radar-multiple.py b/doc/gui/examples/charts/radar-multiple.py index ce090946d8..7d6524ec7d 100644 --- a/doc/gui/examples/charts/radar-multiple.py +++ b/doc/gui/examples/charts/radar-multiple.py @@ -17,40 +17,38 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Skill categories - skills = ["HTML", "CSS", "Java", "Python", "PHP", "JavaScript", "Photoshop"] - data: List[Dict[str, List]] = [ - # Proportion of skills used for Backend development - {"Backend": [10, 10, 80, 70, 90, 30, 0], "Skills": skills}, - # Proportion of skills used for Frontend development - {"Frontend": [90, 90, 0, 10, 20, 80, 60], "Skills": skills}, - ] - - # Append first elements to all arrays for a nice stroke - skills.append(skills[0]) - data[0]["Backend"].append(data[0]["Backend"][0]) - data[1]["Frontend"].append(data[1]["Frontend"][0]) - - layout = { - # Force the radial axis displayed range - "polar": {"radialaxis": {"range": [0, 100]}} - } - - # Fill the trace - options = {"fill": "toself"} - - # Reflected in the legend - names = ["Backend", "Frontend"] - - # To shorten the chart control definition - r = ["0/Backend", "1/Frontend"] - theta = ["0/Skills", "1/Skills"] - - page = """ -# Radar - Multiple - +# Skill categories +skills = ["HTML", "CSS", "Java", "Python", "PHP", "JavaScript", "Photoshop"] +data: List[Dict[str, List]] = [ + # Proportion of skills used for Backend development + {"Backend": [10, 10, 80, 70, 90, 30, 0], "Skills": skills}, + # Proportion of skills used for Frontend development + {"Frontend": [90, 90, 0, 10, 20, 80, 60], "Skills": skills}, +] + +# Append first elements to all arrays for a nice stroke +skills.append(skills[0]) +data[0]["Backend"].append(data[0]["Backend"][0]) +data[1]["Frontend"].append(data[1]["Frontend"][0]) + +layout = { + # Force the radial axis displayed range + "polar": {"radialaxis": {"range": [0, 100]}} +} + +# Fill the trace +options = {"fill": "toself"} + +# Reflected in the legend +names = ["Backend", "Frontend"] + +# To shorten the chart control definition +r = ["0/Backend", "1/Frontend"] +theta = ["0/Skills", "1/Skills"] + +page = """ <|{data}|chart|type=scatterpolar|name={names}|r={r}|theta={theta}|options={options}|layout={layout}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Radar - Multiple") diff --git a/doc/gui/examples/charts/radar-simple.py b/doc/gui/examples/charts/radar-simple.py index 99d6065fe8..441cd3deda 100644 --- a/doc/gui/examples/charts/radar-simple.py +++ b/doc/gui/examples/charts/radar-simple.py @@ -17,41 +17,39 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Source: www.statista.com (Most used programming languages in 2022) - data: Dict[str, List] = { - # List of programming languages - "Language": ["JavaScript", "HTML/CSS", "SQL", "Python", "Typescript", "Java", "Bash/Shell"], - # Percentage of usage, per language - "%": [65.36, 55.08, 49.43, 48.07, 34.83, 33.27, 29.07], - } - - # Close the shape for a nice-looking stroke - # If the first point is *not* appended to the end of the list, - # then the shape does not look as it is closed. - data["%"].append(data["%"][0]) - data["Language"].append(data["Language"][0]) - - layout = { - "polar": { - "radialaxis": { - # Force the radial range to 0-100 - "range": [0, 100], - } - }, - # Hide legend - "showlegend": False, - } - - options = { - # Fill the trace - "fill": "toself" - } - - md = """ -# Radar - Simple - +# Source: www.statista.com (Most used programming languages in 2022) +data: Dict[str, List] = { + # List of programming languages + "Language": ["JavaScript", "HTML/CSS", "SQL", "Python", "Typescript", "Java", "Bash/Shell"], + # Percentage of usage, per language + "%": [65.36, 55.08, 49.43, 48.07, 34.83, 33.27, 29.07], +} + +# Close the shape for a nice-looking stroke +# If the first point is *not* appended to the end of the list, +# then the shape does not look as it is closed. +data["%"].append(data["%"][0]) +data["Language"].append(data["Language"][0]) + +layout = { + "polar": { + "radialaxis": { + # Force the radial range to 0-100 + "range": [0, 100], + } + }, + # Hide legend + "showlegend": False, +} + +options = { + # Fill the trace + "fill": "toself" +} + +md = """ <|{data}|chart|type=scatterpolar|r=%|theta=Language|options={options}|layout={layout}|> - """ +""" - Gui(md).run() +if __name__ == "__main__": + Gui(md).run(title="Chart - Radar - Simple") diff --git a/doc/gui/examples/charts/scatter-classification.py b/doc/gui/examples/charts/scatter-classification.py index 4691b22161..7f563c8421 100644 --- a/doc/gui/examples/charts/scatter-classification.py +++ b/doc/gui/examples/charts/scatter-classification.py @@ -20,26 +20,24 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Let scikit-learn generate a random 2-class classification problem - features, label = make_classification(n_samples=1000, n_features=2, n_informative=2, n_redundant=0) - - random_data = pandas.DataFrame({"x": features[:, 0], "y": features[:, 1], "label": label}) +# Let scikit-learn generate a random 2-class classification problem +features, label = make_classification(n_samples=1000, n_features=2, n_informative=2, n_redundant=0) - data_x = random_data["x"] - class_A = [ - random_data.loc[i, "y"] if random_data.loc[i, "label"] == 0 else numpy.nan for i in range(len(random_data)) - ] - class_B = [ - random_data.loc[i, "y"] if random_data.loc[i, "label"] == 1 else numpy.nan for i in range(len(random_data)) - ] +random_data = pandas.DataFrame({"x": features[:, 0], "y": features[:, 1], "label": label}) - data = {"x": random_data["x"], "Class A": class_A, "Class B": class_B} +data_x = random_data["x"] +class_A = [ + random_data.loc[i, "y"] if random_data.loc[i, "label"] == 0 else numpy.nan for i in range(len(random_data)) +] +class_B = [ + random_data.loc[i, "y"] if random_data.loc[i, "label"] == 1 else numpy.nan for i in range(len(random_data)) +] - page = """ -# Scatter - Classification +data = {"x": random_data["x"], "Class A": class_A, "Class B": class_B} +page = """ <|{data}|chart|mode=markers|x=x|y[1]=Class A|y[2]=Class B|width=60%|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Scatter - Classification") diff --git a/doc/gui/examples/charts/scatter-more-styling.py b/doc/gui/examples/charts/scatter-more-styling.py index 1da988f652..daf0dd62b9 100644 --- a/doc/gui/examples/charts/scatter-more-styling.py +++ b/doc/gui/examples/charts/scatter-more-styling.py @@ -15,63 +15,61 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - data = [ - { - "x": [1, 2, 3, 4], - "y": [10, 11, 12, 13], - }, - { - "x": [1, 2, 3, 4], - "y": [11, 12, 13, 14], - }, - { - "x": [1, 2, 3, 4], - "y": [12, 13, 14, 15], - }, - ] - - options = [ - # First data set is represented by increasingly large - # disks, getting more and more opaque - {"marker": {"color": "red", "size": [12, 22, 32, 42], "opacity": [0.2, 0.5, 0.7, 1]}}, - # Second data set is represented with a different symbol - # for each data point - { - "marker": {"color": "blue", "size": 18, "symbol": ["circle", "square", "diamond", "cross"]}, - }, - # Third data set is represented with green disks surrounded - # by a red circle that becomes thicker and thicker - { - "marker": {"color": "green", "size": 20, "line": {"color": "red", "width": [2, 4, 6, 8]}}, - }, - ] +data = [ + { + "x": [1, 2, 3, 4], + "y": [10, 11, 12, 13], + }, + { + "x": [1, 2, 3, 4], + "y": [11, 12, 13, 14], + }, + { + "x": [1, 2, 3, 4], + "y": [12, 13, 14, 15], + }, +] - markers = [ - # First data set is represented by increasingly large - # disks, getting more and more opaque - {"color": "red", "size": [12, 22, 32, 42], "opacity": [0.2, 0.5, 0.7, 1]}, - # Second data set is represented with a different symbol - # for each data point - {"color": "blue", "size": 18, "symbol": ["circle", "square", "diamond", "cross"]}, - # Third data set is represented with green disks surrounded - # by a red circle that becomes thicker and thicker - {"color": "green", "size": 20, "line": {"color": "red", "width": [2, 4, 6, 8]}}, - ] +options = [ + # First data set is represented by increasingly large + # disks, getting more and more opaque + {"marker": {"color": "red", "size": [12, 22, 32, 42], "opacity": [0.2, 0.5, 0.7, 1]}}, + # Second data set is represented with a different symbol + # for each data point + { + "marker": {"color": "blue", "size": 18, "symbol": ["circle", "square", "diamond", "cross"]}, + }, + # Third data set is represented with green disks surrounded + # by a red circle that becomes thicker and thicker + { + "marker": {"color": "green", "size": 20, "line": {"color": "red", "width": [2, 4, 6, 8]}}, + }, +] - layout = { - # Hide the chart legend - "showlegend": False, - # Remove all ticks from the x axis - "xaxis": {"showticklabels": False}, - # Remove all ticks from the y axis - "yaxis": {"showticklabels": False}, - } +markers = [ + # First data set is represented by increasingly large + # disks, getting more and more opaque + {"color": "red", "size": [12, 22, 32, 42], "opacity": [0.2, 0.5, 0.7, 1]}, + # Second data set is represented with a different symbol + # for each data point + {"color": "blue", "size": 18, "symbol": ["circle", "square", "diamond", "cross"]}, + # Third data set is represented with green disks surrounded + # by a red circle that becomes thicker and thicker + {"color": "green", "size": 20, "line": {"color": "red", "width": [2, 4, 6, 8]}}, +] - page = """ -## Scatter - Customize markers +layout = { + # Hide the chart legend + "showlegend": False, + # Remove all ticks from the x axis + "xaxis": {"showticklabels": False}, + # Remove all ticks from the y axis + "yaxis": {"showticklabels": False}, +} +page = """ <|{data}|chart|mode=markers|layout={layout}|marker={markers}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Scatter - Customize markers") diff --git a/doc/gui/examples/charts/scatter-regression.py b/doc/gui/examples/charts/scatter-regression.py index 1719463d7a..ebfca12c31 100644 --- a/doc/gui/examples/charts/scatter-regression.py +++ b/doc/gui/examples/charts/scatter-regression.py @@ -20,23 +20,21 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Let scikit-learn generate a random regression problem - n_samples = 300 - X, y, coef = make_regression(n_samples=n_samples, n_features=1, n_informative=1, n_targets=1, noise=25, coef=True) - - model = LinearRegression().fit(X, y) +# Let scikit-learn generate a random regression problem +n_samples = 300 +X, y, coef = make_regression(n_samples=n_samples, n_features=1, n_informative=1, n_targets=1, noise=25, coef=True) - x_data = X.flatten() - y_data = y.flatten() - predict = model.predict(X) +model = LinearRegression().fit(X, y) - data = {"x": x_data, "y": y_data, "Regression": predict} +x_data = X.flatten() +y_data = y.flatten() +predict = model.predict(X) - page = """ -# Scatter - Regression +data = {"x": x_data, "y": y_data, "Regression": predict} +page = """ <|{data}|chart|x=x|y[1]=y|mode[1]=markers|y[2]=Regression|mode[2]=line|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Scatter - Regression") diff --git a/doc/gui/examples/charts/scatter-styling.py b/doc/gui/examples/charts/scatter-styling.py index 5c0d7575c5..1411123b28 100644 --- a/doc/gui/examples/charts/scatter-styling.py +++ b/doc/gui/examples/charts/scatter-styling.py @@ -20,24 +20,22 @@ from taipy.gui import Gui -if __name__ == "__main__": - # Let scikit-learn generate a random 2-class classification problem - n_samples = 100 - features, label = make_classification(n_samples=n_samples, n_features=2, n_informative=2, n_redundant=0) - - random_data = pd.DataFrame({"x": features[:, 0], "y": features[:, 1], "label": label}) +# Let scikit-learn generate a random 2-class classification problem +n_samples = 100 +features, label = make_classification(n_samples=n_samples, n_features=2, n_informative=2, n_redundant=0) - data_x = random_data["x"] - class_A = [random_data.loc[i, "y"] if random_data.loc[i, "label"] == 0 else np.nan for i in range(n_samples)] - class_B = [random_data.loc[i, "y"] if random_data.loc[i, "label"] == 1 else np.nan for i in range(n_samples)] +random_data = pd.DataFrame({"x": features[:, 0], "y": features[:, 1], "label": label}) - data = {"x": random_data["x"], "Class A": class_A, "Class B": class_B} - marker_A = {"symbol": "circle-open", "size": 16} - marker_B = {"symbol": "triangle-up-dot", "size": 20, "opacity": 0.7} - page = """ -# Scatter - Styling +data_x = random_data["x"] +class_A = [random_data.loc[i, "y"] if random_data.loc[i, "label"] == 0 else np.nan for i in range(n_samples)] +class_B = [random_data.loc[i, "y"] if random_data.loc[i, "label"] == 1 else np.nan for i in range(n_samples)] +data = {"x": random_data["x"], "Class A": class_A, "Class B": class_B} +marker_A = {"symbol": "circle-open", "size": 16} +marker_B = {"symbol": "triangle-up-dot", "size": 20, "opacity": 0.7} +page = """ <|{data}|chart|mode=markers|x=x|y[1]=Class A|y[2]=Class B|width=60%|marker[1]={marker_A}|marker[2]={marker_B}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Scatter - Styling") diff --git a/doc/gui/examples/charts/treemap-hierarchical-values.py b/doc/gui/examples/charts/treemap-hierarchical-values.py index 6a10876928..b4d003bddb 100644 --- a/doc/gui/examples/charts/treemap-hierarchical-values.py +++ b/doc/gui/examples/charts/treemap-hierarchical-values.py @@ -15,69 +15,67 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Major countries and their surface (in km2), for every continent - # Source: https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area - continents = { - "Africa": [ - {"name": "Algeria", "surface": 2381741}, - {"name": "Dem. Rep. Congo", "surface": 2344858}, - {"name": "Sudan", "surface": 1886068}, - {"name": "Libya", "surface": 1759540}, - {"name": "Chad", "surface": 1284000}, - ], - "Asia": [ - {"name": "Russia-Asia", "surface": 17098246}, - {"name": "China", "surface": 9596961}, - {"name": "India", "surface": 3287263}, - {"name": "Kazakhstan", "surface": 2724900}, - {"name": "Saudi Arabia", "surface": 2149690}, - ], - "Europe": [ - {"name": "Russia-Eur", "surface": 3972400}, - {"name": "Ukraine", "surface": 603628}, - {"name": "France", "surface": 551695}, - {"name": "Spain", "surface": 498980}, - {"name": "Sweden", "surface": 450295}, - ], - "Americas": [ - {"name": "Canada", "surface": 9984670}, - {"name": "U.S.A.", "surface": 9833517}, - {"name": "Brazil", "surface": 8515767}, - {"name": "Argentina", "surface": 2780400}, - {"name": "Mexico", "surface": 1964375}, - ], - "Oceania": [ - {"name": "Australia", "surface": 7692024}, - {"name": "Papua New Guinea", "surface": 462840}, - {"name": "New Zealand", "surface": 270467}, - {"name": "Solomon Islands", "surface": 28896}, - {"name": "Fiji", "surface": 18274}, - ], - "Antarctica": [{"name": "Whole", "surface": 14200000}], - } - - name: list = [] - surface: list = [] - continent: list = [] +# Major countries and their surface (in km2), for every continent +# Source: https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area +continents = { + "Africa": [ + {"name": "Algeria", "surface": 2381741}, + {"name": "Dem. Rep. Congo", "surface": 2344858}, + {"name": "Sudan", "surface": 1886068}, + {"name": "Libya", "surface": 1759540}, + {"name": "Chad", "surface": 1284000}, + ], + "Asia": [ + {"name": "Russia-Asia", "surface": 17098246}, + {"name": "China", "surface": 9596961}, + {"name": "India", "surface": 3287263}, + {"name": "Kazakhstan", "surface": 2724900}, + {"name": "Saudi Arabia", "surface": 2149690}, + ], + "Europe": [ + {"name": "Russia-Eur", "surface": 3972400}, + {"name": "Ukraine", "surface": 603628}, + {"name": "France", "surface": 551695}, + {"name": "Spain", "surface": 498980}, + {"name": "Sweden", "surface": 450295}, + ], + "Americas": [ + {"name": "Canada", "surface": 9984670}, + {"name": "U.S.A.", "surface": 9833517}, + {"name": "Brazil", "surface": 8515767}, + {"name": "Argentina", "surface": 2780400}, + {"name": "Mexico", "surface": 1964375}, + ], + "Oceania": [ + {"name": "Australia", "surface": 7692024}, + {"name": "Papua New Guinea", "surface": 462840}, + {"name": "New Zealand", "surface": 270467}, + {"name": "Solomon Islands", "surface": 28896}, + {"name": "Fiji", "surface": 18274}, + ], + "Antarctica": [{"name": "Whole", "surface": 14200000}], +} - for continent_name, countries in continents.items(): - # Create continent in root rectangle - name.append(continent_name) - surface.append(0) - continent.append("") - # Create countries in that continent rectangle - for country in countries: - name.append(country["name"]) - surface.append(country["surface"]) - continent.append(continent_name) +name: list = [] +surface: list = [] +continent: list = [] - data = {"names": name, "surfaces": surface, "continent": continent} +for continent_name, countries in continents.items(): + # Create continent in root rectangle + name.append(continent_name) + surface.append(0) + continent.append("") + # Create countries in that continent rectangle + for country in countries: + name.append(country["name"]) + surface.append(country["surface"]) + continent.append(continent_name) - page = """ -# TreeMap - Hierarchical values +data = {"names": name, "surfaces": surface, "continent": continent} +page = """ <|{data}|chart|type=treemap|labels=names|values=surfaces|parents=continent|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - TreeMap - Hierarchical values") diff --git a/doc/gui/examples/charts/treemap-hierarchical.py b/doc/gui/examples/charts/treemap-hierarchical.py index 610c9049ef..d231b618e6 100644 --- a/doc/gui/examples/charts/treemap-hierarchical.py +++ b/doc/gui/examples/charts/treemap-hierarchical.py @@ -15,62 +15,60 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Partial family tree of the British House of Windsor - # Source: https://en.wikipedia.org/wiki/Family_tree_of_the_British_royal_family - tree = { - "name": [ - "Queen Victoria", - "Princess Victoria", - "Edward VII", - "Alice", - "Alfred", - "Wilhelm II", - "Albert Victor", - "George V", - "Louise", - "Ernest Louis", - "Alfred (2)", - "Marie", - "Victoria Melita", - "Edward VIII", - "George VI", - "Mary", - "Elizabeth II", - "Margaret", - "Charles III", - "Anne", - "Andrew", - ], - "parent": [ - "", - "Queen Victoria", - "Queen Victoria", - "Queen Victoria", - "Queen Victoria", - "Princess Victoria", - "Edward VII", - "Edward VII", - "Edward VII", - "Alice", - "Alfred", - "Alfred", - "Alfred", - "George V", - "George V", - "George V", - "George VI", - "George VI", - "Elizabeth II", - "Elizabeth II", - "Elizabeth II", - ], - } - - page = """ -# TreeMap - Hierarchical +# Partial family tree of the British House of Windsor +# Source: https://en.wikipedia.org/wiki/Family_tree_of_the_British_royal_family +tree = { + "name": [ + "Queen Victoria", + "Princess Victoria", + "Edward VII", + "Alice", + "Alfred", + "Wilhelm II", + "Albert Victor", + "George V", + "Louise", + "Ernest Louis", + "Alfred (2)", + "Marie", + "Victoria Melita", + "Edward VIII", + "George VI", + "Mary", + "Elizabeth II", + "Margaret", + "Charles III", + "Anne", + "Andrew", + ], + "parent": [ + "", + "Queen Victoria", + "Queen Victoria", + "Queen Victoria", + "Queen Victoria", + "Princess Victoria", + "Edward VII", + "Edward VII", + "Edward VII", + "Alice", + "Alfred", + "Alfred", + "Alfred", + "George V", + "George V", + "George V", + "George VI", + "George VI", + "Elizabeth II", + "Elizabeth II", + "Elizabeth II", + ], +} +page = """ <|{tree}|chart|type=treemap|labels=name|parents=parent|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - TreeMap - Hierarchical") diff --git a/doc/gui/examples/charts/treemap-simple.py b/doc/gui/examples/charts/treemap-simple.py index 72951c453e..345d7d2e11 100644 --- a/doc/gui/examples/charts/treemap-simple.py +++ b/doc/gui/examples/charts/treemap-simple.py @@ -15,19 +15,17 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Data set: the first 10 elements of the Fibonacci sequence - n_numbers = 10 - fibonacci = [0, 1] - for i in range(2, n_numbers): - fibonacci.append(fibonacci[i - 1] + fibonacci[i - 2]) - - data = {"index": list(range(1, n_numbers + 1)), "fibonacci": fibonacci} +# Data set: the first 10 elements of the Fibonacci sequence +n_numbers = 10 +fibonacci = [0, 1] +for i in range(2, n_numbers): + fibonacci.append(fibonacci[i - 1] + fibonacci[i - 2]) - page = """ -# TreeMap - Simple +data = {"index": list(range(1, n_numbers + 1)), "fibonacci": fibonacci} +page = """ <|{data}|chart|type=treemap|labels=index|values=fibonacci|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - TreeMap - Simple") diff --git a/doc/gui/examples/charts/waterfall-period_levels.py b/doc/gui/examples/charts/waterfall-period_levels.py index b822577bfe..a7aa7f61b7 100644 --- a/doc/gui/examples/charts/waterfall-period_levels.py +++ b/doc/gui/examples/charts/waterfall-period_levels.py @@ -15,23 +15,21 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Data set - data = [ - { - # The quarterly periods are grouped by year - "Period": [["Carry", "Q1", "Q2", "Q3", "Q4", "Current"], ["N-1", "N", "N", "N", "N", "N+1"]] - }, - { - "Cash Flow": [25, -17, 12, 18, -8, None], - "Measure": ["absolute", "relative", "relative", "relative", "relative", "total"], - }, - ] - - page = """ -# Waterfall - Period levels +# Data set +data = [ + { + # The quarterly periods are grouped by year + "Period": [["Carry", "Q1", "Q2", "Q3", "Q4", "Current"], ["N-1", "N", "N", "N", "N", "N+1"]] + }, + { + "Cash Flow": [25, -17, 12, 18, -8, None], + "Measure": ["absolute", "relative", "relative", "relative", "relative", "total"], + }, +] +page = """ <|{data}|chart|type=waterfall|x=0/Period|y=1/Cash Flow|measure=1/Measure|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Waterfall - Period levels") diff --git a/doc/gui/examples/charts/waterfall-simple.py b/doc/gui/examples/charts/waterfall-simple.py index 07d4a47842..7581d03d50 100644 --- a/doc/gui/examples/charts/waterfall-simple.py +++ b/doc/gui/examples/charts/waterfall-simple.py @@ -15,18 +15,16 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # Data set - data = { - "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"], - "Values": [10, -5, 20, -10, 30], - "Measure": ["absolute", "relative", "relative", "relative", "relative"], - } - - page = """ -# Waterfall - Simple +# Data set +data = { + "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"], + "Values": [10, -5, 20, -10, 30], + "Measure": ["absolute", "relative", "relative", "relative", "relative"], +} +page = """ <|{data}|chart|type=waterfall|x=Day|y=Values|measure=Measure|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Waterfall - Simple") diff --git a/doc/gui/examples/charts/waterfall-styling.py b/doc/gui/examples/charts/waterfall-styling.py index 2b8b391169..b83b83e777 100644 --- a/doc/gui/examples/charts/waterfall-styling.py +++ b/doc/gui/examples/charts/waterfall-styling.py @@ -15,33 +15,31 @@ # ----------------------------------------------------------------------------------------- from taipy.gui import Gui -if __name__ == "__main__": - # 9-hole course - n_holes = 9 - - # Data set - # Each entry holds an array of values. One for each hole, plus one for th - data = { - # ["Hole1", "Hole2", ..., "Hole9"] - "Hole": [f"Hole{h}" for h in range(1, n_holes + 1)] + ["Score"], - # Par for each hole - "Par": [3, 4, 4, 5, 3, 5, 4, 5, 3] + [None], # type: ignore - # Score for each hole - "Score": [4, 4, 5, 4, 4, 5, 4, 5, 4] + [None], # type: ignore - # Represented as relative values except for the last one - "M": n_holes * ["relative"] + ["total"], - } +# 9-hole course +n_holes = 9 - # Compute difference (Score-Par) - data["Diff"] = [data["Score"][i] - data["Par"][i] for i in range(0, n_holes)] + [None] # type: ignore[index] +# Data set +# Each entry holds an array of values. One for each hole, plus one for th +data = { + # ["Hole1", "Hole2", ..., "Hole9"] + "Hole": [f"Hole{h}" for h in range(1, n_holes + 1)] + ["Score"], + # Par for each hole + "Par": [3, 4, 4, 5, 3, 5, 4, 5, 3] + [None], # type: ignore + # Score for each hole + "Score": [4, 4, 5, 4, 4, 5, 4, 5, 4] + [None], # type: ignore + # Represented as relative values except for the last one + "M": n_holes * ["relative"] + ["total"], +} - # Show positive values in red, and negative values in green - options = {"decreasing": {"marker": {"color": "green"}}, "increasing": {"marker": {"color": "red"}}} +# Compute difference (Score-Par) +data["Diff"] = [data["Score"][i] - data["Par"][i] for i in range(0, n_holes)] + [None] # type: ignore[index] - page = """ -# Waterfall - Styling +# Show positive values in red, and negative values in green +options = {"decreasing": {"marker": {"color": "green"}}, "increasing": {"marker": {"color": "red"}}} +page = """ <|{data}|chart|type=waterfall|x=Hole|y=Diff|measure=M|options={options}|> - """ +""" - Gui(page).run() +if __name__ == "__main__": + Gui(page).run(title="Chart - Waterfall - Styling") diff --git a/doc/gui/examples/controls/button_action.py b/doc/gui/examples/controls/button_action.py new file mode 100644 index 0000000000..e2fc06b04d --- /dev/null +++ b/doc/gui/examples/controls/button_action.py @@ -0,0 +1,30 @@ +# Copyright 2021-2024 Avaiga Private Limited +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on +# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the +# specific language governing permissions and limitations under the License. +# ----------------------------------------------------------------------------------------- +# To execute this script, make sure that the taipy-gui package is installed in your +# Python environment and run: +# python