Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions R/ggplotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ ggplotly.ggmatrix <- function(p = ggplot2::last_plot(), width = NULL,
height = NULL, tooltip = "all", dynamicTicks = FALSE,
layerData = 1, originalData = TRUE, source = "A", ...) {
dots <- list(...)

# provide a sensible crosstalk if none is already provided (makes ggnostic() work at least)
if (!crosstalk_key() %in% names(p$data)) {
p$data[[crosstalk_key()]] <- p$data[[".rownames"]] %||% seq_len(nrow(p$data))
Expand Down
3 changes: 3 additions & 0 deletions R/layers2traces.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ layers2traces <- function(data, prestats_data, layout, p) {
# turn symbol (e.g., ..count..) & call (e.g. calc(count)) mappings into text labels
map <- ggfun("make_labels")(map)


# filter tooltip aesthetics down to those specified in `tooltip` arg
if (!identical(p$tooltip, "all")) {
# rectify tooltips, ggplot automatically convert `color` => `colour`
p$tooltip[p$tooltip == "color"] <- "colour"
map <- map[names(map) %in% p$tooltip | map %in% p$tooltip]
}

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions tests/testthat/_snaps/plotly-area/add-area.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/testthat/test-ggplot-color.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
df = data.frame(width = 1:3, height = 1:3, col = letters[1:3])
test_that("ggplotly automatically converts `color` aes to `colour`", {
p <- qplot(width, height,
data = df, color = col)
# color variable is not shown
color <- plotly_build(ggplotly(p, tooltip = c("color")))
# colour (with u!) variable is shown
expect_identical(color$x$data, plotly_build(ggplotly(p, tooltip = c("colour")))$x$data)
})