Skip to content

Commit 0611f43

Browse files
committed
merge with master
2 parents 641a7ad + 78e4612 commit 0611f43

File tree

14 files changed

+178
-91
lines changed

14 files changed

+178
-91
lines changed

DESCRIPTION

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: plotly
22
Title: Create Interactive Web Graphics via 'plotly.js'
3-
Version: 3.4.4
3+
Version: 3.4.6
44
Authors@R: c(person("Carson", "Sievert", role = c("aut", "cre"),
55
email = "cpsievert1@gmail.com"),
66
person("Chris", "Parmer", role = c("aut", "cph"),
@@ -31,7 +31,8 @@ Imports:
3131
base64enc,
3232
htmlwidgets,
3333
tidyr,
34-
plyr
34+
plyr,
35+
hexbin
3536
Suggests:
3637
dplyr,
3738
maps,
@@ -47,8 +48,7 @@ Suggests:
4748
RColorBrewer,
4849
Rserve,
4950
RSclient,
50-
broom,
51-
hexbin
51+
broom
5252
LazyData: true
5353
VignetteBuilder: knitr
5454
RoxygenNote: 5.0.1

NEWS

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
3.4.4 -- 15 Mar 2016
21

32
NEW FEATURE:
43

@@ -8,6 +7,26 @@ BUGFIX:
87

98
Long legend titles will no longer run off the screen, and legend titles with line breaks (\n) are now translated correctly.
109

10+
3.4.6 -- 17 Mar 2016
11+
12+
NEW FEATURES:
13+
14+
The 'plotly_relayout' event is now accessible via the event_data() function.
15+
16+
Fixed #514.
17+
18+
3.4.5 -- 17 Mar 2016
19+
20+
BUGFIX:
21+
22+
Fixed #514.
23+
24+
3.4.4 -- 17 Mar 2016
25+
26+
BUGFIX:
27+
28+
Show discrete positional values in tooltip (see #515); better GeomTile conversion; pass plot object into layers2traces.
29+
1130
3.4.3 -- 14 Mar 2016
1231

1332
BUGFIX:

R/ggplotly.R

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,13 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
7373
scale_x <- function() scales$get_scales("x")
7474
scale_y <- function() scales$get_scales("y")
7575
panel <- ggfun("train_position")(panel, data, scale_x(), scale_y())
76+
# Before mapping x/y position, save the domain (for discrete scales)
77+
# to display in tooltip.
78+
data <- lapply(data, function(d) {
79+
if (!is.null(scale_x()) && scale_x()$is_discrete()) d$x_plotlyDomain <- d$x
80+
if (!is.null(scale_y()) && scale_y()$is_discrete()) d$y_plotlyDomain <- d$y
81+
d
82+
})
7683
data <- ggfun("map_position")(panel, data, scale_x(), scale_y())
7784
# for some geoms (e.g. boxplots) plotly.js needs the "pre-statistics" data
7885
prestats_data <- data
@@ -245,21 +252,18 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
245252
# stat specific mappings
246253
grep("^\\.\\.", as.character(x$stat$default_aes), value = TRUE)
247254
)
248-
# remove leading/trailing dots in "hidden" stat aes
249-
map <- sub("^\\.\\.", "", sub("\\.\\.$", "", map))
255+
# "hidden" names should be taken verbatim
256+
idx <- grepl("^\\.\\.", map) & grepl("\\.\\.$", map)
257+
hiddenMap <- sub("^\\.\\.", "", sub("\\.\\.$", "", map))
258+
map[idx] <- hiddenMap[idx]
259+
names(map)[idx] <- hiddenMap[idx]
250260
if (!identical(tooltip, "all")) {
251261
map <- map[tooltip]
252262
}
253-
# tooltips for discrete positional scales are misleading
254-
if (scales$get_scales("x")$is_discrete()) {
255-
map <- map[!names(map) %in% "x"]
256-
}
257-
if (scales$get_scales("y")$is_discrete()) {
258-
map <- map[!names(map) %in% "y"]
259-
}
260263
map
261264
})
262265

266+
263267
# attach a new column (hovertext) to each layer of data that should get mapped
264268
# to the text trace property
265269
data <- Map(function(x, y) {
@@ -292,10 +296,11 @@ gg2list <- function(p, width = NULL, height = NULL, tooltip = "all", source = "A
292296
x
293297
}, data, aesMap)
294298

299+
300+
295301
# layers -> plotly.js traces
296-
traces <- layers2traces(
297-
data, prestats_data, layers, panel$layout, scales, p$labels
298-
)
302+
traces <- layers2traces(data, prestats_data, panel$layout, p)
303+
299304
# default to just the text in hover info, mainly because of this
300305
# https://github.com/plotly/plotly.js/issues/320
301306
traces <- lapply(traces, function(tr) {

0 commit comments

Comments
 (0)