funnel-area-multiple.py 2.8 KB

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