gantt-simple.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. import datetime
  17. from taipy.gui import Gui
  18. if __name__ == "__main__":
  19. # Tasks definitions
  20. tasks = ["Plan", "Research", "Design", "Implement", "Test", "Deliver"]
  21. # Task durations, in days
  22. durations = [50, 30, 30, 40, 15, 10]
  23. # Planned start dates of tasks
  24. start_dates = [
  25. datetime.date(2022, 10, 15), # Plan
  26. datetime.date(2022, 11, 7), # Research
  27. datetime.date(2022, 12, 1), # Design
  28. datetime.date(2022, 12, 20), # Implement
  29. datetime.date(2023, 1, 15), # Test
  30. datetime.date(2023, 2, 1), # Deliver
  31. ]
  32. epoch = datetime.date(1970, 1, 1)
  33. data = {
  34. "start": start_dates,
  35. "Task": tasks,
  36. # Compute the time span as adatetime (relative to January 1st, 1970)
  37. "Date": [epoch + datetime.timedelta(days=duration) for duration in durations],
  38. }
  39. layout = {
  40. "yaxis": {
  41. # Sort tasks from top to bottom
  42. "autorange": "reversed",
  43. # Remove title
  44. "title": {"text": ""},
  45. },
  46. }
  47. page = """
  48. # Gantt - Simple
  49. <|{data}|chart|type=bar|orientation=h|y=Task|x=Date|base=start|layout={layout}|>
  50. """
  51. Gui(page).run()