from taipy.gui import Gui      def test_menu_md(gui: Gui, test_client, helpers):      gui._bind_var_val("lov", ["Item 1", "Item 2", "Item 3", "Item 4"])      md_string = "<|menu|lov={lov}|on_action=on_menu_action|>"      expected_list = [          "<MenuCtl",          'libClassName="taipy-menu"',          'defaultLov="["Item 1", "Item 2", "Item 3", "Item 4"]"',          "lov={_TpL_tpec_TpExPr_lov_TPMDL_0}",          'onAction="on_menu_action"',          'updateVars="lov=_TpL_tpec_TpExPr_lov_TPMDL_0"',      ]      helpers.test_control_md(gui, md_string, expected_list)      def test_menu_html(gui: Gui, test_client, helpers):      gui._bind_var_val("lov", ["Item 1", "Item 2", "Item 3", "Item 4"])      html_string = '<taipy:menu lov="{lov}" />'      expected_list = [          "<MenuCtl",          'libClassName="taipy-menu"',          'defaultLov="["Item 1", "Item 2", "Item 3", "Item 4"]"',          "lov={_TpL_tpec_TpExPr_lov_TPMDL_0}",          'updateVars="lov=_TpL_tpec_TpExPr_lov_TPMDL_0"',      ]      helpers.test_control_html(gui, html_string, expected_list)


from taipy.gui import Gui      def test_layout_md_1(gui: Gui, helpers):      md_string = """  <|layout|columns=1 1|gap=1rem|  # This is a layout section  |>  """      expected_list = ["<Layout", 'columns="1 1', 'gap="1rem"', "<h1", "This is a layout section"]      helpers.test_control_md(gui, md_string, expected_list)      def test_layout_md_2(gui: Gui, helpers):      md_string = """  <|layout.start|columns=1 1|gap=1rem|>  # This is a layout section  <|layout.end|>  """      expected_list = ["<Layout", 'columns="1 1', 'gap="1rem"', "<h1", "This is a layout section"]      helpers.test_control_md(gui, md_string, expected_list)      def test_layout_html(gui: Gui, helpers):      html_string = '<taipy:layout columns="1 1" gap="1rem">
This is a layout section
</taipy:layout>'      expected_list = ["<Layout", 'columns="1 1', 'gap="1rem"', "<h1", "This is a layout section"]      helpers.test_control_html(gui, html_string, expected_list)


from taipy.gui import Gui      def test_number_md_1(gui: Gui, helpers):      md_string = "<|10|number|>"      expected_list = ["<Input", 'value="10"', 'type="number"']      helpers.test_control_md(gui, md_string, expected_list)      def test_number_md_2(gui: Gui, test_client, helpers):      gui._bind_var_val("x", "10")      md_string = "<|{x}|number|>"      expected_list = [          "<Input",          'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',          'defaultValue="10"',          'type="number"',          "value={_TpN_tpec_TpExPr_x_TPMDL_0}",      ]      helpers.test_control_md(gui, md_string, expected_list)      def test_number_html_1(gui: Gui, test_client, helpers):      gui._bind_var_val("x", 10)      html_string = '<taipy:number value="{x}" />'      expected_list = [          "<Input",          'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',          'defaultValue="10"',          'type="number"',          "value={_TpN_tpec_TpExPr_x_TPMDL_0}",      ]      helpers.test_control_html(gui, html_string, expected_list)      def test_number_html_2(gui: Gui, test_client, helpers):      gui._bind_var_val("x", 10)      html_string = "<taipy:number>{x}</taipy:number>"      expected_list = [          "<Input",          'updateVarName="_TpN_tpec_TpExPr_x_TPMDL_0"',          'defaultValue="10"',          'type="number"',          "value={_TpN_tpec_TpExPr_x_TPMDL_0}",      ]      helpers.test_control_html(gui, html_string, expected_list)


