filled-area-normalized.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. if __name__ == "__main__":
  18. data = {
  19. "Products": [
  20. "Nail polish",
  21. "Eyebrow pencil",
  22. "Rouge",
  23. "Lipstick",
  24. "Eyeshadows",
  25. "Eyeliner",
  26. "Foundation",
  27. "Lip gloss",
  28. "Mascara",
  29. ],
  30. "USA": [12814, 13012, 11624, 8814, 12998, 12321, 10342, 22998, 11261],
  31. "China": [3054, 5067, 7004, 9054, 12043, 15067, 10119, 12043, 10419],
  32. "EU": [4376, 3987, 3574, 4376, 4572, 3417, 5231, 4572, 6134],
  33. "Africa": [4229, 3932, 5221, 9256, 3308, 5432, 13701, 4008, 18712],
  34. }
  35. # Order the different traces
  36. ys = ["USA", "China", "EU", "Africa"]
  37. options = [
  38. # For the USA
  39. {"stackgroup": "one", "groupnorm": "percent"},
  40. # For China
  41. {"stackgroup": "one"},
  42. # For the EU
  43. {"stackgroup": "one"},
  44. # For Africa
  45. {"stackgroup": "one"},
  46. ]
  47. layout = {
  48. # Show all values when hovering on a data point
  49. "hovermode": "x unified"
  50. }
  51. page = """
  52. # Filled Area - Stacked Normalized
  53. <|{data}|chart|mode=none|x=Products|y={ys}|options={options}|layout={layout}|>
  54. """
  55. Gui(page).run()