Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

How to use postMessageAPI in "on premise" Shiny/Plotly app?

I have been trying to understand how to use the Post Message AP (https://github.com/plotly/postMessage-API) to update a Shiny/Plotly app. I see many examples online with codepen that use plotly but I do not see any examples or steps that show how to use this with a on premise Shiny app. Essentially no embedded URL.

Does anyone have any idea or steps on how to do this or if this is even possible?

This should be possible. Can you share a snippet of you attempted so far?

Hey @ahsanshah
Shiny with Plotly doesn’t use the Post Message API anymore, it uses our open-source Plotly.js library. So Shiny already works completely offline, no embedded URL is required. We have a simple shiny tutorial here.

Thank you!. Yes, I was trying to use PostMessage API and realized I could
do with with the standard Plotly.restyle as follows:

jsCode3 <- "shinyjs.traceCol = function(params) {
Plotly.restyle(‘vis_p’, ‘line.color’,‘red’,3);
}"
includeScript(“www/plotly-tc.min.js”),

observeEvent(input$btn, {
js$traceCol()
})

            shinyjs::useShinyjs(),
            shinyjs::extendShinyjs(text = jsCode3),

I was also trying to use the extendshinyjs (script =
"www/plotly-tc.min.js)) which gave me issues. However, the IncludeScript
worked.

Thanks for your help.

Ahsan