Coder Social home page Coder Social logo

Comments (3)

sigmapi avatar sigmapi commented on August 23, 2024 1

Fixed this in 70e4d62

Added title and desc arguments to dsvg function. You can set them in girafe function and they'll be forwarded.
The result is that:

  • title and desc sub-elements are added to the svg element
  • aria-labelledby and aria-describedby attributes are added to the svg element
  • role attribute (role='img') is added to the svg element

Here is a minimal example:

library(ggplot2)
library(ggiraph)
dat <- mtcars
dat$carname <- row.names(mtcars)
gg <- ggplot(data = dat) +
  geom_point_interactive(aes(
    x = wt, y = qsec, color = disp,
    tooltip = paste(carname, disp, sep = "\n"), 
    data_id = carname
  )) +
  theme_minimal()
x <- girafe(ggobj = gg_point, title = "ggiraph is cool!", desc = "very very cool!")
print(x)

Be aware that when using the title argument, the browser will use it as a tooltip for the whole svg an it may class with the interactive elements' tooltip, as you can see in the example above.

from ggiraph.

sigmapi avatar sigmapi commented on August 23, 2024 1

I preferred to stick with the w3c naming and use title and desc instead of alt-title and alt-desc.

As for the caption, we'd like to leave it out for now.
If you really want a caption you can accomplish it by other way, for example enclose the widget in a figure element with a figcaption.
Additionally, with the quarto develpment going on, this could by accomplished with quarto code.

from ggiraph.

geotheory avatar geotheory commented on August 23, 2024

In fact would be good to implement alt_title, alt_desc & caption as per https://co-analysis.github.io/govuk-hugo-demo/section/render_svg/

from ggiraph.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.