This function generates an SVG visualization of a glass filled with water to a specified level, rendered via D3 using the r2d3 package. The fill level, appearance of the glass, and label settings can be customized.
glass_fill(
fill_level = 0.65,
glassWidth = 80,
glassHeight = 200,
strokeColor = "#555",
strokeWidth = 3,
fillColor = "skyblue",
renderFillLabel = TRUE,
labelFontSize = "16px",
titleText = "Fill level",
labelColor = "#333",
titleColor = "#333",
titleFontSize = "14px",
font = "Verdana, Geneva, Tahoma, sans-serif"
)
Numeric value between 0 and 1 indicating how full the glass should appear.
Width of the glass in pixels.
Height of the glass in pixels.
Color of the glass outline (stroke).
Width of the glass outline stroke.
Color used to fill the water in the glass.
Logical indicating whether to display a percentage label above the glass.
Font size of the label, defaults to "16px"
Text to display as the title beneath the glass.
Color of the label.
Color of the title text displayed below the glass.
Font size of the title text, defaults to "14px"
The font name that will be used for the plot text. Defaults to "Verdana, Geneva, Tahoma, sans-serif"
An interactive D3 visualization rendered in the RStudio Viewer or web browser.
glass_fill(fill_level = 0.75)
glass_fill(fill_level = 0.3, fillColor = "lightblue", titleText = "Water Intake")