igroffman commited on
Commit
8104ef6
·
verified ·
1 Parent(s): f6a438f

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +20 -18
app.R CHANGED
@@ -321,24 +321,26 @@ server <- function(input, output, session){
321
  d <- pitcher_df()
322
  validate(need(nrow(d) > 0, "No data for selected pitcher"))
323
 
324
- plot_ly(
325
- data = d, source = "loc", type = "scatter", mode = "markers",
326
- x = ~PlateLocSide, y = ~PlateLocHeight,
327
- text = ~paste0(
328
- "<b>", TaggedPitchType, "</b>",
329
- "<br>Velo: ", round(RelSpeed,1), " mph",
330
- "<br>X: ", round(PlateLocSide,2),
331
- "<br>Z: ", round(PlateLocHeight,2),
332
- "<br>IVB: ", round(InducedVertBreak,1), " in",
333
- "<br>HB: ", round(HorzBreak,1), " in",
334
- if ("SpinRate" %in% names(d)) paste0("<br>Spin: ", round(SpinRate), " rpm") else ""
335
- ),
336
- hoverinfo = "text",
337
- key = ~.uid,
338
- color = ~factor(TaggedPitchType),
339
- colors = pitch_colors,
340
- marker = list(size = 9)
341
- ) |>
 
 
342
  layout(
343
  title = "Pitch Location (Editable)",
344
  xaxis = list(title="Plate X (ft)", range=c(-2,2), zeroline=TRUE),
 
321
  d <- pitcher_df()
322
  validate(need(nrow(d) > 0, "No data for selected pitcher"))
323
 
324
+ plot_ly(
325
+ data = d, source = "loc",
326
+ type = "scatter", mode = "markers",
327
+ x = ~PlateLocSide, y = ~PlateLocHeight,
328
+ text = ~paste0(
329
+ "<b>", TaggedPitchType, "</b>",
330
+ if ("PitchNo" %in% names(d)) paste0("<br>Pitch #: ", PitchNo) else "",
331
+ "<br>Velo: ", round(RelSpeed, 1), " mph",
332
+ "<br>X: ", round(PlateLocSide, 2),
333
+ "<br>Z: ", round(PlateLocHeight, 2),
334
+ "<br>IVB: ", round(InducedVertBreak, 1), " in",
335
+ "<br>HB: ", round(HorzBreak, 1), " in",
336
+ if ("SpinRate" %in% names(d)) paste0("<br>Spin: ", round(SpinRate), " rpm") else ""
337
+ ),
338
+ hoverinfo = "text",
339
+ key = ~.uid, # or ~PitchUID / ~PitchNo if you don't have .uid
340
+ color = ~factor(TaggedPitchType),
341
+ colors = pitch_colors,
342
+ marker = list(size = 9)
343
+ ) |>
344
  layout(
345
  title = "Pitch Location (Editable)",
346
  xaxis = list(title="Plate X (ft)", range=c(-2,2), zeroline=TRUE),