AshReports.Charts.Types.BarChart (ash_reports v0.1.0)
Bar chart implementation using Contex.
Supports grouped, stacked, and horizontal bar charts for categorical data visualization.
Data Format
Data should be a list of maps with at minimum a category and value field:
[
%{category: "Jan", value: 100},
%{category: "Feb", value: 150},
%{category: "Mar", value: 120}
]For grouped/stacked charts, include a series field:
[
%{category: "Jan", series: "Product A", value: 100},
%{category: "Jan", series: "Product B", value: 80},
%{category: "Feb", series: "Product A", value: 150},
%{category: "Feb", series: "Product B", value: 90}
]Configuration
Standard chart configuration plus:
type- :grouped, :stacked, or :simple (default: :simple)orientation- :vertical or :horizontal (default: :vertical)
Examples
# Simple bar chart
data = [
%{category: "A", value: 10},
%{category: "B", value: 20}
]
config = %Config{title: "Simple Bar Chart"}
chart = BarChart.build(data, config)
# Grouped bar chart
data = [
%{category: "Q1", series: "2023", value: 100},
%{category: "Q1", series: "2024", value: 120}
]
config = %Config{title: "Yearly Comparison"}
chart = BarChart.build(data, config)