from datetime import datetime    from taipy.gui import Gui      def test_date_md_1(gui: Gui, test_client, helpers):      gui._bind_var_val("date", datetime.strptime("15 Dec 2020", "%d %b %Y"))      md_string = "<|{date}|date|>"      expected_list = [          "<DateSelector",          'defaultDate="2020-12-',          'updateVarName="_TpDt_tpec_TpExPr_date_TPMDL_0"',          "date={_TpDt_tpec_TpExPr_date_TPMDL_0}",      ]      helpers.test_control_md(gui, md_string, expected_list)      def test_date_md_2(gui: Gui, test_client, helpers):      gui._bind_var_val("date", datetime.strptime("15 Dec 2020", "%d %b %Y"))      md_string = "<|{date}|date|with_time|label=a label|>"      expected_list = [          "<DateSelector",          'defaultDate="2020-12-',          'updateVarName="_TpDt_tpec_TpExPr_date_TPMDL_0"',          "date={_TpDt_tpec_TpExPr_date_TPMDL_0}",          "withTime={true}",          'label="a label"',      ]      helpers.test_control_md(gui, md_string, expected_list)      def test_date_html_1(gui: Gui, test_client, helpers):      gui._bind_var_val("date", datetime.strptime("15 Dec 2020", "%d %b %Y"))      html_string = '<taipy:date date="{date}" />'      expected_list = [          "<DateSelector",          'defaultDate="2020-12-',          'updateVarName="_TpDt_tpec_TpExPr_date_TPMDL_0"',          "date={_TpDt_tpec_TpExPr_date_TPMDL_0}",      ]      helpers.test_control_html(gui, html_string, expected_list)      def test_date_html_2(gui: Gui, test_client, helpers):      gui._bind_var_val("date", datetime.strptime("15 Dec 2020", "%d %b %Y"))      html_string = "<taipy:date>{date}</taipy:date>"      expected_list = [          "<DateSelector",          'defaultDate="2020-12-',          'updateVarName="_TpDt_tpec_TpExPr_date_TPMDL_0"',          "date={_TpDt_tpec_TpExPr_date_TPMDL_0}",      ]      helpers.test_control_html(gui, html_string, expected_list)


from taipy.gui import Gui      def test_indicator_md(gui: Gui, test_client, helpers):      gui._bind_var_val("val", 15)      md_string = "<|12|indicator|value={val}|min=1|max=20|format=%.2f|>"      expected_list = [          "<Indicator",          'libClassName="taipy-indicator"',          "defaultValue={15}",          "display={12.0}",          'format="%.2f"',          "max={20.0}",          "min={1.0}",          "value={_TpN_tpec_TpExPr_val_TPMDL_0}",      ]      helpers.test_control_md(gui, md_string, expected_list)      def test_menu_html(gui: Gui, test_client, helpers):      gui._bind_var_val("val", 15)      html_string = '<taipy:indicator value="{val}" min="1" max="20" format="%.2f" >12</taipy:indicator>'      expected_list = [          "<Indicator",          'libClassName="taipy-indicator"',          "defaultValue={15}",          "display={12.0}",          'format="%.2f"',          "max={20.0}",          "min={1.0}",          "value={_TpN_tpec_TpExPr_val_TPMDL_0}",      ]      helpers.test_control_html(gui, html_string, expected_list)


from taipy.gui import Gui      def test_navbar_md(gui: Gui, test_client, helpers):      gui._bind_var_val(          "navlov",          [              ("/page1", "Page 1"),              ("/page2", "Page 2"),              ("/page3", "Page 3"),              ("/page4", "Page 4"),          ],      )      md_string = "<|navbar|lov={navlov}|>"      expected_list = [          "<NavBar",          'defaultLov="[["/page1", "Page 1"], ["/page2", "Page 2"], ["/page3", "Page 3"], ["/page4", "Page 4"]]"',          "lov={_TpL_tpec_TpExPr_navlov_TPMDL_0}",      ]      helpers.test_control_md(gui, md_string, expected_list)      def test_navbar_html(gui: Gui, test_client, helpers):      gui._bind_var_val(          "navlov",          [              ("/page1", "Page 1"),              ("/page2", "Page 2"),              ("/page3", "Page 3"),              ("/page4", "Page 4"),          ],      )      html_string = '<taipy:navbar lov="{navlov}" />'      expected_list = [          "<NavBar",          'defaultLov="[["/page1", "Page 1"], ["/page2", "Page 2"], ["/page3", "Page 3"], ["/page4", "Page 4"]]"',          "lov={_TpL_tpec_TpExPr_navlov_TPMDL_0}",      ]      helpers.test_control_html(gui, html_string, expected_list)


from taipy.gui import Gui      def test_part_md_1(gui: Gui, helpers):      md_string = """  <|part|class_name=class1|  # This is a part  |>  """      expected_list = ["<Part", "<h1", "This is a part"]      helpers.test_control_md(gui, md_string, expected_list)      def test_part_md_2(gui: Gui, helpers):      md_string = """  <|part.start|class_name=class1|>  # This is a part  <|part.end|>  """      expected_list = ["<Part", "<h1", "This is a part"]      helpers.test_control_md(gui, md_string, expected_list)      def test_part_html(gui: Gui, helpers):      html_string = '<taipy:part class_name="class1">
This is a part
</taipy:part>'      expected_list = ["<Part", "<h1", "This is a part"]      helpers.test_control_html(gui, html_string, expected_list)


