Plotly: multiple selectize/dynamic color brushes rendered in shiny

Created on 23 Jul 2019  路  5Comments  路  Source: ropensci/plotly

All 5 comments

Hi Carson, I've come across the same issue. I'd prefer to stick with the highlight approach vs. event_data if possible. I find that the plots appear fine in my app, unless I change the value of a dateRangeInput upstream, causing the app to filter the data and reload. My code is below:

`all_cases_by_measure<- reactive({

by_measure_nested<- nested_data() %>% dplyr::mutate(data = purrr::map(data, ~ dplyr::mutate(., timepoint = 1:length(.x$date))))

by_measure<- tidyr::unnest(by_measure_nested)

by_measure<- dplyr::mutate(by_measure, timepoint = paste("Time", timepoint))

by_measure<- by_measure %>% tidyr::unite("Client", first_name, last_name, birth_date, sep = " ")

by_measure<- by_measure %>% dplyr::group_by(subscale, timepoint) %>% dplyr::mutate(mean_score = round(mean(score, na.rm = TRUE), 2)) %>% dplyr::ungroup()

by_measure$subscale<- gsub("_", "-", by_measure$subscale)

by_measure %>%
group_by(subscale) %>%
dplyr::do(
p = highlight_key(., ~Client, group = "Select A Client") %>%
plot_ly(type = 'scatter', mode = 'lines', showlegend = FALSE) %>%
add_lines(x = ~timepoint, y = ~ mean_score, text = ~paste("Mean Score:", mean_score),
line = list(width = 3, dash = 'dash'),
marker = list(symbol ="diamond-open"),
mode = 'lines+markers', hoverinfo = "text") %>%
group_by(Client) %>%
add_trace(
x = ~timepoint, y = ~score, text = ~paste("Client:", Client, "
",
"Assessment Date:", date, "
",
"Score:", score, "
",
"Change Since Previous:", sprintf("%+3.1f", change_all)
),
mode = 'lines+markers', hoverinfo = "text") %>%
layout(xaxis = list(tickangle = 45)) %>%
add_annotations(
text = ~unique(subscale),
x = 0.5, y = 1,
xref = "paper", yref = "paper",
xanchor = "center", yanchor = "bottom",
showarrow = FALSE
)
) %>%
subplot(
nrows = (NROW(.)/2) + 1,
shareY = FALSE, shareX = FALSE, titleY = FALSE
) %>% highlight(
dynamic = TRUE,
selectize = TRUE,
color = "red"
)

})

output$plot_all_cases_by_measure<- plotly::renderPlotly({

req(all_cases_by_measure())

})`

I am also having this issue with Plotly in R. When I "highlight" and set "selectize = TRUE" I get a second box with a vertical scroll bar. I would really like to remove this box. Any thoughts? Maybe it is because my data set is very large (scatter plot with >40,000 points). Sorry I can't share more than the image at this point as the data is proprietary. Thanks in advance!

PlotlyDoubleBox

@AFoudree, I had the same problem -- the same vertical-scroll-bar artifact when I added a selectize dropdown menu to a scatterplot. Curiously, the problem appeared only when I used type = "scattergl"; it didn't appear with type = "scatter". (I know that switching to type = "scatter" may not work for you. 40,000 points in a plot seems like a lot.)

@jbullock35 Thanks for the comment. I cannot believe I missed the notification on this in my inbox. I will play with the scatter type and get back to you shortly. Thanks for the advice!

@jbullock35 I was finally able to remove the second vertical-scroll-bar artifact! I found a solution in stack overflow (Mar 8th, 2020). It looks like the problem may be occurring because the highlight-selectize widget does not work well with shiny dashboards. The fix involves embedding java script to manually remove the scroll-bar-artifact. This solution was presented by St茅phaneLaurent and can be found here: https://stackoverflow.com/questions/60583349/why-does-shiny-app-add-a-spurious-widget-to-a-plotly-graph-using-highlight-funct/62795535#62795535

Thanks again for your helpful ideas!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

d4tagirl picture d4tagirl  路  7Comments

escorial82 picture escorial82  路  6Comments

kranthikandi picture kranthikandi  路  4Comments

robertleitner picture robertleitner  路  5Comments

msummersgill picture msummersgill  路  3Comments