-
-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
e_showtip_p
/ e_dispatch_action_p
not working in modularized shiny app, attempting to debug with local fork but debugger
doesn't register in the addCustomMessageHandler
#612
Comments
e_showtip_p
not working in modularized shiny app, attempting to debug with local fork but debugger
doesn't register in the addCustomMessageHandler
e_showtip_p
/ e_dispatch_action_p
not working in modularized shiny app, attempting to debug with local fork but debugger
doesn't register in the addCustomMessageHandler
After much trial & error, I've managed to get library(shiny)
devtools::load_all()
ui <- fluidPage(
fluidRow(
column(6, echarts4rOutput("plot")),
column(6, echarts4rOutput("plot2"))
)
)
server <- function(input, output, session) {
output$plot <- renderEcharts4r({
mtcars |>
e_charts(mpg) |>
e_line(disp, bind = carb, name = "displacement", emphasis = list(
disabled = FALSE,
lineStyle = list(opacity = 1,
width = 6)
)) |>
e_line(hp, emphasis = list(
disabled = FALSE,
lineStyle = list(opacity = 1,
width = 6)
)) |>
e_x_axis(min = 10) |>
e_tooltip() |>
e_theme("westeros") |>
e_group('p') |>
e_on(
"series",
event = "mouseover",
"
(event) => {
Shiny.setInputValue('plot_mouseover_seriesIndex', event.seriesIndex, {priority: 'event'})
}
"
) |>
e_on(
"series",
event = "mouseover",
"
(event) => {
Shiny.setInputValue('plot_mouseout_seriesIndex', event.seriesIndex, {priority: 'event'})
}
"
)
})
output$plot2 <- renderEcharts4r({
mtcars |>
e_charts(mpg) |>
e_line(disp, bind = carb, name = "displacement", emphasis = list(
disabled = FALSE,
lineStyle = list(opacity = 1,
width = 6)
)) |>
e_line(hp, emphasis = list(
disabled = FALSE,
lineStyle = list(opacity = 1,
width = 6)
)) |>
e_x_axis(min = 10) |>
e_tooltip() |>
e_theme("westeros") |>
e_group('p') |>
e_on(
"series",
event = "mouseover",
"
(event) => {
Shiny.setInputValue('plot2_mouseover_seriesIndex', event.seriesIndex, {priority: 'event'})
}
"
) |>
e_on(
"series",
event = "mouseout",
"
(event) => {
Shiny.setInputValue('plot2_mouseout_seriesIndex', event.seriesIndex, {priority: 'event'})
}
"
)
# |>
# e_connect_group("p")
})
browse = FALSE
observeEvent(input$plot_mouseover_seriesIndex, {
cli::cli_inform("plot_mouseover")
if (browse)
browser()
prox <- echarts4rProxy("plot2")
e_dispatch_action_p(
prox,
"select",
seriesIndex = input$plot_mouseover_seriesIndex
)
e_showtip_p(
prox,
seriesIndex = input$plot_mouseover_seriesIndex
)
e_highlight_p(
prox,
series_index = input$plot_mouseover_seriesIndex
)
})
observeEvent(input$plot2_mouseover_seriesIndex, {
cli::cli_inform("plot2_mouseover")
if (browse)
browser()
prox <- echarts4rProxy("plot")
e_dispatch_action_p(
prox,
"select",
seriesIndex = input$plot2_mouseover_seriesIndex
)
e_showtip_p(
prox,
seriesIndex = input$plot2_mouseover_seriesIndex
)
e_highlight_p(
prox,
series_index = input$plot2_mouseover_seriesIndex
)
})
observeEvent(input$plot_mouseout_seriesIndex, {
cli::cli_inform("plot2_mouseout")
if (browse)
browser()
prox <- echarts4rProxy("plot2")
e_dispatch_action_p(
prox,
"select",
seriesIndex = input$plot_mouseout_seriesIndex
)
e_hidetip_p(
prox
)
e_downplay_p(
prox,
series_index = input$plot_mouseout_seriesIndex
)
})
observeEvent(input$plot2_mouseout_seriesIndex, {
cli::cli_inform("plot2_mouseout")
if (browse)
browser()
prox <- echarts4rProxy("plot")
e_dispatch_action_p(
prox,
"select",
seriesIndex = input$plot2_mouseout_seriesIndex
)
e_hidetip_p(
prox
)
e_downplay_p(
prox,
series_index = input$plot2_mouseout_seriesIndex
)
})
}
if (interactive()) {
shinyApp(ui, server)
} |
Thanks for the detailed issue once again! I'm afraid I haven't had any luck either. Doesn't work in pure. JavaScript either, echarts4r proxy code does execute but echarts.js fails to show the tooltip. Perhaps we'll need to update the JavaScript dependencies in echarts4r. |
Hi @JohnCoene and echarts4r maintainers,
I'm not having any luck getting any of the
echarts4r
action
handling helper functions to work in a modularized environment.I'm attempting to connect the showing of a tooltip between two different plots and the
e_dispatch_action_p
ande_showtip_p
used based on the echarts docs here appear to not be functioning. I've attempted to debug the problem with a local fork ofecharts4r
by addingdebugger
to the associatedsendCustomMessage
callbacks:but those don't appear to be being passed through to the rendered code. Probably something to do with the
HTMLWidgets
framework.There's a reprex below where the intended outcome is to have the mouseover event on a serie activate the tooltip for the same series on the other chart.
Can anyone:
`devtools::session_info`
The text was updated successfully, but these errors were encountered: