Stacked Bar Charts are useful for visualising data with two levels, what might be considered “categories” and “subcategories” of information. The embedded Shiny app below acts as both a template app and demonstrates a number of htmlwidget libraries that could be used for this visualisation.
A toy example dataset is provided in the oidnChaRts
library:
library(oidnChaRts)
library(DT)
library(dplyr)
data_stacked_bar_chart %>%
sample_n(10) %>%
datatable(rownames = F)
The stacked bar chart template is embedded into the page below, see here for the code.
This template allows users to control the following:
Which htmlwidget library is used to display the data
Different libraries provide different features, move your cursor within the chart to explore what options are available to you.
How to stack bars (group, stack or percent)
Which column of the data file should be used to populate the categories (y-axis) and subcategories (individual bars) in the chart.
This template contains a number of standard features from the IDN Templates, you will need to read the separate guides to understand these features: