data.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Importing the necessary modules
  2. from taipy import Gui
  3. import graphs
  4. import pandas as pd
  5. # Constants
  6. OE = "OddEven"
  7. PT = "PublicTransport"
  8. EV = "ElectricVehicle"
  9. DATE = "Date"
  10. BREAKTYPE = "Break"
  11. COOLPINK = "#f8b4ce"
  12. COOLGREEN = "#a2c9ba"
  13. PASTELYELLOW = "#f8ecb4"
  14. # Path to CSV file
  15. path_to_csv = "test.csv"
  16. # Function to refresh data
  17. def refresh_data():
  18. # Resetting variables in graphs.py
  19. graphs.PTnum = 0
  20. graphs.OEnum = 0
  21. graphs.EVnum = 0
  22. graphs.date_lis = []
  23. graphs.OE_breaks = []
  24. graphs.PT_breaks = []
  25. graphs.EV_breaks = []
  26. # Reading CSV and updating data in graphs.py
  27. dataset = graphs.readCSV(path_to_csv)
  28. date_lis = graphs.get_date_lis()
  29. date_lis = graphs.date_to_list(dataset, date_lis)
  30. graphs.add_all_data(dataset, date_lis)
  31. # Retrieving data from graphs.py
  32. PT_lis = graphs.get_PT()
  33. OE_lis = graphs.get_OE()
  34. EV_lis = graphs.get_EV()
  35. date_lis = graphs.get_date_lis()
  36. # Property chart configuration
  37. property_chart = {
  38. "type": "bar",
  39. "x": DATE,
  40. "rebuild": True,
  41. "render": True,
  42. "y[1]": PT,
  43. "y[2]": OE,
  44. "y[3]": EV,
  45. "color[1]": COOLPINK,
  46. "color[2]": COOLGREEN,
  47. "color[3]": PASTELYELLOW,
  48. }