if(grouping_{{ env_id }} %in% names(colormaps)) colors_{{ env_id }} <- colormaps[[grouping_{{ env_id }}]] else colors_{{ env_id }} <- "Set1" sp_bars <- plotly::plot_ly(sd_{{ env_id }}, colors = colors_{{ env_id }}, x = df_{{ env_id }}[[grouping_{{ env_id }}]], color = df_{{ env_id }}[[grouping_{{ env_id }}]]) %>% plotly::layout( xaxis = list(title = names(df_{{ env_id }}[grouping_{{ env_id }}])), yaxis = list(title = "Number of observations"), barmode = "overlay", showlegend = FALSE ) %>% plotly::highlight("plotly_selected") sp_bars
# # Output # output$plot_sp_bars_{{ env_id }} <- plotly::renderPlotly({ if(df_{{ env_id }}()$grouping %in% names(colormaps)) colors <- colormaps[[df_{{ env_id }}()$grouping]] else colors <- "Set1" sp_bars <- plotly::plot_ly(df_{{ env_id }}()$sd, colors = colors, x = df_{{ env_id }}()$df[[df_{{ env_id }}()$grouping]], color = df_{{ env_id }}()$df[[df_{{ env_id }}()$grouping]]) %>% plotly::layout( xaxis = list(title = names(df_{{ env_id }}()$df[df_{{ env_id }}()$grouping])), yaxis = list(title = "Number of observations"), barmode = "overlay", showlegend = FALSE ) %>% plotly::highlight("plotly_selected") sp_bars }) # # Layout of component # renderUI({plotly::plotlyOutput("plot_sp_bars_{{ env_id }}", height = "100%")})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.