Skip to content

Commit 9c35f4f

Browse files
committed
merge conflicts
2 parents 09f045d + 1fd4290 commit 9c35f4f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+905
-484
lines changed

DESCRIPTION

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ URL: https://plot.ly/r, https://cpsievert.github.io/plotly_book/, https://github
2121
BugReports: https://github.com/ropensci/plotly/issues
2222
Depends:
2323
R (>= 3.2.0),
24-
ggplot2 (> 2.1.0)
24+
ggplot2 (> 2.1.1)
2525
Imports:
2626
scales,
2727
httr,
@@ -38,7 +38,6 @@ Imports:
3838
tibble,
3939
lazyeval (>= 0.2.0),
4040
crosstalk,
41-
colourpicker,
4241
purrr
4342
Suggests:
4443
MASS,
@@ -59,4 +58,6 @@ Suggests:
5958
listviewer,
6059
dendextend
6160
LazyData: true
62-
RoxygenNote: 5.0.1
61+
RoxygenNote: 6.0.1
62+
Remotes:
63+
tidyverse/ggplot2

NAMESPACE

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# Generated by roxygen2: do not edit by hand
22

3-
S3method(arrange_,plotly)
4-
S3method(distinct_,plotly)
5-
S3method(do_,plotly)
6-
S3method(filter_,plotly)
73
S3method(fortify,SharedData)
84
S3method(geom2trace,GeomBar)
95
S3method(geom2trace,GeomBlank)
@@ -20,22 +16,15 @@ S3method(ggplot,plotly)
2016
S3method(ggplotly,ggmatrix)
2117
S3method(ggplotly,ggplot)
2218
S3method(ggplotly,plotly)
23-
S3method(group_by_,plotly)
24-
S3method(groups,plotly)
2519
S3method(layout,matrix)
2620
S3method(layout,plotly)
2721
S3method(layout,shiny.tag.list)
28-
S3method(mutate_,plotly)
2922
S3method(plotly_build,gg)
3023
S3method(plotly_build,list)
3124
S3method(plotly_build,plotly)
3225
S3method(print,api_grid)
3326
S3method(print,api_grid_local)
3427
S3method(print,api_plot)
35-
S3method(rename_,plotly)
36-
S3method(select_,plotly)
37-
S3method(slice_,plotly)
38-
S3method(summarise_,plotly)
3928
S3method(to_basic,GeomAbline)
4029
S3method(to_basic,GeomArea)
4130
S3method(to_basic,GeomBoxplot)
@@ -63,8 +52,6 @@ S3method(to_basic,GeomTile)
6352
S3method(to_basic,GeomViolin)
6453
S3method(to_basic,GeomVline)
6554
S3method(to_basic,default)
66-
S3method(transmute_,plotly)
67-
S3method(ungroup,plotly)
6855
export("%>%")
6956
export(add_annotations)
7057
export(add_area)
@@ -95,28 +82,34 @@ export(animation_opts)
9582
export(animation_slider)
9683
export(arrange)
9784
export(arrange_)
85+
export(arrange_.plotly)
9886
export(as.widget)
9987
export(as_widget)
10088
export(colorbar)
10189
export(config)
10290
export(distinct)
10391
export(distinct_)
92+
export(distinct_.plotly)
10493
export(do)
10594
export(do_)
95+
export(do_.plotly)
10696
export(download_grid)
10797
export(download_plot)
10898
export(embed_notebook)
10999
export(event_data)
110100
export(export)
111101
export(filter)
112102
export(filter_)
103+
export(filter_.plotly)
113104
export(geom2trace)
114105
export(get_figure)
115106
export(gg2list)
116107
export(ggplotly)
117108
export(group_by)
118109
export(group_by_)
110+
export(group_by_.plotly)
119111
export(groups)
112+
export(groups.plotly)
120113
export(hide_colorbar)
121114
export(hide_guides)
122115
export(hide_legend)
@@ -127,6 +120,7 @@ export(last_plot)
127120
export(layout)
128121
export(mutate)
129122
export(mutate_)
123+
export(mutate_.plotly)
130124
export(offline)
131125
export(overwrite_grid)
132126
export(overwrite_plot)
@@ -146,28 +140,32 @@ export(rangeslider)
146140
export(remove_typedarray_polyfill)
147141
export(rename)
148142
export(rename_)
143+
export(rename_.plotly)
149144
export(renderPlotly)
150145
export(schema)
151146
export(select)
152147
export(select_)
148+
export(select_.plotly)
153149
export(signup)
154150
export(slice)
155151
export(slice_)
152+
export(slice_.plotly)
156153
export(style)
157154
export(subplot)
158155
export(summarise)
159156
export(summarise_)
157+
export(summarise_.plotly)
160158
export(toRGB)
161159
export(toWebGL)
162160
export(to_basic)
163161
export(transmute)
164162
export(transmute_)
163+
export(transmute_.plotly)
165164
export(ungroup)
165+
export(ungroup.plotly)
166166
export(upload_grid)
167167
export(upload_plot)
168168
import(ggplot2)
169-
importFrom(Cairo,Cairo)
170-
importFrom(colourpicker,colourWidget)
171169
importFrom(dplyr,arrange)
172170
importFrom(dplyr,arrange_)
173171
importFrom(dplyr,distinct)
@@ -199,8 +197,10 @@ importFrom(grDevices,extendrange)
199197
importFrom(graphics,layout)
200198
importFrom(htmltools,browsable)
201199
importFrom(htmltools,tagList)
200+
importFrom(htmltools,tags)
202201
importFrom(htmlwidgets,createWidget)
203202
importFrom(htmlwidgets,onRender)
203+
importFrom(htmlwidgets,prependContent)
204204
importFrom(htmlwidgets,saveWidget)
205205
importFrom(htmlwidgets,shinyRenderWidget)
206206
importFrom(htmlwidgets,shinyWidgetOutput)

