@oh-my-pi/omp-stats 16.0.4 → 16.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/build.ts +11 -0
- package/dist/client/index.css +1 -1
- package/dist/client/index.html +11 -0
- package/dist/client/index.js +108 -108
- package/dist/client/styles.css +1070 -631
- package/dist/types/client/api.d.ts +19 -10
- package/dist/types/client/app/AppLayout.d.ts +16 -0
- package/dist/types/client/app/NavRail.d.ts +7 -0
- package/dist/types/client/app/RangeControl.d.ts +7 -0
- package/dist/types/client/app/SyncButton.d.ts +14 -0
- package/dist/types/client/app/ThemeToggle.d.ts +1 -0
- package/dist/types/client/app/TopBar.d.ts +15 -0
- package/dist/types/client/app/routes.d.ts +12 -0
- package/dist/types/client/components/chart-shared.d.ts +26 -40
- package/dist/types/client/components/models-table-shared.d.ts +20 -40
- package/dist/types/client/data/charts.d.ts +1 -0
- package/dist/types/client/data/formatters.d.ts +7 -0
- package/dist/types/client/data/useHashRoute.d.ts +8 -0
- package/dist/types/client/data/useResource.d.ts +13 -0
- package/dist/types/client/data/view-models.d.ts +37 -0
- package/dist/types/client/index.d.ts +1 -0
- package/dist/types/client/routes/BehaviorRoute.d.ts +7 -0
- package/dist/types/client/routes/CostsRoute.d.ts +7 -0
- package/dist/types/client/routes/ErrorsRoute.d.ts +8 -0
- package/dist/types/client/routes/ModelsRoute.d.ts +7 -0
- package/dist/types/client/routes/OverviewRoute.d.ts +8 -0
- package/dist/types/client/routes/ProjectsRoute.d.ts +7 -0
- package/dist/types/client/routes/RequestsRoute.d.ts +8 -0
- package/dist/types/client/routes/index.d.ts +7 -0
- package/dist/types/client/ui/AsyncBoundary.d.ts +12 -0
- package/dist/types/client/ui/DataTable.d.ts +17 -0
- package/dist/types/client/ui/EmptyState.d.ts +7 -0
- package/dist/types/client/ui/ErrorState.d.ts +6 -0
- package/dist/types/client/ui/JsonBlock.d.ts +7 -0
- package/dist/types/client/ui/MetricCluster.d.ts +5 -0
- package/dist/types/client/ui/Panel.d.ts +7 -0
- package/dist/types/client/ui/RequestDrawer.d.ts +5 -0
- package/dist/types/client/ui/SegmentedControl.d.ts +12 -0
- package/dist/types/client/ui/Skeleton.d.ts +8 -0
- package/dist/types/client/ui/StatusPill.d.ts +7 -0
- package/dist/types/client/ui/index.d.ts +11 -0
- package/dist/types/client/useSystemTheme.d.ts +9 -0
- package/package.json +4 -4
- package/src/aggregator.ts +4 -3
- package/src/client/App.tsx +89 -207
- package/src/client/api.ts +55 -37
- package/src/client/app/AppLayout.tsx +93 -0
- package/src/client/app/NavRail.tsx +44 -0
- package/src/client/app/RangeControl.tsx +39 -0
- package/src/client/app/SyncButton.tsx +75 -0
- package/src/client/app/ThemeToggle.tsx +37 -0
- package/src/client/app/TopBar.tsx +73 -0
- package/src/client/app/routes.ts +50 -0
- package/src/client/components/chart-shared.tsx +28 -91
- package/src/client/components/models-table-shared.tsx +9 -29
- package/src/client/components/range-meta.ts +3 -2
- package/src/client/data/charts.ts +14 -0
- package/src/client/data/formatters.ts +38 -0
- package/src/client/data/useHashRoute.ts +85 -0
- package/src/client/data/useResource.ts +154 -0
- package/src/client/data/view-models.ts +178 -0
- package/src/client/index.tsx +4 -0
- package/src/client/routes/BehaviorRoute.tsx +623 -0
- package/src/client/routes/CostsRoute.tsx +234 -0
- package/src/client/routes/ErrorsRoute.tsx +118 -0
- package/src/client/routes/ModelsRoute.tsx +430 -0
- package/src/client/routes/OverviewRoute.tsx +332 -0
- package/src/client/routes/ProjectsRoute.tsx +163 -0
- package/src/client/routes/RequestsRoute.tsx +123 -0
- package/src/client/routes/index.ts +7 -0
- package/src/client/styles.css +1242 -225
- package/src/client/ui/AsyncBoundary.tsx +54 -0
- package/src/client/ui/DataTable.tsx +122 -0
- package/src/client/ui/EmptyState.tsx +16 -0
- package/src/client/ui/ErrorState.tsx +25 -0
- package/src/client/ui/JsonBlock.tsx +75 -0
- package/src/client/ui/MetricCluster.tsx +67 -0
- package/src/client/ui/Panel.tsx +24 -0
- package/src/client/ui/RequestDrawer.tsx +208 -0
- package/src/client/ui/SegmentedControl.tsx +36 -0
- package/src/client/ui/Skeleton.tsx +17 -0
- package/src/client/ui/StatusPill.tsx +15 -0
- package/src/client/ui/index.ts +11 -0
- package/src/client/useSystemTheme.ts +73 -17
- package/dist/types/client/components/BehaviorChart.d.ts +0 -6
- package/dist/types/client/components/BehaviorModelsTable.d.ts +0 -7
- package/dist/types/client/components/BehaviorSummary.d.ts +0 -7
- package/dist/types/client/components/ChartsContainer.d.ts +0 -7
- package/dist/types/client/components/CostChart.d.ts +0 -6
- package/dist/types/client/components/CostSummary.d.ts +0 -6
- package/dist/types/client/components/Header.d.ts +0 -12
- package/dist/types/client/components/ModelsTable.d.ts +0 -8
- package/dist/types/client/components/RequestDetail.d.ts +0 -6
- package/dist/types/client/components/RequestList.d.ts +0 -8
- package/dist/types/client/components/StatsGrid.d.ts +0 -6
- package/src/client/components/BehaviorChart.tsx +0 -189
- package/src/client/components/BehaviorModelsTable.tsx +0 -342
- package/src/client/components/BehaviorSummary.tsx +0 -95
- package/src/client/components/ChartsContainer.tsx +0 -221
- package/src/client/components/CostChart.tsx +0 -171
- package/src/client/components/CostSummary.tsx +0 -53
- package/src/client/components/Header.tsx +0 -72
- package/src/client/components/ModelsTable.tsx +0 -265
- package/src/client/components/RequestDetail.tsx +0 -172
- package/src/client/components/RequestList.tsx +0 -73
- package/src/client/components/StatsGrid.tsx +0 -135
|
@@ -1,31 +1,87 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
2
|
|
|
3
3
|
export type SystemTheme = "light" | "dark";
|
|
4
|
+
export type ThemePreference = "system" | "light" | "dark";
|
|
4
5
|
|
|
6
|
+
const STORAGE_KEY = "omp-stats-theme";
|
|
5
7
|
const DARK_SCHEME_QUERY = "(prefers-color-scheme: dark)";
|
|
6
8
|
|
|
7
|
-
function
|
|
8
|
-
if (typeof
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function readStoredPreference(): ThemePreference {
|
|
10
|
+
if (typeof localStorage === "undefined") return "system";
|
|
11
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
12
|
+
return stored === "light" || stored === "dark" || stored === "system" ? stored : "system";
|
|
13
|
+
}
|
|
11
14
|
|
|
15
|
+
function getSystemTheme(): SystemTheme {
|
|
16
|
+
if (typeof window === "undefined") return "dark";
|
|
12
17
|
return window.matchMedia(DARK_SCHEME_QUERY).matches ? "dark" : "light";
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
20
|
+
// Module-level store shared by the toggle (writer) and every chart (reader) so
|
|
21
|
+
// an explicit override and the system default resolve through one source.
|
|
22
|
+
let preference: ThemePreference = readStoredPreference();
|
|
23
|
+
let resolved: SystemTheme = preference === "system" ? getSystemTheme() : preference;
|
|
24
|
+
const listeners = new Set<() => void>();
|
|
25
|
+
|
|
26
|
+
function emit(): void {
|
|
27
|
+
for (const listener of listeners) listener();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function applyResolvedTheme(): void {
|
|
31
|
+
resolved = preference === "system" ? getSystemTheme() : preference;
|
|
32
|
+
if (typeof document !== "undefined") {
|
|
33
|
+
document.documentElement.dataset.theme = resolved;
|
|
34
|
+
document.documentElement.style.colorScheme = resolved;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (typeof window !== "undefined") {
|
|
39
|
+
applyResolvedTheme();
|
|
40
|
+
window.matchMedia(DARK_SCHEME_QUERY).addEventListener("change", () => {
|
|
41
|
+
// System changes only move the needle while following the system.
|
|
42
|
+
if (preference === "system") {
|
|
43
|
+
applyResolvedTheme();
|
|
44
|
+
emit();
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
17
48
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
49
|
+
export function setThemePreference(next: ThemePreference): void {
|
|
50
|
+
preference = next;
|
|
51
|
+
if (typeof localStorage !== "undefined") localStorage.setItem(STORAGE_KEY, next);
|
|
52
|
+
applyResolvedTheme();
|
|
53
|
+
emit();
|
|
54
|
+
}
|
|
23
55
|
|
|
24
|
-
|
|
56
|
+
function subscribe(callback: () => void): () => void {
|
|
57
|
+
listeners.add(callback);
|
|
58
|
+
return () => listeners.delete(callback);
|
|
59
|
+
}
|
|
25
60
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
61
|
+
/** Reader for the active resolved theme. Reflects system default and overrides. */
|
|
62
|
+
export function useSystemTheme(): SystemTheme {
|
|
63
|
+
return useSyncExternalStore(
|
|
64
|
+
subscribe,
|
|
65
|
+
() => resolved,
|
|
66
|
+
() => "dark" as SystemTheme,
|
|
67
|
+
);
|
|
68
|
+
}
|
|
29
69
|
|
|
30
|
-
|
|
70
|
+
/** Reader + writer for the theme preference (powers the toggle). */
|
|
71
|
+
export function useThemePreference(): {
|
|
72
|
+
preference: ThemePreference;
|
|
73
|
+
resolved: SystemTheme;
|
|
74
|
+
setPreference: (next: ThemePreference) => void;
|
|
75
|
+
} {
|
|
76
|
+
const pref = useSyncExternalStore(
|
|
77
|
+
subscribe,
|
|
78
|
+
() => preference,
|
|
79
|
+
() => "system" as ThemePreference,
|
|
80
|
+
);
|
|
81
|
+
const res = useSyncExternalStore(
|
|
82
|
+
subscribe,
|
|
83
|
+
() => resolved,
|
|
84
|
+
() => "dark" as SystemTheme,
|
|
85
|
+
);
|
|
86
|
+
return { preference: pref, resolved: res, setPreference: setThemePreference };
|
|
31
87
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BehaviorModelStats, BehaviorTimeSeriesPoint } from "../types";
|
|
2
|
-
interface BehaviorModelsTableProps {
|
|
3
|
-
models: BehaviorModelStats[];
|
|
4
|
-
behaviorSeries: BehaviorTimeSeriesPoint[];
|
|
5
|
-
}
|
|
6
|
-
export declare function BehaviorModelsTable({ models, behaviorSeries }: BehaviorModelsTableProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { BehaviorOverallStats, BehaviorTimeSeriesPoint } from "../types";
|
|
2
|
-
interface BehaviorSummaryProps {
|
|
3
|
-
overall: BehaviorOverallStats;
|
|
4
|
-
behaviorSeries: BehaviorTimeSeriesPoint[];
|
|
5
|
-
}
|
|
6
|
-
export declare function BehaviorSummary({ overall, behaviorSeries }: BehaviorSummaryProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { ModelTimeSeriesPoint, TimeRange } from "../types";
|
|
2
|
-
interface ChartsContainerProps {
|
|
3
|
-
modelSeries: ModelTimeSeriesPoint[];
|
|
4
|
-
timeRange: TimeRange;
|
|
5
|
-
}
|
|
6
|
-
export declare function ChartsContainer({ modelSeries, timeRange }: ChartsContainerProps): import("react").JSX.Element;
|
|
7
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { TimeRange } from "../types";
|
|
2
|
-
type Tab = "overview" | "requests" | "errors" | "models" | "costs" | "behavior";
|
|
3
|
-
interface HeaderProps {
|
|
4
|
-
activeTab: Tab;
|
|
5
|
-
onTabChange: (tab: Tab) => void;
|
|
6
|
-
onSync: () => void;
|
|
7
|
-
syncing: boolean;
|
|
8
|
-
timeRange: TimeRange;
|
|
9
|
-
onTimeRangeChange: (timeRange: TimeRange) => void;
|
|
10
|
-
}
|
|
11
|
-
export declare function Header({ activeTab, onTabChange, onSync, syncing, timeRange, onTimeRangeChange }: HeaderProps): import("react").JSX.Element;
|
|
12
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { ModelPerformancePoint, ModelStats, TimeRange } from "../types";
|
|
2
|
-
interface ModelsTableProps {
|
|
3
|
-
models: ModelStats[];
|
|
4
|
-
performanceSeries: ModelPerformancePoint[];
|
|
5
|
-
timeRange: TimeRange;
|
|
6
|
-
}
|
|
7
|
-
export declare function ModelsTable({ models, performanceSeries, timeRange }: ModelsTableProps): import("react").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { MessageStats } from "../types";
|
|
2
|
-
interface RequestListProps {
|
|
3
|
-
requests: MessageStats[];
|
|
4
|
-
onSelect: (req: MessageStats) => void;
|
|
5
|
-
title: string;
|
|
6
|
-
}
|
|
7
|
-
export declare function RequestList({ requests, onSelect, title }: RequestListProps): import("react").JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BarElement,
|
|
3
|
-
CategoryScale,
|
|
4
|
-
Chart as ChartJS,
|
|
5
|
-
type ChartOptions,
|
|
6
|
-
Filler,
|
|
7
|
-
Legend,
|
|
8
|
-
LinearScale,
|
|
9
|
-
LineElement,
|
|
10
|
-
PointElement,
|
|
11
|
-
Title,
|
|
12
|
-
Tooltip,
|
|
13
|
-
} from "chart.js";
|
|
14
|
-
import { useMemo, useState } from "react";
|
|
15
|
-
import { Bar, Line } from "react-chartjs-2";
|
|
16
|
-
import type { BehaviorTimeSeriesPoint } from "../types";
|
|
17
|
-
import { useSystemTheme } from "../useSystemTheme";
|
|
18
|
-
import {
|
|
19
|
-
barDatasetStyle,
|
|
20
|
-
buildAggregateTimeSeries,
|
|
21
|
-
buildSharedPlugins,
|
|
22
|
-
buildSharedScales,
|
|
23
|
-
buildTopNByModelSeries,
|
|
24
|
-
CHART_THEMES,
|
|
25
|
-
ChartFrame,
|
|
26
|
-
type ChartSeries,
|
|
27
|
-
lineDatasetStyle,
|
|
28
|
-
MODEL_COLORS,
|
|
29
|
-
styleDatasets,
|
|
30
|
-
} from "./chart-shared";
|
|
31
|
-
|
|
32
|
-
ChartJS.register(CategoryScale, LinearScale, BarElement, LineElement, PointElement, Title, Tooltip, Legend, Filler);
|
|
33
|
-
|
|
34
|
-
const METRIC_OPTIONS = [
|
|
35
|
-
{ value: "yelling", label: "Yelling" },
|
|
36
|
-
{ value: "profanity", label: "Profanity" },
|
|
37
|
-
{ value: "anguish", label: "Anguish (!!!, nooo, dude, ..)" },
|
|
38
|
-
{ value: "negation", label: "Negation (no/nope/wrong)" },
|
|
39
|
-
{ value: "repetition", label: "Repetition (i meant, still doesnt)" },
|
|
40
|
-
{ value: "blame", label: "Blame (you didnt, stop X-ing)" },
|
|
41
|
-
{ value: "frustration", label: "Frustration (neg + rep + blame)" },
|
|
42
|
-
{ value: "total", label: "All signals combined" },
|
|
43
|
-
] as const;
|
|
44
|
-
type Metric = (typeof METRIC_OPTIONS)[number]["value"];
|
|
45
|
-
|
|
46
|
-
function formatRateAxis(value: number): string {
|
|
47
|
-
if (!Number.isFinite(value)) return "-";
|
|
48
|
-
if (value === 0) return "0%";
|
|
49
|
-
if (Math.abs(value) < 1) return `${value.toFixed(1)}%`;
|
|
50
|
-
return `${value.toFixed(0)}%`;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
interface BehaviorChartProps {
|
|
54
|
-
behaviorSeries: BehaviorTimeSeriesPoint[];
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function pointHits(point: BehaviorTimeSeriesPoint, metric: Metric): number {
|
|
58
|
-
if (metric === "frustration") return point.negation + point.repetition + point.blame;
|
|
59
|
-
if (metric === "total") {
|
|
60
|
-
return point.yelling + point.profanity + point.anguish + point.negation + point.repetition + point.blame;
|
|
61
|
-
}
|
|
62
|
-
return point[metric];
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** Hits per 100 user messages, 0 when there were no messages. */
|
|
66
|
-
function ratePercent(hits: number, messages: number): number {
|
|
67
|
-
if (messages <= 0) return 0;
|
|
68
|
-
return (hits / messages) * 100;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface DailyBucket {
|
|
72
|
-
hits: number;
|
|
73
|
-
messages: number;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function buildAggregateSeries(points: BehaviorTimeSeriesPoint[], metric: Metric): ChartSeries {
|
|
77
|
-
const label = METRIC_OPTIONS.find(m => m.value === metric)?.label ?? "Hits";
|
|
78
|
-
return buildAggregateTimeSeries<BehaviorTimeSeriesPoint, DailyBucket>(points, label, {
|
|
79
|
-
initBucket: () => ({ hits: 0, messages: 0 }),
|
|
80
|
-
accumulate: (bucket, point) => {
|
|
81
|
-
bucket.hits += pointHits(point, metric);
|
|
82
|
-
bucket.messages += point.messages;
|
|
83
|
-
},
|
|
84
|
-
bucketToValue: bucket => ratePercent(bucket.hits, bucket.messages),
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
function buildByModelSeries(points: BehaviorTimeSeriesPoint[], metric: Metric): ChartSeries {
|
|
89
|
-
// Rank by message volume so the models you actually use surface first,
|
|
90
|
-
// matching the Behavior-by-Model table. Per-bucket math tracks hits +
|
|
91
|
-
// messages separately so the final rate isn't skewed by low-volume days.
|
|
92
|
-
return buildTopNByModelSeries<BehaviorTimeSeriesPoint, DailyBucket>(points, {
|
|
93
|
-
rankWeight: point => point.messages,
|
|
94
|
-
initBucket: () => ({ hits: 0, messages: 0 }),
|
|
95
|
-
accumulate: (bucket, point) => {
|
|
96
|
-
bucket.hits += pointHits(point, metric);
|
|
97
|
-
bucket.messages += point.messages;
|
|
98
|
-
},
|
|
99
|
-
bucketToValue: bucket => ratePercent(bucket.hits, bucket.messages),
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function BehaviorChart({ behaviorSeries }: BehaviorChartProps) {
|
|
104
|
-
const [byModel, setByModel] = useState(false);
|
|
105
|
-
const [metric, setMetric] = useState<Metric>("total");
|
|
106
|
-
const theme = useSystemTheme();
|
|
107
|
-
const chartTheme = CHART_THEMES[theme];
|
|
108
|
-
|
|
109
|
-
const chartData = useMemo(
|
|
110
|
-
() => (byModel ? buildByModelSeries(behaviorSeries, metric) : buildAggregateSeries(behaviorSeries, metric)),
|
|
111
|
-
[behaviorSeries, byModel, metric],
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const sharedPlugins = buildSharedPlugins({
|
|
115
|
-
chartTheme,
|
|
116
|
-
showLegend: byModel,
|
|
117
|
-
defaultLabel: "Hits",
|
|
118
|
-
formatValue: formatRateAxis,
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
const { sharedScaleBase, yScale } = buildSharedScales({ chartTheme, formatY: formatRateAxis });
|
|
122
|
-
|
|
123
|
-
const metricLabel = METRIC_OPTIONS.find(m => m.value === metric)?.label ?? "";
|
|
124
|
-
const metricTabs = (
|
|
125
|
-
<div className="flex bg-[var(--bg-surface)] rounded-[var(--radius-sm)] p-0.5 border border-[var(--border-subtle)]">
|
|
126
|
-
{METRIC_OPTIONS.map(opt => (
|
|
127
|
-
<button
|
|
128
|
-
key={opt.value}
|
|
129
|
-
type="button"
|
|
130
|
-
onClick={() => setMetric(opt.value)}
|
|
131
|
-
className={`tab-btn text-xs ${metric === opt.value ? "active" : ""}`}
|
|
132
|
-
>
|
|
133
|
-
{opt.label}
|
|
134
|
-
</button>
|
|
135
|
-
))}
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
let chartNode: React.ReactNode;
|
|
140
|
-
if (byModel) {
|
|
141
|
-
const lineData = {
|
|
142
|
-
labels: chartData.labels,
|
|
143
|
-
datasets: styleDatasets(chartData, i => lineDatasetStyle(MODEL_COLORS[i % MODEL_COLORS.length])),
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
const lineOptions: ChartOptions<"line"> = {
|
|
147
|
-
responsive: true,
|
|
148
|
-
maintainAspectRatio: false,
|
|
149
|
-
interaction: { mode: "index", intersect: false },
|
|
150
|
-
plugins: sharedPlugins,
|
|
151
|
-
scales: { x: sharedScaleBase, y: yScale },
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
chartNode = <Line data={lineData} options={lineOptions} />;
|
|
155
|
-
} else {
|
|
156
|
-
const barData = {
|
|
157
|
-
labels: chartData.labels,
|
|
158
|
-
datasets: styleDatasets(chartData, i => barDatasetStyle(MODEL_COLORS[i % MODEL_COLORS.length])),
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
const barOptions: ChartOptions<"bar"> = {
|
|
162
|
-
responsive: true,
|
|
163
|
-
maintainAspectRatio: false,
|
|
164
|
-
interaction: { mode: "index", intersect: false },
|
|
165
|
-
plugins: sharedPlugins,
|
|
166
|
-
scales: {
|
|
167
|
-
x: { ...sharedScaleBase, stacked: true },
|
|
168
|
-
y: { ...yScale, stacked: true },
|
|
169
|
-
},
|
|
170
|
-
layout: { padding: { top: 8 } },
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
chartNode = <Bar data={barData} options={barOptions} />;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return (
|
|
177
|
-
<ChartFrame
|
|
178
|
-
title="User Tantrums"
|
|
179
|
-
subtitle={`${metricLabel} as % of user messages per day`}
|
|
180
|
-
empty={chartData.labels.length === 0}
|
|
181
|
-
emptyMessage="No behavioral data yet. Sync to scan your sessions."
|
|
182
|
-
controls={metricTabs}
|
|
183
|
-
byModel={byModel}
|
|
184
|
-
onByModelChange={setByModel}
|
|
185
|
-
>
|
|
186
|
-
{chartNode}
|
|
187
|
-
</ChartFrame>
|
|
188
|
-
);
|
|
189
|
-
}
|