The shared building blocks of the six report pages: the filter bar, stat tiles, the trend chart, and the ranked breakdown card.
The charts are CSS, not JavaScript
A module whose whole premise is "no client-side weight on your pages" would
be a strange place to pull in a charting library for its own admin. Every
visual here is divs with a percentage height or width — themed by daisyUI
variables, responsive without a resize listener, and readable in both light
and dark themes with no configuration. Values are exposed through title
attributes, so hovering still tells you the exact number.
Summary
Functions
A ranked "label + counts" card, with each row's share drawn as a bar behind the label.
Percentage change from previous to current, or nil when there is no
meaningful comparison (no previous data, or no previous period at all).
A short call to action shown when tracking is installed but off.
Period + site selector shared by every report page.
Formats a duration in seconds as 1m 05s.
Formats a millisecond duration.
Formats an integer with thin thousands separators (1 234 567).
Formats a percentage to one decimal place.
A headline number, optionally with its change against the previous period.
The trend chart — one column per bucket, height proportional to the metric.
Functions
A ranked "label + counts" card, with each row's share drawn as a bar behind the label.
Attributes
title(:string) (required)rows(:list) (required)icon(:string) - Defaults tonil.empty_message(:string) - Defaults to"Nothing recorded yet.".label_header(:string) - Defaults tonil.metric_header(:string) - Defaults to"Views".link(:string) - Defaults tonil.link_label(:string) - Defaults to"View all".
Percentage change from previous to current, or nil when there is no
meaningful comparison (no previous data, or no previous period at all).
A short call to action shown when tracking is installed but off.
Attributes
settings_path(:string) (required)
Period + site selector shared by every report page.
Emits phx-change="filter" with period and site params.
Attributes
period(:string) (required)site(:string) - Defaults tonil.sites(:list) - Defaults to[].active_visitors(:integer) - Defaults tonil.
Formats a duration in seconds as 1m 05s.
iex> PhoenixKitWebAnalytics.Web.Components.format_duration(65.4)
"1m 05s"
Formats a millisecond duration.
Formats an integer with thin thousands separators (1 234 567).
iex> PhoenixKitWebAnalytics.Web.Components.format_number(1234567)
"1,234,567"
Formats a percentage to one decimal place.
A headline number, optionally with its change against the previous period.
Attributes
label(:string) (required)value(:string) (required)hint(:string) - Defaults tonil.delta(:float) - Defaults tonil.delta_good(:atom) - Defaults to:up. Must be one of:up, or:down.
The trend chart — one column per bucket, height proportional to the metric.
Renders nothing but divs: no canvas, no chart library, no resize handler.
Named traffic_chart rather than bar_chart because core 2.0 introduced
PhoenixKitWeb.Components.Core.Chart.bar_chart/1, which every LiveView
imports via use PhoenixKitWeb, :live_view — two same-arity imports of that
name make an unqualified call ambiguous and fail to compile. Core's is a
generic SVG chart keyed on id/data; this one is bucket-aware and takes
series/metric/bucket, so they are not interchangeable.
Attributes
series(:list) (required)metric(:atom) - Defaults to:pageviews. Must be one of:pageviews, or:visitors.bucket(:atom) - Defaults to:day.