Skip to content
Open
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
4 changes: 3 additions & 1 deletion R/common.R
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,7 @@ editImage <- function(name, optionsJson) {
jaspPlotCPP$plotObject <- newPlot

}
interactiveJsonData <- jaspPlotCPP$interactiveJsonData
revision <- jaspPlotCPP$revision

finishJaspResults(jaspResultsCPP, calledFromAnalysis = FALSE)
Expand All @@ -1140,7 +1141,8 @@ editImage <- function(name, optionsJson) {
height = height,
revision = revision,
error = FALSE,
editOptions = jaspGraphs::plotEditingOptions(plot)
editOptions = jaspGraphs::plotEditingOptions(plot),
interactiveJsonData = interactiveJsonData
)
)

Expand Down
9 changes: 7 additions & 2 deletions R/writeImage.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ openGrDevice <- function(...) {
ragg::agg_png(...)
}

writeImageJaspResults <- function(plot, width = 320, height = 320, obj = TRUE, relativePathpng = NULL, ppi = 300, backgroundColor = "white",
writeImageJaspResults <- function(plot, width = 320, height = 320, obj = TRUE, relativePathpng = NULL, relativePathJson = NULL, ppi = 300, backgroundColor = "white",
location = getImageLocation(), oldPlotInfo = list()) {
# Set values from JASP'S Rcpp when available
if (exists(".fromRCPP")) {
Expand Down Expand Up @@ -132,7 +132,12 @@ writeImageJaspResults <- function(plot, width = 320, height = 320, obj = TRUE, r
if (isTryError(jsonOrTryError)) {
image[["interactiveConvertError"]] = gettextf("The following error occured while converting a ggplot to plotly: %s", .extractErrorMessage(jsonOrTryError))
} else {
locationPlotly <- .fromRCPP(".requestTempFileNameNative", "json")

if (!is.null(relativePathJson) && nzchar(relativePathJson)) {
locationPlotly <- list(root = location$root, relativePath = relativePathJson)
} else {
locationPlotly <- .fromRCPP(".requestTempFileNameNative", "json")
}
fullPathPlotly <- paste(locationPlotly$root, locationPlotly$relativePath, sep="/")
plotlyJsonFile <- file(fullPathPlotly)
on.exit(close(plotlyJsonFile), add = TRUE)
Expand Down
11 changes: 6 additions & 5 deletions src/jaspModuleRegistration.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ RCPP_MODULE(jaspResults)

.property("plotObject", &jaspPlot_Interface::getPlotObject, &jaspPlot_Interface::setPlotObject, "Stores the plotObj used to generate the graphic, will (should) be stored in a way that is later accesible to saveImage an editImage.")

.property("editing", &jaspPlot_Interface::getEditing, &jaspPlot_Interface::setEditing, "If set to true will overwrite current png file when rendering a plot.")
.property("resizedByUser", &jaspPlot_Interface::getResizedByUser, &jaspPlot_Interface::setResizedByUser, "If set to true, a user resized the plot and its width and height may be recycled in future runs of this analysis.")
.property("revision", &jaspPlot_Interface::getRevision, "return the current revision of the plot.")
.property("editing", &jaspPlot_Interface::getEditing, &jaspPlot_Interface::setEditing, "If set to true will overwrite current png file when rendering a plot.")
.property("resizedByUser", &jaspPlot_Interface::getResizedByUser, &jaspPlot_Interface::setResizedByUser, "If set to true, a user resized the plot and its width and height may be recycled in future runs of this analysis.")
.property("revision", &jaspPlot_Interface::getRevision, "return the current revision of the plot.")
.property("interactiveJsonData", &jaspPlot_Interface::getInteractiveJsonData, "Returns the relative path to the interactive plotly JSON data file.")
;

JASPLIST_MODULE_EXPORT(jaspStringlist_Interface, "jaspStringlist")
Expand Down Expand Up @@ -189,7 +190,7 @@ RCPP_MODULE(jaspResults)
.property("class", &jaspHtml_Interface::getClass, &jaspHtml_Interface::setClass, "The Css-class of this element, for monospace one could use jasp-code or simply leave it empty.")
.property("maxWidth", &jaspHtml_Interface::getMaxWidth, &jaspHtml_Interface::setMaxWidth, "The Css-max-width property. It will be set on a span around your html.")
;

Rcpp::class_<jaspReport_Interface>("jaspReport")
.derives<jaspObject_Interface>("jaspObject")
.property("text", &jaspReport_Interface::getText, &jaspReport_Interface::setText, "The text of this element")
Expand Down Expand Up @@ -234,7 +235,7 @@ RCPP_MODULE(jaspResults)

.method("prepareForWriting", &jaspResults_Interface::prepareForWriting, "Remove seal for writing")
.method("finishWriting", &jaspResults_Interface::finishWriting, "Set seal for writing")
.method("saveResults", &jaspResults_Interface::saveResults, "save results")
.method("saveResults", &jaspResults_Interface::saveResults, "save results")
;

Rcpp::class_<jaspQmlSource_Interface>("jaspQmlSource")
Expand Down
2 changes: 1 addition & 1 deletion src/jaspPlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void jaspPlot::renderPlot()
{
oldPlotInfo = Rcpp::List();
_revision++;
writeResult = tryToWriteImage(Rcpp::_["width"] = _width, Rcpp::_["height"] = _height, Rcpp::_["plot"] = obj, Rcpp::_["oldPlotInfo"] = oldPlotInfo, Rcpp::_["relativePathpng"] = _filePathPng);
writeResult = tryToWriteImage(Rcpp::_["width"] = _width, Rcpp::_["height"] = _height, Rcpp::_["plot"] = obj, Rcpp::_["oldPlotInfo"] = oldPlotInfo, Rcpp::_["relativePathpng"] = _filePathPng, Rcpp::_["relativePathJson"] = Rcpp::String(_interactiveJsonData));
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions src/jaspPlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ class jaspPlot_Interface : public jaspObject_Interface
JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR(jaspPlot, int, _height, Height)
JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR(jaspPlot, int, _revision, Revision)

JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR_NO_NOTIFY(jaspPlot, bool, _editing, Editing)
JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR_NO_NOTIFY(jaspPlot, bool, _resizedByUser, ResizedByUser)
JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR_NO_NOTIFY(jaspPlot, bool, _editing, Editing)
JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR_NO_NOTIFY(jaspPlot, bool, _resizedByUser, ResizedByUser)
JASPOBJECT_INTERFACE_PROPERTY_FUNCTIONS_GENERATOR_NO_NOTIFY(jaspPlot, std::string, _interactiveJsonData, InteractiveJsonData)
};

RCPP_EXPOSED_CLASS_NODECL(jaspPlot_Interface)
Loading