diff --git a/docs/architecture.md b/docs/architecture.md
index e7823f4f..5c6b5c9b 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -285,7 +285,7 @@ All authenticated routes live inside a single `live_session` with three `on_moun
| `CoreComponents` | Forms, buttons, icons, tables, flash messages |
| `Layouts` | Application layout templates, navigation components (`dropdown_nav/1`) |
| `RecordComponents` | Record cards, cover images, artist images, labels, grids, shared show-page sections (title, external links, genres, releases, timestamps, debug) |
-| `ChartComponents` | SVG charts for stats |
+| `ChartComponents` | Charts for stats dashboard |
| `StatsComponents` | Stats dashboard widgets |
| `ScrobbleComponents` | Scrobble activity displays |
| `SearchComponents` | Search result rendering |
diff --git a/lib/music_library_web/components/chart_components.ex b/lib/music_library_web/components/chart_components.ex
index cc591d13..69858b81 100644
--- a/lib/music_library_web/components/chart_components.ex
+++ b/lib/music_library_web/components/chart_components.ex
@@ -1,24 +1,29 @@
defmodule MusicLibraryWeb.ChartComponents do
+ @moduledoc """
+ Chart components for the stats dashboard.
+ """
+
use MusicLibraryWeb, :live_component
@doc """
- Renders a horizontal bar chart.
+ Renders a horizontal bar chart using CSS Grid.
+
+ The label column auto-sizes to the widest label (up to 130px max),
+ bars fill remaining space proportionally, and values are displayed
+ to the right of each bar.
## Examples
+
<.vertical_bar_chart
data={[{"Artist 1", 5}, {"Artist 2", 3}]}
label_fn={&elem(&1, 0)}
value_fn={&elem(&1, 1)}
- width={400}
- height={300}
- color_class="fill-red-500"
+ color_class="bg-red-500"
/>
"""
attr :data, :list, required: true
attr :label_fn, :any, required: true
attr :value_fn, :any, required: true
- attr :width, :integer, default: 400
- attr :height, :integer, default: 300
attr :color_class, :string, required: true
attr :class, :string, default: ""
attr :datum_click, :any, default: nil, doc: "the function for handling phx-click on each datum"
@@ -26,71 +31,38 @@ defmodule MusicLibraryWeb.ChartComponents do
def vertical_bar_chart(assigns) when assigns.data != [] do
assigns =
assigns
- |> assign(:padding, 40)
|> assign(:max_value, max_value(assigns.data, assigns.value_fn))
- # Account for labels and padding
- |> assign(:chart_width, assigns.width - 150 - 40)
- # Account for bottom padding
- |> assign(:chart_height, assigns.height - 40)
- |> assign(:bar_height, calculate_bar_height(assigns.data, assigns.height - 40))
~H"""
-
-