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
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ S3method(parseThis,character)
S3method(parseThis,factor)
S3method(plot,jaspGraphs)
S3method(plot,jaspGraphsPlot)
S3method(plotEditing,default)
S3method(plotEditing,ggplot)
S3method(plotEditing,jaspGraphsPlot)
S3method(print,jaspGraphs)
S3method(print,jaspGraphsPlot)
export(.graphOptions)
Expand Down
22 changes: 19 additions & 3 deletions R/plotEditing.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,30 @@ optionsDiff <- function(new, old) {
}

#' @title Edit a plot
#' @param graph a ggplot2 object
#' @param graph a ggplot2 object or a jaspGraphsPlot object
#' @param newOptions an options list
#'
#' @export
plotEditing <- function(graph, newOptions) {
UseMethod("plotEditing", graph)
}

#' @export
plotEditing.default <- function(graph, newOptions) {
stop2("graph should be a ggplot or a jaspGraphsPlot")
}

#' @export
plotEditing.jaspGraphsPlot <- function(graph, newOptions) {
if (length(graph) != 1L)
stop2("This plot cannot be edited because it consists of multiple smaller figures.")

if (!is_ggplot(graph))
stop2("graph should be a ggplot2")
graph[[1L]] <- plotEditing(graph[[1L]], newOptions)
return(graph)
Comment on lines +81 to +86
}

#' @export
plotEditing.ggplot <- function(graph, newOptions) {

if (isTRUE(newOptions[["resetPlot"]])) {
if (hasOriginalEditingOptions(graph)) {
Expand Down
4 changes: 3 additions & 1 deletion R/plotEditingOptions.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ getPlotEditingOptions.qgraph <- function(graph) {

#' @exportS3Method
getPlotEditingOptions.jaspGraphsPlot <- function(graph) {
plotEditingOptionsError(gettext("This plot cannot be edited because it consists of multiple smaller figures."))
if (length(graph) != 1L)
return(plotEditingOptionsError(gettext("This plot cannot be edited because it consists of multiple smaller figures.")))
return(getPlotEditingOptions(graph[[1L]]))
}

#' @exportS3Method getPlotEditingOptions "function"
Expand Down
2 changes: 1 addition & 1 deletion man/plotEditing.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading