Spaces:
Running
Running
Update app.R
Browse files
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 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 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),
|