CodexBloom - Programming Q&A Platform

Integrating accessibility features in R visualizations with plotly and shiny for diverse user needs

👀 Views: 0 💬 Answers: 1 📅 Created: 2025-09-13
r shiny plotly accessibility R

I've been working on this all day and Been tasked with creating interactive dashboards using R's Shiny and plotly, focusing on improving accessibility for users with visual impairments... The goal is to ensure that visualizations are not only informative but also compliant with WCAG standards. I started by implementing basic tooltips for hover interactions, but I want to take it a step further by enabling screen readers to interpret the visualizations correctly. Here’s a simplified version of the code I'm working with: ```r library(shiny) library(plotly) ui <- fluidPage( plotlyOutput("myPlot") ) server <- function(input, output) { output$myPlot <- renderPlotly({ p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Sepal.Width, type = 'scatter', mode = 'markers') p <- p %>% layout(title = "Iris Dataset") p }) } shinyApp(ui, server) ``` Although tooltips show data when hovered over, I realized that this alone doesn’t address screen reader functionalities. Exploring options, I've researched adding ARIA attributes to the plotly chart. However, I'm uncertain how to effectively integrate ARIA roles and properties within the plotly object. One approach I considered was using `plotly::plotly_build()` to modify the underlying plotly object. But it’s not straightforward, and the documentation isn’t clear on how to access ARIA attributes. Has anyone successfully enhanced plotly visualizations with accessibility features? Any examples or best practices would be greatly appreciated. Additionally, I intend to use tabsets in Shiny to allow users to navigate through visualizations, which I hope will also improve accessibility. My aim is to ensure that all elements are keyboard navigable, but I'm still in the early stages of implementation. Would love some insights or resources on this topic. My development environment is Linux. For reference, this is a production web app. Any help would be greatly appreciated! What would be the recommended way to handle this? I'm working on a web app that needs to handle this. Hoping someone can shed some light on this.