import random  import string    from example_library import ExampleLibrary    from taipy.gui import Gui    # Initial value  label = "Here is some text"    page = """  # Custom elements example    ## Fraction:    No denominator: <|123|example.fraction|>    Denominator is 0: <|321|example.fraction|denominator=0|>    Regular: <|355|example.fraction|denominator=113|>    ## Custom label:    Colored text: <|{label}|example.label|>    <|Add a character|button|id=addChar|>  <|Remove a character|button|id=removeChar|>  """      def on_action(state, id):      if id == "addChar":          # Add a random character to the end of 'label'          state.label += random.choice(string.ascii_letters)      elif id == "removeChar":          # Remove the first character of 'label'          if len(state.label) > 0:              state.label = state.label[1:]      Gui(page, libraries=[ExampleLibrary()]).run(debug=True)


from .example_library import ExampleLibrary


from taipy.gui.extension import Element, ElementLibrary, ElementProperty, PropertyType      class ExampleLibrary(ElementLibrary):      def __init__(self) -> None:          # Initialize the set of visual elements for this extension library          self.elements = {              # A static element that displays its properties in a fraction              "fraction": Element(                  "numerator",                  {                      "numerator": ElementProperty(PropertyType.number),                      "denominator": ElementProperty(PropertyType.number),                  },                  render_xhtml=ExampleLibrary._fraction_render,              ),              # A dynamic element that decorates its value              "label": Element(                  "value",                  {"value": ElementProperty(PropertyType.dynamic_string)},                  # The name of the React component (ColoredLabel) that implements this custom                  # element, exported as ExampleLabel in front-end/src/index.ts                  react_component="ExampleLabel",              ),          }        # The implementation of the rendering for the "fraction" static element      @staticmethod      def _fraction_render(props: dict) -> str:          # Get the property values          numerator = props.get("numerator")          denominator = props.get("denominator")          # No denominator or numerator is 0: display the numerator          if denominator is None or int(numerator) == 0:              return f"{numerator}"          # Denominator is zero: display infinity          if int(denominator) == 0:              return '∞'          # 'Normal' case          return f"{numerator}/{denominator}"        def get_name(self) -> str:          return "example"        def get_elements(self) -> dict:          return self.elements        def get_scripts(self) -> list[str]:          # Only one JavaScript bundle for this library.          return ["front-end/dist/exampleLibrary.js"]


#  # 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 <script>  # -----------------------------------------------------------------------------------------  # Demonstrate how to share variable values across multiple clients.  # This application creates a thread that increments a value every few seconds.  # The value is updated for every client using the state.broadcast() method.  # The text of the button that starts or stops the thread is updated on every client's browser  # using a direct assignment of the state property because the variable is declared 'shared'.  # -----------------------------------------------------------------------------------------  from threading import Event, Thread  from time import sleep    from taipy.gui import Gui, State, broadcast_callback    counter = 0    # Thread management  thread = None  thread_event = Event()    button_texts = ["Start", "Stop"]  # Text in the start/stop button (initially "Start")  button_text = button_texts[0]      # Invoked by the timer  def update_counter(state: State, c):      # Update all clients      state.broadcast("counter", c)      def count(event, gui):      while not event.is_set():          global counter          counter = counter + 1          broadcast_callback(gui, update_counter, [counter])          sleep(2)      # Start or stop the timer when the button is pressed  def start_or_stop(state):      global thread      if thread:  # Timer is running          thread_event.set()          thread = None      else:  # Timer is stopped          thread_event.clear()          thread = Thread(target=count, args=[thread_event, state.get_gui()])          thread.start()      # Update button status.      # Because "button_text" is shared, all clients are updated      state.button_text = button_texts[1 if thread else 0]      page = """# Broadcasting values    Counter: <|{counter}|>    Timer: <|{button_text}|button|on_action=start_or_stop|>  """    # 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()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  # Demonstrates the use of the 'rebuild' property of the 'chart' control  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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]    page = """  <|{data}|chart|type={selected_type[0]}|x=X|y=Y|rebuild|>    <|{selected_type}|toggle|lov={types}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import datetime    from taipy.gui import Gui    # 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    <|{data}|chart|type=bar|orientation=h|y=Task|x=Date|base=start|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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]}    page = """  # Basics - X range    <|{data}|chart|x=X|y=Y|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui      # Function to plot: x^3/3-x  def f(x):      return x * x * x / 3 - x      # 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],  }    shape_size = 0.1    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 = """  # Advanced - Annotations    <|{data}|chart|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import numpy    from taipy.gui import Gui      # Return the x and y coordinates of the spiral for the given angle  def spiral(th):      a = 1.120529      b = 0.306349      r = a * numpy.exp(-b * th)      return (r * numpy.cos(th), r * numpy.sin(th))      # 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]    # 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]]    # 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],      },  ]    # Axis template: hide all ticks, lines and labels  axis = {"range": [0, 2.0], "showgrid": False, "zeroline": False, "showticklabels": False, "ticks": "", "title": ""}    layout = {      # Use the axis template for both x and y axes      "xaxis": axis,      "yaxis": axis,  }    options = {      # Hide the color scale of the heatmap      "showscale": False  }    # 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 = """  ## Heatmap - Drawing on top    <|{data}|chart|type={types}|z[1]=0/z|x={xs}|y={ys}|layout={layout}|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    from taipy.gui import Gui    # Data set made of two series of random numbers  data = {"A": [random.random() for i in range(200)], "B": [random.random() for i in range(200)]}    # Names of the two traces  names = ["A samples", "B samples"]    layout = {      # Make the histogram stack the data sets      "barmode": "stack"  }    page = """  # Histogram - Stacked    <|{data}|chart|type=histogram|x[1]=A|x[2]=B|name={names}|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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}|chart|type=waterfall|x=Day|y=Values|measure=Measure|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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]  }    layout = {      # Hide the legend      "showlegend": False  }    options = {      # Hide the texts      "textinfo": "none"  }    page = """  # Pie - Style    <|{values}|chart|type=pie|marker={marker}|options={options}|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from datetime import datetime    import numpy    from taipy.gui import Gui      def generate_hand_shapes():      # Retrieve and store the current, local time      time_now = datetime.now()      hours = time_now.hour      minutes = time_now.minute      seconds = time_now.second        # Compute the angle that represents the hours      hours_angle = 360 * ((hours % 12) / 12 + (minutes % 60) / 60 / 60 + (seconds % 60) / 60 / 60 / 60)      # Short and thick hand for the hours      hours_hand = {"r": [0, 4, 5, 4, 0], "a": [0, hours_angle - 7, hours_angle, hours_angle + 7, 0]}        # Compute the angle that represents the minutes      minutes_angle = 360 * ((minutes % 60) / 60 + (seconds % 60) / 60 / 60)      # Longer and slighly thinner hand for the minutes      minutes_hand = {"r": [0, 6, 8, 6, 0], "a": [0, minutes_angle - 4, minutes_angle, minutes_angle + 4, 0]}        # Compute the angle that represents the seconds      seconds_angle = 360 * (seconds % 60) / 60      # Even longer and thinner hand for the seconds      seconds_hand = {"r": [0, 8, 10, 8, 0], "a": [0, seconds_angle - 2, seconds_angle, seconds_angle + 2, 0]}      # Build and return the whole data set      return [hours_hand, minutes_hand, seconds_hand]      # 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]},      },      "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,  }      # Update time on every refresh  def on_navigate(state, page):      state.data = generate_hand_shapes()      return page      page = """  # Polar - Tick texts    <|{data}|chart|type=scatterpolar|properties={properties}|>  """  Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    data = {"Types": ["Visits", "Downloads", "Prospects", "Invoiced", "Closed"], "Visits": [13873, 10533, 5443, 2703, 908]}    layout = {      # Stack the areas      "funnelmode": "stack",      # Hide the legend      "showlegend": False,  }    page = """  # Funnel - Area    <|{data}|chart|type=funnelarea|values=Visits|text=Types|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import pandas    from taipy.gui import Gui    # 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    <|{data}|chart|type=bar|x=Year|y[1]=Won|y[2]=Lost|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import numpy  import pandas    from taipy.gui import Gui    # 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    <|{data}|chart|x=Date|y=Value|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    from taipy.gui import Gui    # Data set made of two series of random numbers  data = [{"x": [random.random() + 1 for i in range(100)]}, {"x": [random.random() + 1.1 for i 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"}},  ]    layout = {      # Overlay the two histograms      "barmode": "overlay",      # Hide the legend      "showlegend": False,  }    page = """  # Histogram - Overlay    <|{data}|chart|type=histogram|options={options}|layout={layout}|>  """  Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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"},  ]    page = """  # Filled Area - Overlay    <|{data}|chart|mode=none|x=Day|y[1]=Items|y[2]=Price|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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],  }    page = """  # Basics - Multiple traces    <|{data}|chart|x=x|y[1]=y1|y[2]=y2|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  # Two data sets as a bar chart  import pandas    from taipy.gui import Gui    # 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    <|{data}|chart|type=bar|x=Year|y[1]=Won|y[2]=Lost|>  """    Gui(page).run()


#  # 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 <script>  # You may need to install the yfinance package as well.  # -----------------------------------------------------------------------------------------  import yfinance    from taipy import Gui    # 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    <|{stock}|chart|type=candlestick|x=Date|open=Open|close=Close|low=Low|high=High|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    import numpy    from taipy.gui import Gui    # x = [0..20]  x = list(range(0, 21))    data = {      "x": x,      # A list of random values within [1, 10]      "y": [random.uniform(1, 10) for _ in x],  }    layout = {      # Force the Box select tool      "dragmode": "select",      # Remove all margins around the plot      "margin": {"l": 0, "r": 0, "b": 0, "t": 0},  }    config = {      # Hide Plotly's mode bar      "displayModeBar": False  }    selected_indices = []    mean_value = 0.0      def on_change(state, var, val):      if var == "selected_indices":          state.mean_value = numpy.mean([data["y"][idx] for idx in val]) if len(val) else 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()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import math  import random    from taipy.gui import Gui    # 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,  }    options = {      # Create the error bar information:      "error_y": {"type": "data", "array": error_ranges}  }    page = """  # Error bars - Simple    <|{data}|chart|x=x|y[1]=y1|y[2]=y2|options[1]={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    data = {      "Day": ["Mon", "Tue", "Wed", "Thu", "Fri"],      "Items": [32, 25, 86, 60, 70],  }    options = {      # Fill to x axis      "fill": "tozeroy"  }    page = """  # Filled Area - Simple    <|{data}|chart|x=Day|y=Items|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import datetime    import dateutil.relativedelta    from taipy.gui import Gui    # 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 = {      # 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],  }    # Create monthly time series  months = [start_date + n * period for n in range(0, len(prices["apples"]))]    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"])),      },  ]    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 = """  # Continuous Error - Multiple traces    <|{data}|chart|properties={properties}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    from taipy.gui import Gui    # 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 i 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 i in y],          # The 'minus' error data is a series of random numbers          "arrayminus": [random.uniform(0, 2) for i in y],          # Color of the error bar          "color": "red",      }  }    page = """  # Error bars - Asymmetric    <|{data}|chart|type=bar|x=x|y=y|orientation=h|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import math    from taipy.gui import Gui    # One data point for each degree  theta = range(0, 360)      # Parametric equation that draws a shape (source Wolfram Mathworld)  def draw_heart(angle):      a = math.radians(angle)      sa = math.sin(a)      return 2 - 2 * sa + sa * (math.sqrt(math.fabs(math.cos(a))) / (sa + 1.4))      data = {      # Create the heart shape      "r": [draw_heart(angle) for angle in theta],      "theta": theta,  }    page = """  # Polar - Simple    <|{data}|chart|type=scatterpolar|mode=lines|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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,      },  ]    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          {              "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    <|{data}|chart|type=pie|x[1]=0/values|x[2]=1/values|options={options}|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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)]    # 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 = """  # Advanced - Unbalanced data sets    <|{data}|chart|x[1]=0/x|y[1]=0/Coarse|x[2]=1/x|y[2]=1/Fine|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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 displayed as a thick, red plot  line = {"width": 5, "color": "red"}    page = """  # Maps - Simple    <|{data}|chart|type=scattergeo|mode=lines|lat=lat|lon=lon|line={line}|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    from taipy.gui import Gui    # Random data set  data = {"Count": [random.random() for i in range(100)]}    page = """  # Histograms - Horizontal    <|{data}|chart|type=histogram|y=Count|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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]}},      },  ]    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]}},  ]    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 = """  ## Scatter - Customize markers    <|{data}|chart|mode=markers|layout={layout}|marker={markers}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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"]    options = {      # Group all traces in the same stack group      "stackgroup": "first_group"  }    page = """  # Filled Area - Stacked    <|{data}|chart|mode=none|x=Month|y={items}|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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}|chart|type=waterfall|x=0/Period|y=1/Cash Flow|measure=1/Measure|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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 = []  surface = []  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)    data = {"names": name, "surfaces": surface, "continent": continent}    page = """  # TreeMap - Hierarchical values    <|{data}|chart|type=treemap|labels=names|values=surfaces|parents=continent|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import datetime    from taipy.gui import Gui    # 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],  }    md = """  # Candlestick - Timeline    <|{data}|chart|type=candlestick|x=Date|open=Open|close=Close|low=Low|high=High|>  """    Gui(md).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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"]    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]},      },      # 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]},      },      # 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]},      },      # 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]},      },  ]    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 = """  # Funnel Area - Multiple Charts    <|{data}|chart|type=funnelarea|values={values}|options={options}|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import math    from taipy.gui import Gui    # One data point for each degree  theta = range(0, 360)      # Parametric equation that draws a shape (source Wolfram Mathworld)  def draw_heart(angle):      a = math.radians(angle)      sa = math.sin(a)      return 2 - 2 * sa + sa * (math.sqrt(math.fabs(math.cos(a))) / (sa + 1.4))      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    <|{data}|chart|type=scatterpolar|mode=none|layout={layout}|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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    <|{tree}|chart|type=treemap|labels=name|parents=parent|>  """    Gui(page).run()


#  # 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 <script>  # You may need to install the scikit-learn package as well.  # -----------------------------------------------------------------------------------------  import numpy as np  import pandas as pd  from sklearn.datasets import make_classification    from taipy.gui import Gui    # 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})    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 = """  # Scatter - Styling    <|{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()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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"}    page = """  # Heatmap - Colorscale    <|{data}|chart|type=heatmap|z=Temperatures|x=Seasons|y=Cities|options={options}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    layout = {      "xaxis": {          # Force the title of the x axis          "title": "Values for x"      }  }    page = """  # Basics - Title    <|{[x*x for x in range(0, 11)]}|chart|title=Plotting x squared|layout={layout}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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": [i for i in range(1, n_numbers + 1)], "fibonacci": fibonacci}    page = """  # TreeMap - Simple    <|{data}|chart|type=treemap|labels=index|values=fibonacci|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy import Gui    # The chart control's data is defined as inline  # code.  page = """  # Basics - Simple line    <|{[x*x for x in range(0, 11)]}|chart|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    from taipy import Gui    # Random data set  data = [random.gauss(0, 5) for i in range(1000)]    page = """  # Histogram - Simple    <|{data}|chart|type=histogram|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import pandas    from taipy.gui import Gui    # 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    <|{data}|chart|type=bar|x=Year|y=%|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  import random    from taipy.gui import Gui    # Random set of 100 samples  samples = {"x": [random.gauss() for i in range(100)]}    # Use the same data for both traces  data = [samples, samples]    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},  ]    layout = {      # Overlay the two histograms      "barmode": "overlay",      # Hide the legend      "showlegend": False,  }    page = """  # Histogram - NBins    <|{data}|chart|type=histogram|options={options}|layout={layout}|>  """  Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # Data set  data = {"Opps": ["Hot leads", "Doc sent", "Quote", "Closed Won"], "Visits": [316, 238, 125, 83]}    page = """  # Funnel Chart - Simple    <|{data}|chart|type=funnel|x=Visits|y=Opps|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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}|chart|type=heatmap|z=0/Temperatures|x=1/Seasons|y=0/Cities|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # 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]    # Naming the subplot is mandatory to get them both in  # the same chart  options = [      {          "subplot": "polar",      },      {"subplot": "polar2"},  ]    layout = {      # Hide the legend      "showlegend": False,      # Restrict the angular values for second trace      "polar2": {"sector": [30, 130]},  }    md = """  # Polar - Sectors    <|{data}|chart|type=scatterpolar|layout={layout}|options={options}|>  """    Gui(md).run()


#  # 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 <script>  # You may need to install the yfinance package as well.  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    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"}    page = """  # Bubble - Simple    <|{data}|chart|mode=markers|x=x|y=y|marker={marker}|>  """    Gui(page).run()


#  # 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 <script>  # -----------------------------------------------------------------------------------------  from taipy.gui import Gui    # Source: www.statista.com (Most used programming languages in 2022)  data = {      # 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    <|{data}|chart|type=scatterpolar|r=%|theta=Language|options={options}|layout={layout}|>  """    Gui(md).run()