Draws a column chart: a hairline grid, columns with rounded tops and square feet, 2 pixels apart, the busiest day or month labelled, and the first and the last under the axis; or, for named columns such as the days of the week, each name under its column. Each column has its day or month and its value as a tooltip, where the SVG itself is shown, not a PNG of it.
Arguments
- data
A data frame of
dateandvalue, or oflabelandvaluefor named columns.- x, w
Where the chart starts, and its width, in pixels.
- col
The colours of the card, from
card_colors().- unit
The unit of the values, for one and for several, for the tooltips.
- by
"day","month"or"label": what each column is.
Examples
data <- data.frame(date = as.Date("2026-12-01") + 0:6, value = c(3, 0, 5, 2, 8, 1, 4))
svg <- rghcard:::columns_svg(data, 24, 260, rghcard:::card_colors("dark"),
c("page view", "page views"))
cat(substr(svg, 1, 300))
#> <line x1="36.0" y1="420.0" x2="284.0" y2="420.0" stroke="#3d444d" stroke-width="1"/>
#> <text x="30.0" y="423.5" font-size="10" font-weight="400" fill="#9198a1" text-anchor="end">0</text>
#> <line x1="36.0" y1="373.0" x2="284.0" y2="373.0" stroke="#21262d" stroke-width="1"/>
#> <text x="30.0" y="376.5" font-
days <- data.frame(label = c("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"),
value = c(52, 61, 58, 49, 40, 12, 9))
svg <- rghcard:::columns_svg(days, 24, 260, rghcard:::card_colors("dark"),
c("contribution", "contributions"), by = "label")