Bar chart - Code
Basic
Common bar charts normally compare the values of different categories where the length of the bars are proportional to their values.
Stacked bar chart
Stacked bar charts are typically used to visualize the relationship between the parts and the whole. Each bar is divided into segments, with each segment representing a different category.
Dos and Don’ts
- Do start the Y-axis at zero and label axes clearly
- Do use short and clear category names
- Do include context and additional information when necessary
- Do arrange categories and bars in a logical order
- Don’t use too many bars in one chart
- Don’t overcrowd charts with colors and categories, especially the stacked variant
- Don’t use stacked bars if the total value is not important