-
Notifications
You must be signed in to change notification settings - Fork 15
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
Brush Chart example error #23
Comments
I also currently have trouble recreating a brushed chart in Shiny. The code works, when I use it in Rmarkdown. But if I move the code to two apexchartOutputs, than the smaller plot used for filtering blanks out. |
Hello, There's indeed a bug in shiny, unfortunately I haven't found a solution yet. But here's an alternative using custom input and proxy to get the same result : Live demo: https://dreamrs.shinyapps.io/example-brush-proxy/ library(shiny)
library(apexcharter)
data("economics", package = "ggplot2")
ui <- fluidPage(
fluidRow(
column(
width = 8, offset = 2,
tags$h2("Apexchart brush example (alternative) in Shiny", class = "text-center"),
apexchartOutput("brush_1"),
apexchartOutput("brush_2", height = "130px")
)
)
)
server <- function(input, output, session) {
output$brush_1 <- renderApexchart({
apex(
data = economics,
mapping = aes(x = date, y = psavert),
type = "line"
) %>%
ax_chart(
toolbar = list(
autoSelected = "pan",
show = FALSE
)
)
})
output$brush_2 <- renderApexchart({
apex(
data = economics,
mapping = aes(x = date, y = psavert),
type = "line"
) %>%
ax_chart(
brush = list(
enabled = TRUE
),
offsetY = -20,
selection = list(
enabled = TRUE
)
) %>%
ax_xaxis(labels = list(show = FALSE)) %>%
ax_yaxis(labels = list(show = FALSE)) %>%
set_input_selection(
inputId = "brush",
xmin = format_date(economics$date[1]),
xmax = format_date(economics$date[100])
)
})
observeEvent(input$brush, {
apexchartProxy("brush_1") %>%
ax_proxy_options(list(
xaxis = list(
min = as.numeric(input$brush$x$min) * 1000,
max = as.numeric(input$brush$x$max) * 1000
)
))
})
}
shinyApp(ui, server) Victor |
Really been enjoying this package as it keeps maturing, so just wanted to say thanks first!
I've created a minimal Shiny app with the Brush Chart example on your package's
github.io
, but the 2nd chart (w/ brush:enabled=TRUE
) doesn't show up until I open the browser's devtools. When I open it in Chrome, I'm getting the errorTypeError: Cannot read property 'w' of undefined
.Reprex:
global.R
server.R
ui.R
Oddly enough, the exact same chart works locally in another app of mine, but then once it's deployed to shinyapps.io or a GCP VM Instance, the same console error occurs.
Here's my session info (
GithubSHA1: bd179f978b27fb34e9ac5b8a206339fdb5465bbf
):The text was updated successfully, but these errors were encountered: