@@ -272,29 +272,35 @@ HTMLWidgets.widget({
272
272
273
273
// send user input event data to shiny
274
274
if ( HTMLWidgets . shinyMode ) {
275
+ var priority = x . config . priority ? { priority : x . config . priority } : undefined ;
276
+
275
277
// https://plot.ly/javascript/zoom-events/
276
278
graphDiv . on ( 'plotly_relayout' , function ( d ) {
277
279
Shiny . setInputValue (
278
280
".clientValue-plotly_relayout-" + x . source ,
279
- JSON . stringify ( d )
281
+ JSON . stringify ( d ) ,
282
+ priority
280
283
) ;
281
284
} ) ;
282
285
graphDiv . on ( 'plotly_restyle' , function ( d ) {
283
286
Shiny . setInputValue (
284
287
".clientValue-plotly_restyle-" + x . source ,
285
- JSON . stringify ( d )
288
+ JSON . stringify ( d ) ,
289
+ priority
286
290
) ;
287
291
} ) ;
288
292
graphDiv . on ( 'plotly_hover' , function ( d ) {
289
293
Shiny . setInputValue (
290
294
".clientValue-plotly_hover-" + x . source ,
291
- JSON . stringify ( eventDataWithKey ( d ) )
295
+ JSON . stringify ( eventDataWithKey ( d ) ) ,
296
+ priority
292
297
) ;
293
298
} ) ;
294
299
graphDiv . on ( 'plotly_click' , function ( d ) {
295
300
Shiny . setInputValue (
296
301
".clientValue-plotly_click-" + x . source ,
297
- JSON . stringify ( eventDataWithKey ( d ) )
302
+ JSON . stringify ( eventDataWithKey ( d ) ) ,
303
+ priority
298
304
) ;
299
305
} ) ;
300
306
graphDiv . on ( 'plotly_selected' , function ( d ) {
@@ -307,47 +313,52 @@ HTMLWidgets.widget({
307
313
if ( d ) {
308
314
Shiny . setInputValue (
309
315
".clientValue-plotly_selected-" + x . source ,
310
- JSON . stringify ( eventDataWithKey ( d ) )
316
+ JSON . stringify ( eventDataWithKey ( d ) ) ,
317
+ priority
311
318
) ;
312
319
var limits = d . range ? d . range : d . lassoPoints ;
313
320
Shiny . setInputValue (
314
321
".clientValue-plotly_brush-" + x . source ,
315
- JSON . stringify ( limits )
322
+ JSON . stringify ( limits ) ,
323
+ priority
316
324
) ;
317
325
}
318
326
} ) ;
319
327
graphDiv . on ( 'plotly_selecting' , function ( d ) {
320
328
if ( d ) {
321
329
Shiny . setInputValue (
322
330
".clientValue-plotly_selecting-" + x . source ,
323
- JSON . stringify ( eventDataWithKey ( d ) )
331
+ JSON . stringify ( eventDataWithKey ( d ) ) ,
332
+ priority
324
333
) ;
325
334
var limits = d . range ? d . range : d . lassoPoints ;
326
335
Shiny . setInputValue (
327
336
".clientValue-plotly_brushing-" + x . source ,
328
- JSON . stringify ( limits )
337
+ JSON . stringify ( limits ) ,
338
+ priority
329
339
) ;
330
340
}
331
341
} ) ;
332
342
graphDiv . on ( 'plotly_unhover' , function ( eventData ) {
333
- Shiny . setInputValue ( ".clientValue-plotly_hover-" + x . source , null ) ;
343
+ Shiny . setInputValue ( ".clientValue-plotly_hover-" + x . source , null , priority ) ;
334
344
} ) ;
335
345
graphDiv . on ( 'plotly_doubleclick' , function ( eventData ) {
336
- Shiny . setInputValue ( ".clientValue-plotly_click-" + x . source , null ) ;
346
+ Shiny . setInputValue ( ".clientValue-plotly_click-" + x . source , null , priority ) ;
337
347
} ) ;
338
348
// 'plotly_deselect' is code for doubleclick when in select mode
339
349
graphDiv . on ( 'plotly_deselect' , function ( eventData ) {
340
- Shiny . setInputValue ( ".clientValue-plotly_selected-" + x . source , null ) ;
341
- Shiny . setInputValue ( ".clientValue-plotly_selecting-" + x . source , null ) ;
342
- Shiny . setInputValue ( ".clientValue-plotly_brush-" + x . source , null ) ;
343
- Shiny . setInputValue ( ".clientValue-plotly_brushing-" + x . source , null ) ;
344
- Shiny . setInputValue ( ".clientValue-plotly_click-" + x . source , null ) ;
350
+ Shiny . setInputValue ( ".clientValue-plotly_selected-" + x . source , null , priority ) ;
351
+ Shiny . setInputValue ( ".clientValue-plotly_selecting-" + x . source , null , priority ) ;
352
+ Shiny . setInputValue ( ".clientValue-plotly_brush-" + x . source , null , priority ) ;
353
+ Shiny . setInputValue ( ".clientValue-plotly_brushing-" + x . source , null , priority ) ;
354
+ Shiny . setInputValue ( ".clientValue-plotly_click-" + x . source , null , priority ) ;
345
355
} ) ;
346
356
347
357
graphDiv . on ( 'plotly_clickannotation' , function ( d ) {
348
- Shiny . setInputValue ( ".clientValue-plotly_clickannotation-" + x . source , JSON . stringify ( d . fullAnnotation ) ) ;
358
+ Shiny . setInputValue ( ".clientValue-plotly_clickannotation-" + x . source , JSON . stringify ( d . fullAnnotation ) , priority ) ;
349
359
} ) ;
350
360
361
+ // This is a 'true' event -- always give it priority
351
362
graphDiv . on ( 'plotly_afterplot' , function ( ) {
352
363
Shiny . setInputValue ( ".clientValue-plotly_afterplot-" + x . source , "afterplot" , { priority : "event" } ) ;
353
364
} ) ;
0 commit comments