NEWS.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* `ggplotly()` gains a new argument, `dynamicTicks`, which allows axis ticks to update upon zoom/pan interactions (fixes #485).
1010
* Added support for the `GeomCol` and `GeomDotplot` **ggplot2** geoms.
1111
* Sensible sizing and positioning defaults are now provided for subplots multiple colorbars.
12+
* R linebreaks are translated to HTML linebreaks (i.e., '\n' translates to '<br />') (fixes #851).
1213
* Added a `plot_dendro()` function for a quick and dirty interactive dendrogram with support for hierarchial selection. For more, see -- <https://cpsievert.github.io/plotly_book/linking-views-without-shiny.html#nested-selections>
1314

1415
## BUG FIXES
@@ -17,7 +18,7 @@
1718

1819
## CHANGES
1920

20-
* Upgraded to plotly.js v1.20.5 -- https://github.com/plotly/plotly.js/releases/tag/v1.20.5
21+
* Upgraded to plotly.js v1.22.0 -- https://github.com/plotly/plotly.js/releases/tag/v1.22.0
2122
* `HTMLwidgets.renderValue()` now calls `Plotly.redraw()` instead of `Plotly.newPlot()`. (thanks @AleksandrIanevski)
2223
* A TypedArray polyfill is now included by default, and the function `remove_typedarray_polyfill()` was added to make it easy to remove it. Fixes #824.
2324
* If no graphics device is already open, `ggplotly()` now tries to open/close a Cairo graphics device, then a bitmap (png/jpeg) device. If neither is available, it errors. This helps to ensure that a *screen* device is never opened by `ggplotly()` (which fixes #829). Furthermore, if `width`/`height` is not specified *and* no graphics device is currently open, a default of 640/480 is used for width/height of the device.

R/ggplotly.R

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,8 @@ gg2list <- function(p, width = NULL, height = NULL,
219219

220220
# Initialise panels, add extra data for margins & missing facetting
221221
# variables, and add on a PANEL variable to data
222-
layout <- ggfun("create_layout")(plot$facet)
223-
data <- layout$setup(layer_data, plot$data, plot$plot_env, plot$coordinates)
224-
data <- layout$map(data)
222+
layout <- ggfun("create_layout")(plot$facet, plot$coordinates)
223+
data <- layout$setup(layer_data, plot$data, plot$plot_env)
225224

226225
# save the domain of the group for display in tooltips
227226
groupDomains <- Map(function(x, y) {
@@ -344,6 +343,7 @@ gg2list <- function(p, width = NULL, height = NULL,
344343
# displayed, or does it include the range of underlying data
345344
layout$reset_scales()
346345
layout$train_position(data, scale_x(), scale_y())
346+
layout$setup_panel_params()
347347
data <- layout$map_position(data)
348348

349349
# Train and map non-position scales
@@ -364,9 +364,6 @@ gg2list <- function(p, width = NULL, height = NULL,
364364
data <- lapply(data, ggfun("scales_map_df"), scales = npscales)
365365
}
366366

367-
# Train coordinate system
368-
layout$train_ranges(plot$coordinates)
369-
370367
# Fill in defaults etc.
371368
data <- by_layer(function(l, d) l$compute_geom_2(d))
372369

@@ -410,51 +407,51 @@ gg2list <- function(p, width = NULL, height = NULL,
410407
# https://github.com/plotly/plotly.js/blob/dd1547/src/components/modebar/index.js#L171
411408
gglayout$margin$t <- gglayout$margin$t + 16
412409

413-
# important stuff like layout$panel_ranges is already flipped, but
410+
# important stuff like layout$panel_params is already flipped, but
414411
# plot$scales/plot$labels/data aren't. We flip x/y trace data at the very end
415412
# and scales in the axis loop below.
416413
if (inherits(plot$coordinates, "CoordFlip")) {
417414
plot$labels[c("x", "y")] <- plot$labels[c("y", "x")]
418415
}
419416

420417
# important panel summary stats
421-
nPanels <- nrow(layout$panel_layout)
422-
nRows <- max(layout$panel_layout$ROW)
423-
nCols <- max(layout$panel_layout$COL)
418+
nPanels <- nrow(layout$layout)
419+
nRows <- max(layout$layout$ROW)
420+
nCols <- max(layout$layout$COL)
424421

425422
# panel -> plotly.js axis/anchor info
426423
# (assume a grid layout by default)
427-
layout$panel_layout$xaxis <- layout$panel_layout$COL
428-
layout$panel_layout$yaxis <- layout$panel_layout$ROW
429-
layout$panel_layout$xanchor <- nRows
430-
layout$panel_layout$yanchor <- 1
424+
layout$layout$xaxis <- layout$layout$COL
425+
layout$layout$yaxis <- layout$layout$ROW
426+
layout$layout$xanchor <- nRows
427+
layout$layout$yanchor <- 1
431428
if (inherits(plot$facet, "FacetWrap")) {
432429
if (plot$facet$params$free$x) {
433-
layout$panel_layout$xaxis <- layout$panel_layout$PANEL
434-
layout$panel_layout$xanchor <- layout$panel_layout$ROW
430+
layout$layout$xaxis <- layout$layout$PANEL
431+
layout$layout$xanchor <- layout$layout$ROW
435432
}
436433
if (plot$facet$params$free$y) {
437-
layout$panel_layout$yaxis <- layout$panel_layout$PANEL
438-
layout$panel_layout$yanchor <- layout$panel_layout$COL
439-
layout$panel_layout$xanchor <- nPanels
434+
layout$layout$yaxis <- layout$layout$PANEL
435+
layout$layout$yanchor <- layout$layout$COL
436+
layout$layout$xanchor <- nPanels
440437
}
441438
if (plot$facet$params$free$x && plot$facet$params$free$y) {
442-
layout$panel_layout$xaxis <- layout$panel_layout$PANEL
443-
layout$panel_layout$yaxis <- layout$panel_layout$PANEL
444-
layout$panel_layout$xanchor <- layout$panel_layout$PANEL
445-
layout$panel_layout$yanchor <- layout$panel_layout$PANEL
439+
layout$layout$xaxis <- layout$layout$PANEL
440+
layout$layout$yaxis <- layout$layout$PANEL
441+
layout$layout$xanchor <- layout$layout$PANEL
442+
layout$layout$yanchor <- layout$layout$PANEL
446443
}
447444
}
448445
# format the axis/anchor to a format plotly.js respects
449-
layout$panel_layout$xaxis <- paste0("xaxis", sub("^1$", "", layout$panel_layout$xaxis))
450-
layout$panel_layout$yaxis <- paste0("yaxis", sub("^1$", "", layout$panel_layout$yaxis))
451-
layout$panel_layout$xanchor <- paste0("y", sub("^1$", "", layout$panel_layout$xanchor))
452-
layout$panel_layout$yanchor <- paste0("x", sub("^1$", "", layout$panel_layout$yanchor))
446+
layout$layout$xaxis <- paste0("xaxis", sub("^1$", "", layout$layout$xaxis))
447+
layout$layout$yaxis <- paste0("yaxis", sub("^1$", "", layout$layout$yaxis))
448+
layout$layout$xanchor <- paste0("y", sub("^1$", "", layout$layout$xanchor))
449+
layout$layout$yanchor <- paste0("x", sub("^1$", "", layout$layout$yanchor))
453450
# for some layers2traces computations, we need the range of each panel
454-
layout$panel_layout$x_min <- sapply(layout$panel_ranges, function(z) min(z$x.range))
455-
layout$panel_layout$x_max <- sapply(layout$panel_ranges, function(z) max(z$x.range))
456-
layout$panel_layout$y_min <- sapply(layout$panel_ranges, function(z) min(z$y.range))
457-
layout$panel_layout$y_max <- sapply(layout$panel_ranges, function(z) max(z$y.range))
451+
layout$layout$x_min <- sapply(layout$panel_params, function(z) min(z$x.range))
452+
layout$layout$x_max <- sapply(layout$panel_params, function(z) max(z$x.range))
453+
layout$layout$y_min <- sapply(layout$panel_params, function(z) min(z$y.range))
454+
layout$layout$y_max <- sapply(layout$panel_params, function(z) max(z$y.range))
458455

459456
# layers -> plotly.js traces
460457
plot$tooltip <- tooltip
@@ -464,7 +461,7 @@ gg2list <- function(p, width = NULL, height = NULL,
464461

465462
# reattach crosstalk key-set attribute
466463
data <- Map(function(x, y) structure(x, set = y), data, sets)
467-
traces <- layers2traces(data, prestats_data, layout$panel_layout, plot)
464+
traces <- layers2traces(data, prestats_data, layout$layout, plot)
468465

469466
# default to just the text in hover info, mainly because of this
470467
# https://github.com/plotly/plotly.js/issues/320
@@ -509,7 +506,7 @@ gg2list <- function(p, width = NULL, height = NULL,
509506
)
510507
# allocate enough space for the _longest_ text label
511508
axisTextX <- theme[["axis.text.x"]] %||% theme[["axis.text"]]
512-
labz <- unlist(lapply(layout$panel_ranges, "[[", "x.labels"))
509+
labz <- unlist(lapply(layout$panel_params, "[[", "x.labels"))
513510
lab <- labz[which.max(nchar(labz))]
514511
panelMarginY <- panelMarginY + axisTicksX +
515512
bbox(lab, axisTextX$angle, unitConvert(axisTextX, "npc", "height"))[["height"]]
@@ -521,7 +518,7 @@ gg2list <- function(p, width = NULL, height = NULL,
521518
)
522519
# allocate enough space for the _longest_ text label
523520
axisTextY <- theme[["axis.text.y"]] %||% theme[["axis.text"]]
524-
labz <- unlist(lapply(layout$panel_ranges, "[[", "y.labels"))
521+
labz <- unlist(lapply(layout$panel_params, "[[", "y.labels"))
525522
lab <- labz[which.max(nchar(labz))]
526523
panelMarginX <- panelMarginX + axisTicksY +
527524
bbox(lab, axisTextY$angle, unitConvert(axisTextY, "npc", "width"))[["width"]]
@@ -534,7 +531,7 @@ gg2list <- function(p, width = NULL, height = NULL,
534531
doms <- get_domains(nPanels, nRows, margins)
535532

536533
for (i in seq_len(nPanels)) {
537-
lay <- layout$panel_layout[i, ]
534+
lay <- layout$layout[i, ]
538535
for (xy in c("x", "y")) {
539536
# find axis specific theme elements that inherit from their parent
540537
theme_el <- function(el) {
@@ -549,8 +546,8 @@ gg2list <- function(p, width = NULL, height = NULL,
549546

550547
axisName <- lay[, paste0(xy, "axis")]
551548
anchor <- lay[, paste0(xy, "anchor")]
552-
rng <- layout$panel_ranges[[i]]
553-
# stuff like layout$panel_ranges is already flipped, but scales aren't
549+
rng <- layout$panel_params[[i]]
550+
# stuff like layout$panel_params is already flipped, but scales aren't
554551
sc <- if (inherits(plot$coordinates, "CoordFlip")) {
555552
scales$get_scales(setdiff(c("x", "y"), xy))
556553
} else {
@@ -598,6 +595,7 @@ gg2list <- function(p, width = NULL, height = NULL,
598595
if (i == 1) {
599596
traces <- lapply(traces, function(z) { z[[xy]] <- z[[xy]] * 86400000; z })
600597
}
598+
axisObj$type <- "date"
601599
}
602600
# tickvals are currently on 0-1 scale, but we want them on data scale
603601
axisObj$tickvals <- scales::rescale(
@@ -930,7 +928,7 @@ gg2list <- function(p, width = NULL, height = NULL,
930928
l$attrs <- setNames(mappingFormulas, ids)
931929
l$attrs <- lapply(l$attrs, function(x) structure(x, class = "plotly_eval"))
932930
# the build step removes the first attrs if no type exists
933-
l$attrs[[1]][["type"]] <- "ggplotly"
931+
l$attrs[[1]][["type"]] <- l$data[[1]][["type"]] %||% "scatter"
934932

935933
l$cur_data <- ids[[layerData]]
936934
l$visdat <- setNames(lapply(return_dat, function(x) function(y) x), ids)

0 commit comments

Comments
 (0)