filled_area_normalized.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Copyright 2021-2024 Avaiga Private Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
  4. # the License. You may obtain a copy of the License at
  5. #
  6. # http://www.apache.org/licenses/LICENSE-2.0
  7. #
  8. # Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
  9. # an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
  10. # specific language governing permissions and limitations under the License.
  11. # -----------------------------------------------------------------------------------------
  12. # To execute this script, make sure that the taipy-gui package is installed in your
  13. # Python environment and run:
  14. # python <script>
  15. # -----------------------------------------------------------------------------------------
  16. from taipy.gui import Gui
  17. data = {
  18. "Products": [
  19. "Nail polish",
  20. "Eyebrow pencil",
  21. "Rouge",
  22. "Lipstick",
  23. "Eyeshadows",
  24. "Eyeliner",
  25. "Foundation",
  26. "Lip gloss",
  27. "Mascara",
  28. ],
  29. "USA": [12814, 13012, 11624, 8814, 12998, 12321, 10342, 22998, 11261],
  30. "China": [3054, 5067, 7004, 9054, 12043, 15067, 10119, 12043, 10419],
  31. "EU": [4376, 3987, 3574, 4376, 4572, 3417, 5231, 4572, 6134],
  32. "Africa": [4229, 3932, 5221, 9256, 3308, 5432, 13701, 4008, 18712],
  33. }
  34. # Order the different traces
  35. ys = ["USA", "China", "EU", "Africa"]
  36. options = [
  37. # For the USA
  38. {"stackgroup": "one", "groupnorm": "percent"},
  39. # For China
  40. {"stackgroup": "one"},
  41. # For the EU
  42. {"stackgroup": "one"},
  43. # For Africa
  44. {"stackgroup": "one"},
  45. ]
  46. layout = {
  47. # Show all values when hovering on a data point
  48. "hovermode": "x unified"
  49. }
  50. page = """
  51. <|{data}|chart|mode=none|x=Products|y={ys}|options={options}|layout={layout}|>
  52. """
  53. if __name__ == "__main__":
  54. Gui(page).run(title="Chart - Filled Area - Stacked Normalized")