diff --git a/R/common.R b/R/common.R index 8db8d7be..bb4edfe4 100644 --- a/R/common.R +++ b/R/common.R @@ -1,5 +1,5 @@ # -# Copyright (C) 2013-2018 University of Amsterdam +# Copyright (C) 2013-2026 University of Amsterdam # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -14,9 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # - -#' @importFrom stats na.omit - fromJSON <- function(x) jsonlite::fromJSON(x, TRUE, FALSE, FALSE) toJSON <- function(x) jsonlite::toJSON(x, auto_unbox = TRUE, digits = NA, null="null") @@ -1136,12 +1133,15 @@ editImage <- function(name, optionsJson) { status = "imageEdited", results = list( name = plotName, + uniqueName = uniqueName, + pngFile = jaspPlotCPP$filePathPng, + jsonFile = interactiveJsonData, resized = type == "resize", width = width, height = height, revision = revision, error = FALSE, - editOptions = jaspGraphs::plotEditingOptions(plot), + editOptions = jaspGraphs::plotEditingOptions(jaspPlotCPP$plotObject), interactiveJsonData = interactiveJsonData ) ) diff --git a/R/writeImage.R b/R/writeImage.R index 0d6360ad..2434b286 100755 --- a/R/writeImage.R +++ b/R/writeImage.R @@ -1,5 +1,19 @@ -#Originally in common.R in package JASP, extracted here and changed for standalone use in jaspResults/jaspTools - +# +# Copyright (C) 2013-2026 University of Amsterdam +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# tryToWriteImageJaspResults <- function(...) { tryCatch( suppressWarnings(return(writeImageJaspResults(...))), @@ -127,6 +141,7 @@ writeImageJaspResults <- function(plot, width = 320, height = 320, obj = TRUE, r tryCatch( { jsonOrTryError <- jaspGraphs::convertGgplotToPlotly(plot) + cat("DEBUG writeImage: plotly generated, nchar=", nchar(jsonOrTryError), " isTryError=", isTryError(jsonOrTryError), "\n", file = stderr()) if (exists(".fromRCPP")) { if (isTryError(jsonOrTryError)) { @@ -135,8 +150,10 @@ writeImageJaspResults <- function(plot, width = 320, height = 320, obj = TRUE, r if (!is.null(relativePathJson) && nzchar(relativePathJson)) { locationPlotly <- list(root = location$root, relativePath = relativePathJson) + cat("DEBUG writeImage: reusing interactiveJsonData path='", relativePathJson, "'\n", file = stderr()) } else { locationPlotly <- .fromRCPP(".requestTempFileNameNative", "json") + cat("DEBUG writeImage: NEW interactiveJsonData path='", locationPlotly$relativePath, "'\n", file = stderr()) } fullPathPlotly <- paste(locationPlotly$root, locationPlotly$relativePath, sep="/") plotlyJsonFile <- file(fullPathPlotly) @@ -145,11 +162,13 @@ writeImageJaspResults <- function(plot, width = 320, height = 320, obj = TRUE, r if(file.exists(fullPathPlotly)) { image[["interactiveJsonData"]] <- locationPlotly$relativePath + cat("DEBUG writeImage: file written OK, interactiveJsonData='", locationPlotly$relativePath, "'\n", file = stderr()) } else { image[["interactiveJsonData"]] <- "" image[["interactiveConvertError"]] <- gettext("No interactive plot generated...") + cat("DEBUG writeImage: file NOT found after write! fullPathPlotly='", fullPathPlotly, "'\n", file = stderr()) } } }