Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix #2462: dynamicTicks now works with grouped geom_line
NA values in trace data (e.g., from geom_line gaps between groups) now
correctly remain as NA when mapping categorical data back to ticktext
labels. Previously, which.min() on NA values returned an empty vector
which caused an indexing error.

Fixes #2462

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
  • Loading branch information
cpsievert and claude committed Jan 20, 2026
commit 4be6198deee45598b1259f2ffecfdf9924a97b04
4 changes: 3 additions & 1 deletion R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -843,10 +843,12 @@ gg2list <- function(p, width = NULL, height = NULL,

# inverse transform categorical data based on tickvals/ticktext
if (isDiscreteType) {
traces <- lapply(traces, function(tr) {
traces <- lapply(traces, function(tr) {
# map x/y trace data back to the 'closest' ticktext label
# http://r.789695.n4.nabble.com/check-for-nearest-value-in-a-vector-td4369339.html
tr[[xy]]<- vapply(tr[[xy]], function(val) {
# NA values (e.g., geom_line gaps) should remain NA
if (is.na(val)) return(NA_character_)
with(axisObj, ticktext[[which.min(abs(tickvals - val))]])
}, character(1))
tr
Expand Down