Skip to contents

dashboardr (development version)

Unified Stacked Bar Chart Function

viz_stackedbar() is now a unified function that supports two modes:

Mode 1: Grouped/Crosstab (use x_var + stack_var)

# Show how one variable breaks down by another
viz_stackedbar(data, x_var = "education", stack_var = "gender")

Mode 2: Multi-Variable/Battery (use x_vars)

# Compare multiple survey questions side-by-side
viz_stackedbar(data, x_vars = c("q1", "q2", "q3"))

This eliminates confusion between viz_stackedbar() and viz_stackedbars() - you now only need to remember one function! The function automatically detects which mode to use based on the parameters you provide.

Migration from viz_stackedbars(): Simply change the function name - all parameters work the same way:

# Old way (still works, shows deprecation notice)
viz_stackedbars(data, x_vars = c("q1", "q2", "q3"))

# New preferred way
viz_stackedbar(data, x_vars = c("q1", "q2", "q3"))

The viz_stackedbars() function is soft-deprecated and will continue to work, but we recommend using viz_stackedbar() for all new code.

Breaking Changes

Visualization Function Renaming

All create_* visualization functions have been renamed to viz_* for clarity and to distinguish them from dashboard-level creation functions:

Old Name New Name
create_histogram() viz_histogram()
create_bar() viz_bar()
create_stackedbar() viz_stackedbar()
create_stackedbars() viz_stackedbars()
create_timeline() viz_timeline()
create_heatmap() viz_heatmap()
create_scatter() viz_scatter()
create_map() viz_map()
create_treemap() viz_treemap()

The old function names are deprecated and will show a warning when used. They will be removed in a future version.

Migration: Simply replace create_ with viz_ in your code.

Timeline Parameter Renaming

Timeline chart parameters have been renamed for consistency with other visualization types:

Old Name New Name
response_var y_var
response_filter y_filter
response_filter_combine y_filter_combine
response_filter_label y_filter_label
response_levels y_levels
response_breaks y_breaks
response_bin_labels y_bin_labels

New Features

Error Bars Support in Bar Charts

viz_bar() now supports error bars for displaying uncertainty in mean values:

  • New value_var parameter: When provided, bars show the mean of this variable per category (instead of counts)
  • New error_bars parameter: Choose from β€œnone” (default), β€œsd” (standard deviation), β€œse” (standard error), or β€œci” (confidence interval)
  • New ci_level parameter: Set confidence level for CI (default 0.95 for 95% CI)
  • Customizable appearance via error_bar_color and error_bar_width parameters
  • Works with both simple and grouped bar charts

Example usage:

# Bar chart with means and 95% CI
viz_bar(
  data = mtcars,
  x_var = "cyl",
  value_var = "mpg",
  error_bars = "ci",
  title = "Mean MPG by Cylinders"
)

# Grouped bars with standard error
viz_bar(
  data = mtcars,
  x_var = "cyl",
  group_var = "am",
  value_var = "mpg",
  error_bars = "se"
)

Early Validation for Visualizations

  • preview() now automatically validates all visualization specs before rendering, catching missing required parameters (like stack_var for stacked bar charts) and invalid column names early with helpful error messages
  • New validate_specs() function for manual validation of content collections
  • print(collection, check = TRUE) validates specs while viewing the structure

New Visualization Types

  • viz_density(): Create kernel density estimate plots for visualizing continuous distributions. Supports grouped densities, adjustable bandwidth, rug marks, and weighted estimation.
  • viz_boxplot(): Create interactive box-and-whisker plots. Supports grouped boxplots, horizontal orientation, outlier display, and weighted percentiles.

Histogram Improvements

  • Fixed handling of character-numeric values (e.g., β€œ25”, β€œ30”) - now correctly converted to numeric for binning
  • Improved default bin labels to show readable ranges (e.g., β€œ18-29” instead of β€œ[18,30)”)
  • Added data_labels_enabled parameter to control display of value labels on bars

Data Labels Control

Documentation

  • Added new visualization vignettes: density_vignette, boxplot_vignette, histogram_vignette, scatter_vignette, treemap_vignette, map_vignette
  • Interactive inputs demo and documentation in vignette("advanced-features")
  • Improved cross-references between vignettes

Bug Fixes

  • Fixed Unicode/emoji rendering issues in console output
  • Fixed nested tabgroup rendering in preview()
  • Fixed parameter mapping for stackedbars visualization type