Analytics dashboard Pro
A web analytics dashboard people arrange themselves. Key metrics count up to their values, revenue is drawn against the previous period (daily or weekly), live visitors tick every few seconds, and below sit a sign-up funnel, top pages, countries, devices, channels and weekly retention. A date range with presets or a calendar, Compare and filters by country, device and channel sit up top, and change every widget at once.
Edit dashboard turns the widgets into a DashboardGrid: drag to move, pull a corner to resize, ✕ removes with Undo, Add widget opens a gallery, and Reset layout puts everything back. On phones the widgets stack and a long press reorders them. The data is generated from a seed, so it looks real and never changes between runs.
import { AnalyticsDashboardScreen } from '@patine-ui/pro';
<AnalyticsDashboardScreen />;
<View style={{ width: '100%', height: 900 }}> <AnalyticsDashboardScreen /> </View>
| Prop | Type | Default |
|---|---|---|
demo | 'ready' | 'loading' | 'empty' | 'error' | 'ready' |
seed | number: the same seed draws the same numbers | 7 |
today | Date, the data's last day | Nov 16, 2026 |
defaultEditing | boolean: starts in edit mode | false |
site | string, in the subtitle | 'northwind.dev' |
Make it yours
Copy the screen and swap analyticsFor(range, seed, filters) for your own query: it returns AnalyticsData (days, totals, the previous period, funnel, pages, countries, cohorts, devices and channels), so each widget keeps working. ANALYTICS_WIDGETS lists the widgets the gallery offers and ANALYTICS_LAYOUT and ANALYTICS_LAYOUTS the starting arrangement; save what onLayoutChange gives you to keep each person's dashboard. lastDays(today, n) and previousRange(range) work out the ranges.
Built with
The free components, from patine-ui:
BottomSheet · Button · Calendar · DropdownMenu · Switch · Text
And from Patine Pro:
- Bar chart PRO
- Combo chart PRO
- Dashboard grid PRO
- Funnel chart PRO
- Patine Icons, the Pro set PRO
- Pie chart PRO
- Sparkline PRO
Files
analytics/
├── components/
│ ├── AnalyticsWidget.tsx
│ ├── KpiStrip.tsx
│ ├── Panels.tsx
│ └── Toolbar.tsx
├── hooks/
│ ├── useAnalytics.ts
│ └── useRealtime.ts
├── analytics.constants.ts
├── analytics.types.ts
├── analytics.utils.ts
├── AnalyticsDashboardScreen.tsx
└── index.ts
A look at the code
A range’s headline numbers and their change, from analytics.utils.ts:
/** A range's headline numbers: sums, and the rates weighted by sessions. */
export const totalsOf = (days: readonly DayMetrics[]): Totals => {
const sum = (pick: (d: DayMetrics) => number) => days.reduce((n, d) => n + pick(d), 0);
const sessions = sum((d) => d.sessions);
return {
visitors: sum((d) => d.visitors),
pageviews: sum((d) => d.pageviews),
bounceRate: sessions ? sum((d) => d.bounces) / sessions : 0,
avgSession: sessions ? sum((d) => d.sessionSeconds) / sessions : 0,
conversions: sum((d) => d.conversions),
revenue: Math.round(sum((d) => d.revenue)),
};
};
/** The change from `previous` as a ratio: 0.12 is +12%. Undefined without a previous value. */
export const change = (current: number, previous: number) => (previous ? (current - previous) / previous : undefined);