funnel-area-multiple.py 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. "John_us": [500, 450, 340, 230, 220, 110],
  20. "John_eu": [600, 500, 400, 300, 200, 100],
  21. "Robert_us": [510, 480, 440, 330, 220, 100],
  22. "Robert_eu": [360, 250, 240, 130, 120, 60],
  23. }
  24. # Values for each trace
  25. values = ["John_us", "John_eu", "Robert_us", "Robert_eu"]
  26. options = [
  27. # For John/US
  28. {
  29. "scalegroup": "first",
  30. "textinfo": "value",
  31. "title": {
  32. # "position": "top",
  33. "text": "John in the U.S."
  34. },
  35. # Lower-left corner
  36. "domain": {"x": [0, 0.5], "y": [0, 0.5]},
  37. },
  38. # For John/EU
  39. {
  40. "scalegroup": "first",
  41. "textinfo": "value",
  42. "title": {
  43. # "position": "top",
  44. "text": "John in the E.U."
  45. },
  46. # Upper-left corner
  47. "domain": {"x": [0, 0.5], "y": [0.55, 1]},
  48. },
  49. # For Robert/US
  50. {
  51. "scalegroup": "second",
  52. "textinfo": "value",
  53. "title": {
  54. # "position": "top",
  55. "text": "Robert in the U.S."
  56. },
  57. # Lower-right corner
  58. "domain": {"x": [0.51, 1], "y": [0, 0.5]},
  59. },
  60. # For Robert/EU
  61. {
  62. "scalegroup": "second",
  63. "textinfo": "value",
  64. "title": {
  65. # "position": "top",
  66. "text": "Robert in the E.U."
  67. },
  68. # Upper-right corner
  69. "domain": {"x": [0.51, 1], "y": [0.51, 1]},
  70. },
  71. ]
  72. layout = {
  73. "title": "Sales per Salesman per Region",
  74. "showlegend": False,
  75. # Draw frames around each trace
  76. "shapes": [
  77. {"x0": 0, "x1": 0.5, "y0": 0, "y1": 0.5},
  78. {"x0": 0, "x1": 0.5, "y0": 0.52, "y1": 1},
  79. {"x0": 0.52, "x1": 1, "y0": 0, "y1": 0.5},
  80. {"x0": 0.52, "x1": 1, "y0": 0.52, "y1": 1},
  81. ],
  82. }
  83. page = """
  84. # Funnel Area - Multiple Charts
  85. <|{data}|chart|type=funnelarea|values={values}|options={options}|layout={layout}|>
  86. """
  87. Gui(page).run()