Skip to content

Commit 10f4dac

Browse files
author
Jeffrey Shen
committed
Support renderValue within iframe
1 parent 8e89a00 commit 10f4dac

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

inst/htmlwidgets/plotly.js

+16
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,18 @@ HTMLWidgets.widget({
148148
}
149149
}
150150

151+
// remove "sendDataToCloud", unless user has specified they want it
152+
x.config = x.config || {};
153+
if (!x.config.cloud) {
154+
x.config.modeBarButtonsToRemove = x.config.modeBarButtonsToRemove || [];
155+
x.config.modeBarButtonsToRemove.push("sendDataToCloud");
156+
}
157+
158+
// if the object was passed in from another window, plotly will falsely think it isn't a "plain object"
159+
// to get around this, we have to create a deep copy of the object
160+
if (inIframe() && !isPlainObject(x))
161+
x = JSON.parse(JSON.stringify(x))
162+
151163
// if no plot exists yet, create one with a particular configuration
152164
if (!instance.plotly) {
153165

@@ -868,6 +880,10 @@ function isPlainObject(obj) {
868880
);
869881
}
870882

883+
function inIframe() {
884+
return window && window.self !== window.top;
885+
}
886+
871887
function subsetArrayAttrs(obj, indices) {
872888
var newObj = {};
873889
Object.keys(obj).forEach(function(k) {

0 commit comments

Comments
 (0)