Skip to content

Commit

Permalink
Close #2012: avoid with() to better account for missing tickvals/tick…
Browse files Browse the repository at this point in the history
…text
  • Loading branch information
cpsievert committed Nov 1, 2021
1 parent 15807cf commit 31b3f88
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -1385,10 +1385,13 @@ gdef2trace <- function(gdef, theme, gglayout) {
rng <- range(gdef$bar$value)
gdef$bar$value <- scales::rescale(gdef$bar$value, from = rng)
gdef$key$.value <- scales::rescale(gdef$key$.value, from = rng)
vals <- lapply(gglayout[c("xaxis", "yaxis")], function(ax) {
if (identical(ax$tickmode, "auto")) ax$ticktext else ax$tickvals
})
list(
x = with(gglayout$xaxis, if (identical(tickmode, "auto")) ticktext else tickvals)[[1]],
y = with(gglayout$yaxis, if (identical(tickmode, "auto")) ticktext else tickvals)[[1]],
# esentially to prevent this getting merged at a later point
x = vals[[1]][[1]],
y = vals[[2]][[1]],
# essentially to prevent this getting merged at a later point
name = gdef$hash,
type = "scatter",
mode = "markers",
Expand Down

0 comments on commit 31b3f88

Please sign in to comment.