radar-simple.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 typing import Dict, List
  17. from taipy.gui import Gui
  18. if __name__ == "__main__":
  19. # Source: www.statista.com (Most used programming languages in 2022)
  20. data: Dict[str, List] = {
  21. # List of programming languages
  22. "Language": ["JavaScript", "HTML/CSS", "SQL", "Python", "Typescript", "Java", "Bash/Shell"],
  23. # Percentage of usage, per language
  24. "%": [65.36, 55.08, 49.43, 48.07, 34.83, 33.27, 29.07],
  25. }
  26. # Close the shape for a nice-looking stroke
  27. # If the first point is *not* appended to the end of the list,
  28. # then the shape does not look as it is closed.
  29. data["%"].append(data["%"][0])
  30. data["Language"].append(data["Language"][0])
  31. layout = {
  32. "polar": {
  33. "radialaxis": {
  34. # Force the radial range to 0-100
  35. "range": [0, 100],
  36. }
  37. },
  38. # Hide legend
  39. "showlegend": False,
  40. }
  41. options = {
  42. # Fill the trace
  43. "fill": "toself"
  44. }
  45. md = """
  46. # Radar - Simple
  47. <|{data}|chart|type=scatterpolar|r=%|theta=Language|options={options}|layout={layout}|>
  48. """
  49. Gui(md).run()