kbberendsen commited on
Commit
217dd35
1 Parent(s): 12c311f

add second column (no second graph)

Browse files
__pycache__/app.cpython-311.pyc CHANGED
Binary files a/__pycache__/app.cpython-311.pyc and b/__pycache__/app.cpython-311.pyc differ
 
app.py CHANGED
@@ -46,11 +46,6 @@ app_ui = ui.page_fluid(
46
  choices = ["Austria", "Hungary", "Spain", "Bahrain", "United-Kingdom"],
47
  selected = "Austria"
48
  ),
49
- ui.input_select(
50
- "driver_select", label="Select driver:",
51
- choices = ["Fastest driver"],
52
- selected = "Fastest driver"
53
- ),
54
  ui.input_radio_buttons(
55
  "session_type", "Session type:",
56
  choices = {"R": "Race", "Q": "Qualification"},
@@ -65,13 +60,42 @@ app_ui = ui.page_fluid(
65
  ),
66
 
67
  ui.panel_main(
68
- ui.output_plot("gear"),
69
- ui.output_text("fastest_driver")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  ),
71
  ),
72
  )
73
 
74
  def server(input, output, session):
 
 
75
  @reactive.Effect()
76
  def _():
77
  if input.year() == "2023":
@@ -79,23 +103,30 @@ def server(input, output, session):
79
  elif input.year() == "2022":
80
  driver_options = drivers_2022
81
 
82
- ui.update_select("driver_select",
83
- label="Select driver:",
84
  choices=driver_options,
85
- selected=input.driver_select()
 
 
 
 
 
 
86
  )
87
 
 
88
  @reactive.Calc
89
- def get_data():
90
  try:
91
  f1_session = ff1.get_session(int(input.year()), input.track_select(), input.session_type())
92
  f1_session.load()
93
 
94
  # Check if user input == fastest driver
95
- if input.driver_select() == "Fastest driver":
96
  lap = f1_session.laps.pick_fastest()
97
  else:
98
- laps_driver = f1_session.laps.pick_driver(input.driver_select())
99
  lap = laps_driver.pick_fastest()
100
 
101
  tel = lap.get_telemetry()
@@ -115,16 +146,16 @@ def server(input, output, session):
115
 
116
  @output
117
  @render.text
118
- def fastest_driver():
119
- segments, gear, driver = get_data()
120
  #print(f"The driver of the fastest lap this session is: {driver}")
121
- return f"Fastest lap this session of: {driver}"
122
 
123
  @output
124
  @render.plot
125
- def gear():
126
  try:
127
- segments, gear, driver = get_data()
128
 
129
  cmap = cm.get_cmap('Paired')
130
  lc_comp = LineCollection(segments, norm=plt.Normalize(1, cmap.N+1), cmap=cmap)
@@ -142,7 +173,6 @@ def server(input, output, session):
142
  plt
143
 
144
  except Exception:
145
- ui.notification_show("Data not available. Select another track or driver.", duration=10, type = 'error')
146
-
147
 
148
  app = App(app_ui, server)
 
46
  choices = ["Austria", "Hungary", "Spain", "Bahrain", "United-Kingdom"],
47
  selected = "Austria"
48
  ),
 
 
 
 
 
49
  ui.input_radio_buttons(
50
  "session_type", "Session type:",
51
  choices = {"R": "Race", "Q": "Qualification"},
 
60
  ),
61
 
62
  ui.panel_main(
63
+ ui.row(
64
+ ui.column(
65
+ 6,
66
+ ui.input_select(
67
+ "driver1_select", label="Select driver 1:",
68
+ choices = ["Fastest driver"],
69
+ selected = "Fastest driver"
70
+ )
71
+ ),
72
+ ui.column(
73
+ 6,
74
+ ui.input_select(
75
+ "driver2_select", label="Select driver 2:",
76
+ choices = ["Fastest driver"],
77
+ selected = "Fastest driver"
78
+ )
79
+ )
80
+ ),
81
+ ui.row(
82
+ ui.column(
83
+ 6,
84
+ ui.output_plot("gear"),
85
+ ui.output_text("fastest_driver")
86
+ ),
87
+ ui.column(
88
+ 6,
89
+ ui.output_text("column_2")
90
+ )
91
+ ),
92
  ),
93
  ),
94
  )
95
 
96
  def server(input, output, session):
97
+
98
+ # Updating driver selection list
99
  @reactive.Effect()
100
  def _():
101
  if input.year() == "2023":
 
103
  elif input.year() == "2022":
104
  driver_options = drivers_2022
105
 
106
+ ui.update_select("driver1_select",
107
+ label="Select driver 1:",
108
  choices=driver_options,
109
+ selected=input.driver1_select()
110
+ )
111
+
112
+ ui.update_select("driver2_select",
113
+ label="Select driver 2:",
114
+ choices=driver_options,
115
+ selected=input.driver2_select()
116
  )
117
 
118
+ # Get required data for both drivers based on selection
119
  @reactive.Calc
120
+ def get_data_1():
121
  try:
122
  f1_session = ff1.get_session(int(input.year()), input.track_select(), input.session_type())
123
  f1_session.load()
124
 
125
  # Check if user input == fastest driver
126
+ if input.driver1_select() == "Fastest driver":
127
  lap = f1_session.laps.pick_fastest()
128
  else:
129
+ laps_driver = f1_session.laps.pick_driver(input.driver1_select())
130
  lap = laps_driver.pick_fastest()
131
 
132
  tel = lap.get_telemetry()
 
146
 
147
  @output
148
  @render.text
149
+ def fastest_driver_1():
150
+ segments, gear, driver = get_data_1()
151
  #print(f"The driver of the fastest lap this session is: {driver}")
152
+ return f"Graph shows the fastest lap of: {driver}"
153
 
154
  @output
155
  @render.plot
156
+ def gear_1():
157
  try:
158
+ segments, gear, driver = get_data_1()
159
 
160
  cmap = cm.get_cmap('Paired')
161
  lc_comp = LineCollection(segments, norm=plt.Normalize(1, cmap.N+1), cmap=cmap)
 
173
  plt
174
 
175
  except Exception:
176
+ pass
 
177
 
178
  app = App(app_ui, server)
cache/fastf1_http_cache.sqlite CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:44fa52e250a4f456d50a8b10e46756687572f622ef2c8dc1c2d6646688b9b1a2
3
  size 287285248
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1b369a473451488571ed3c82190ba1cd424e0bea56d0af4b02b2a31088a3c945
3
  size 287285248