@@ -24,12 +24,10 @@ HTMLWidgets.widget({
24
24
25
25
renderValue : function ( el , x , instance ) {
26
26
27
- var shinyMode ;
28
27
if ( typeof ( window ) !== "undefined" ) {
29
- // make sure plots don't get created outside the network
28
+ // make sure plots don't get created outside the network (for on-prem)
30
29
window . PLOTLYENV = window . PLOTLYENV || { } ;
31
30
window . PLOTLYENV . BASE_URL = x . base_url ;
32
- shinyMode = ! ! window . Shiny ;
33
31
}
34
32
35
33
var graphDiv = document . getElementById ( el . id ) ;
@@ -209,12 +207,12 @@ HTMLWidgets.widget({
209
207
}
210
208
211
209
// send user input event data to shiny
212
- if ( shinyMode ) {
210
+ if ( HTMLWidgets . shinyMode ) {
213
211
// https://plot.ly/javascript/zoom-events/
214
212
graphDiv . on ( 'plotly_relayout' , function ( d ) {
215
213
Shiny . onInputChange (
216
214
".clientValue-plotly_relayout-" + x . source ,
217
- JSON . stringify ( eventDataWithKey ( d ) )
215
+ JSON . stringify ( d )
218
216
) ;
219
217
} ) ;
220
218
graphDiv . on ( 'plotly_hover' , function ( d ) {
@@ -805,70 +803,3 @@ function removeBrush(el) {
805
803
outlines [ i ] . remove ( ) ;
806
804
}
807
805
}
808
-
809
- /* Currently not used
810
-
811
- // Given an array of strings, return an object that hierarchically
812
- // represents the corresponding curves/points.
813
- //
814
- // For example, the following data:
815
- //
816
- // [
817
- // {curveNumber: 0, pointNumber: 1},
818
- // {curveNumber: 0, pointNumber: 2},
819
- // {curveNumber: 2, pointNumber: 1}
820
- // ]
821
- //
822
- // would be returned as:
823
- // {
824
- // "0": [1, 2],
825
- // "2": [1]
826
- // }
827
-
828
- // # Begin Crosstalk support
829
-
830
- // ## Crosstalk point/key translation functions
831
- //
832
- // Plotly.js uses curveNumber/pointNumber addressing to refer
833
- // to data points (i.e. when plotly_selected is received). We
834
- // prefer to let the R user use key-based addressing, where
835
- // a string is used that uniquely identifies a data point (we
836
- // can also use row numbers in a pinch).
837
- //
838
- // The pointsToKeys and keysToPoints functions let you convert
839
- // between the two schemes.
840
-
841
- // Combine the name of a set and key into a single string, suitable for
842
- // using as a keyCache key.
843
- function joinSetAndKey(set, key) {
844
- return set + "\n" + key;
845
- }
846
-
847
- // To allow translation from sets+keys to points in O(1) time, we
848
- // make a cache that lets us map keys to objects with
849
- // {curveNumber, pointNumber} properties.
850
- var keyCache = {};
851
- for (var i = 0; i < x.data.length; i++) {
852
- var trace = x.data[i];
853
- if (!trace.key || !trace.set) {
854
- continue;
855
- }
856
- for (var j = 0; j < trace.key.length; j++) {
857
- var nm = joinSetAndKey(trace.set, trace.key[j]);
858
- keyCache[nm] = {curveNumber: i, pointNumber: j};
859
- }
860
- }
861
-
862
- function keysToPoints(set, keys) {
863
- var curves = {};
864
- for (var i = 0; i < keys.length; i++) {
865
- var pt = keyCache[joinSetAndKey(set, keys[i])];
866
- if (!pt) {
867
- throw new Error("Unknown key " + keys[i]);
868
- }
869
- curves[pt.curveNumber] = curves[pt.curveNumber] || [];
870
- curves[pt.curveNumber].push(pt.pointNumber);
871
- }
872
- return curves;
873
- }
874
- */
0 commit comments