@altertable/data-app-examples 0.76.0 → 0.78.0
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/package.json +1 -1
- package/templates/starter-data-app/index.tsx +686 -136
- package/templates/starter-finding-data-app/index.tsx +530 -188
- package/templates/starter-local-data-app/AGENTS.md +9 -9
- package/templates/starter-local-data-app/README.md +14 -5
- package/templates/starter-local-data-app/app.ts +256 -21
- package/templates/starter-local-data-app/package.json +5 -5
- package/templates/starter-local-data-app/src/App.tsx +276 -5
- package/templates/starter-local-data-app/src/data-context.ts +28 -14
- package/templates/starter-local-data-app/src/filters.ts +35 -0
- package/templates/starter-local-data-app/src/main.tsx +3 -3
- package/templates/starter-local-data-app/src/operations.ts +129 -4
- package/templates/starter-local-data-app/src/server.ts +1 -2
- package/templates/starter-local-finding-data-app/AGENTS.md +9 -9
- package/templates/starter-local-finding-data-app/README.md +3 -4
- package/templates/starter-local-finding-data-app/app.ts +63 -34
- package/templates/starter-local-finding-data-app/package.json +5 -5
- package/templates/starter-local-finding-data-app/src/App.tsx +308 -126
- package/templates/starter-local-finding-data-app/src/data-context.ts +19 -4
- package/templates/starter-local-finding-data-app/src/filters.ts +66 -0
- package/templates/starter-local-finding-data-app/src/main.tsx +3 -3
- package/templates/starter-local-finding-data-app/src/operations.ts +101 -37
- package/templates/starter-local-finding-data-app/src/server.ts +4 -2
- package/templates/starter-local-metric-data-app/AGENTS.md +9 -9
- package/templates/starter-local-metric-data-app/README.md +3 -4
- package/templates/starter-local-metric-data-app/app.ts +5 -2
- package/templates/starter-local-metric-data-app/package.json +5 -5
- package/templates/starter-local-metric-data-app/src/App.tsx +69 -71
- package/templates/starter-local-metric-data-app/src/data-context.ts +9 -5
- package/templates/starter-local-metric-data-app/src/filters.ts +18 -0
- package/templates/starter-local-metric-data-app/src/main.tsx +3 -3
- package/templates/starter-local-metric-data-app/src/operations.ts +34 -41
- package/templates/starter-local-metric-data-app/src/server.ts +4 -2
- package/templates/starter-metric-data-app/index.tsx +125 -122
|
@@ -1,108 +1,150 @@
|
|
|
1
1
|
import {
|
|
2
|
-
choiceVariable,
|
|
3
2
|
createDataHooks,
|
|
4
3
|
DataApp,
|
|
5
4
|
DataSection,
|
|
6
|
-
|
|
5
|
+
Button,
|
|
6
|
+
Grid,
|
|
7
|
+
GridItem,
|
|
8
|
+
Notice,
|
|
7
9
|
Stack,
|
|
8
10
|
TableWidget,
|
|
9
11
|
VisualizationWidget,
|
|
12
|
+
Ranking,
|
|
13
|
+
Comparison,
|
|
10
14
|
} from '@altertable/data-app-react';
|
|
11
|
-
import {
|
|
12
|
-
|
|
15
|
+
import {
|
|
16
|
+
Tabs,
|
|
17
|
+
TabList,
|
|
18
|
+
Tab,
|
|
19
|
+
TabPanels,
|
|
20
|
+
TabPanel,
|
|
21
|
+
useViewTab,
|
|
22
|
+
ComposedChart,
|
|
23
|
+
useAppFilters,
|
|
24
|
+
} from '@altertable/data-app-react/ui';
|
|
25
|
+
import {
|
|
26
|
+
formatCount,
|
|
27
|
+
formatNumber,
|
|
28
|
+
formatPercent,
|
|
29
|
+
} from '@altertable/data-app/format';
|
|
13
30
|
|
|
14
31
|
import { sampleDataContext } from '#app/data-context.ts';
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
32
|
+
import {
|
|
33
|
+
findingPeriodLabel,
|
|
34
|
+
periodLabel,
|
|
35
|
+
periodFilter,
|
|
36
|
+
groupName,
|
|
37
|
+
grain,
|
|
38
|
+
breakdown,
|
|
39
|
+
} from '#app/filters.ts';
|
|
40
|
+
import { operations } from '#app/operations.ts';
|
|
41
|
+
const { defineView } = createDataHooks(operations.createDataClient());
|
|
42
|
+
const count = { kind: 'count' } as const;
|
|
43
|
+
const emptyFallback = {
|
|
44
|
+
title: 'No samples in this period',
|
|
45
|
+
description: 'No observations are available for this period.',
|
|
46
|
+
};
|
|
47
|
+
const totalsView = defineView({
|
|
20
48
|
dataContext: sampleDataContext,
|
|
21
|
-
operation: '
|
|
22
|
-
time: period,
|
|
23
|
-
variables: {
|
|
24
|
-
grain: choiceVariable({
|
|
25
|
-
key: 'grain',
|
|
26
|
-
label: 'Grain',
|
|
27
|
-
defaultValue: 'day',
|
|
28
|
-
options: [
|
|
29
|
-
{ id: 'day', label: 'Day' },
|
|
30
|
-
{ id: 'week', label: 'Week' },
|
|
31
|
-
],
|
|
32
|
-
presentation: { group: 'display', control: 'widget' },
|
|
33
|
-
}),
|
|
34
|
-
breakdown: choiceVariable({
|
|
35
|
-
key: 'breakdown',
|
|
36
|
-
label: 'Breakdown',
|
|
37
|
-
defaultValue: 'segment',
|
|
38
|
-
options: [
|
|
39
|
-
{ id: 'segment', label: 'Segment' },
|
|
40
|
-
{ id: 'group', label: 'Group' },
|
|
41
|
-
],
|
|
42
|
-
presentation: { group: 'display', control: 'widget' },
|
|
43
|
-
}),
|
|
44
|
-
},
|
|
49
|
+
operation: 'sampleTotals',
|
|
45
50
|
isEmpty: rows => rows.length === 0,
|
|
46
|
-
emptyFallback
|
|
47
|
-
title: 'No samples in this period',
|
|
48
|
-
description: 'No observations are available for this period.',
|
|
49
|
-
},
|
|
51
|
+
emptyFallback,
|
|
50
52
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
id: 'total-samples',
|
|
68
|
-
label: 'Samples',
|
|
69
|
-
glossaryId: 'sampleCount',
|
|
70
|
-
format: count,
|
|
53
|
+
const totals = totalsView.dataset({
|
|
54
|
+
name: 'Period totals',
|
|
55
|
+
select: rows => rows,
|
|
56
|
+
rowKey: () => 'total',
|
|
57
|
+
columns: {
|
|
58
|
+
currentCount: {
|
|
59
|
+
label: 'Selected period',
|
|
60
|
+
value: row => row.currentCount,
|
|
61
|
+
format: count,
|
|
62
|
+
},
|
|
63
|
+
previousCount: {
|
|
64
|
+
label: 'Previous period',
|
|
65
|
+
value: row => row.previousCount,
|
|
66
|
+
format: count,
|
|
67
|
+
},
|
|
71
68
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
evidence: { id: 'period-totals', glossaryIds: ['sampleCount'] },
|
|
70
|
+
});
|
|
71
|
+
const trendView = defineView({
|
|
72
|
+
dataContext: sampleDataContext,
|
|
73
|
+
operation: 'samplesOverTime',
|
|
74
|
+
isEmpty: rows => rows.length === 0,
|
|
75
|
+
emptyFallback,
|
|
76
|
+
});
|
|
77
|
+
const trend = trendView.dataset({
|
|
80
78
|
name: 'Samples over time',
|
|
81
|
-
select: rows =>
|
|
82
|
-
rowKey: row => row.
|
|
79
|
+
select: rows => rows,
|
|
80
|
+
rowKey: row => row.periodStart,
|
|
83
81
|
columns: {
|
|
84
|
-
|
|
82
|
+
periodStart: { label: 'Period start', value: row => row.periodStart },
|
|
85
83
|
sampleCount: { value: row => row.sampleCount, format: count },
|
|
86
84
|
},
|
|
87
85
|
evidence: { id: 'samples-over-time', glossaryIds: ['sampleCount'] },
|
|
88
86
|
});
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
87
|
+
const memberView = defineView({
|
|
88
|
+
dataContext: sampleDataContext,
|
|
89
|
+
operation: 'samplesByMember',
|
|
90
|
+
isEmpty: rows => rows.length === 0,
|
|
91
|
+
emptyFallback,
|
|
92
|
+
});
|
|
93
|
+
const byMember = memberView.dataset({
|
|
94
|
+
name: 'Member comparison',
|
|
95
|
+
select: rows => rows,
|
|
96
|
+
rowKey: row => row.member,
|
|
97
97
|
columns: {
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
member: { label: 'Member', value: row => row.member },
|
|
99
|
+
currentCount: {
|
|
100
|
+
label: 'Selected period',
|
|
101
|
+
value: row => row.currentCount,
|
|
102
|
+
format: count,
|
|
103
|
+
},
|
|
104
|
+
previousCount: {
|
|
105
|
+
label: 'Previous period',
|
|
106
|
+
value: row => row.previousCount,
|
|
107
|
+
format: count,
|
|
108
|
+
},
|
|
109
|
+
change: {
|
|
110
|
+
label: 'Change',
|
|
111
|
+
value: row => row.change,
|
|
112
|
+
format: row => formatNumber(row.change, { signDisplay: 'exceptZero' }),
|
|
113
|
+
},
|
|
114
|
+
changeRate: {
|
|
115
|
+
label: 'Change %',
|
|
116
|
+
value: row => row.changeRate,
|
|
117
|
+
format: row => formatPercent(row.changeRate),
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
evidence: {
|
|
121
|
+
id: 'samples-by-member',
|
|
122
|
+
glossaryIds: ['sampleCount', 'sampleChange'],
|
|
100
123
|
},
|
|
101
|
-
evidence: { id: 'samples-by-member', glossaryIds: ['sampleCount'] },
|
|
102
124
|
});
|
|
103
|
-
const
|
|
125
|
+
const selectedMembers = memberView.dataset({
|
|
126
|
+
name: 'Selected-period samples',
|
|
127
|
+
select: rows => rows,
|
|
128
|
+
rowKey: row => row.member,
|
|
129
|
+
columns: {
|
|
130
|
+
member: { label: 'Member', value: row => row.member },
|
|
131
|
+
currentCount: {
|
|
132
|
+
label: 'Samples',
|
|
133
|
+
value: row => row.currentCount,
|
|
134
|
+
format: count,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
evidence: { id: 'selected-members', glossaryIds: ['sampleCount'] },
|
|
138
|
+
});
|
|
139
|
+
const rowsView = defineView({
|
|
140
|
+
dataContext: sampleDataContext,
|
|
141
|
+
operation: 'sampleRows',
|
|
142
|
+
isEmpty: rows => rows.length === 0,
|
|
143
|
+
emptyFallback,
|
|
144
|
+
});
|
|
145
|
+
const sampleRows = rowsView.dataset({
|
|
104
146
|
name: 'Samples',
|
|
105
|
-
select: rows => rows
|
|
147
|
+
select: rows => rows,
|
|
106
148
|
rowKey: row => `${row.periodStart}:${row.member}`,
|
|
107
149
|
columns: {
|
|
108
150
|
periodStart: { label: 'Period start', value: row => row.periodStart },
|
|
@@ -111,55 +153,195 @@ const sampleRows = samplesView.dataset({
|
|
|
111
153
|
},
|
|
112
154
|
evidence: { id: 'samples', glossaryIds: ['sampleCount'] },
|
|
113
155
|
});
|
|
114
|
-
//
|
|
115
|
-
const
|
|
116
|
-
<
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
value: row.sampleCount,
|
|
152
|
-
}))}
|
|
156
|
+
// Compare current and previous periods from the same displayed result.
|
|
157
|
+
const totalsContent = totalsView.content(result => (
|
|
158
|
+
<VisualizationWidget
|
|
159
|
+
dataset={totals}
|
|
160
|
+
source={result}
|
|
161
|
+
title={
|
|
162
|
+
result.loading || result.input.period.comparison
|
|
163
|
+
? 'Period comparison'
|
|
164
|
+
: 'Selected period'
|
|
165
|
+
}
|
|
166
|
+
>
|
|
167
|
+
{rows =>
|
|
168
|
+
result.loading ? null : result.input.period.comparison ? (
|
|
169
|
+
<Comparison
|
|
170
|
+
label="Samples"
|
|
171
|
+
current={{
|
|
172
|
+
value: rows[0]!.currentCount,
|
|
173
|
+
formattedValue: formatCount(rows[0]!.currentCount),
|
|
174
|
+
periodLabel: periodLabel(result.input.period.range),
|
|
175
|
+
}}
|
|
176
|
+
previous={{
|
|
177
|
+
value: rows[0]!.previousCount,
|
|
178
|
+
formattedValue: formatCount(rows[0]!.previousCount, {
|
|
179
|
+
missing: 'Not available',
|
|
180
|
+
}),
|
|
181
|
+
periodLabel: periodLabel(result.input.period.comparison),
|
|
182
|
+
}}
|
|
183
|
+
/>
|
|
184
|
+
) : (
|
|
185
|
+
<Ranking
|
|
186
|
+
items={[
|
|
187
|
+
{
|
|
188
|
+
id: 'selected',
|
|
189
|
+
label: periodLabel(result.input.period.range),
|
|
190
|
+
value: rows[0]!.currentCount,
|
|
191
|
+
},
|
|
192
|
+
]}
|
|
153
193
|
/>
|
|
154
|
-
)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
194
|
+
)
|
|
195
|
+
}
|
|
196
|
+
</VisualizationWidget>
|
|
197
|
+
));
|
|
198
|
+
const trendContent = trendView.content(result => (
|
|
199
|
+
<VisualizationWidget
|
|
200
|
+
dataset={trend}
|
|
201
|
+
source={result}
|
|
202
|
+
title="Samples over time"
|
|
203
|
+
breakdown={trendView.breakdown('grain')}
|
|
204
|
+
>
|
|
205
|
+
{rows => (
|
|
206
|
+
<ComposedChart
|
|
207
|
+
ariaLabel="Samples over time"
|
|
208
|
+
data={rows}
|
|
209
|
+
valueFormat={count}
|
|
210
|
+
>
|
|
211
|
+
<ComposedChart.XAxis dataKey="periodStart" />
|
|
212
|
+
<ComposedChart.YAxis />
|
|
213
|
+
<ComposedChart.Line dataKey="sampleCount" name="Samples" />
|
|
214
|
+
<ComposedChart.Tooltip />
|
|
215
|
+
</ComposedChart>
|
|
216
|
+
)}
|
|
217
|
+
</VisualizationWidget>
|
|
218
|
+
));
|
|
219
|
+
const memberContent = memberView.content(result => (
|
|
220
|
+
<VisualizationWidget
|
|
221
|
+
dataset={byMember}
|
|
222
|
+
source={result}
|
|
223
|
+
title={
|
|
224
|
+
result.loading || result.input.period.comparison
|
|
225
|
+
? 'Where volume changed'
|
|
226
|
+
: 'Samples by member'
|
|
227
|
+
}
|
|
228
|
+
breakdown={memberView.breakdown('breakdown')}
|
|
229
|
+
>
|
|
230
|
+
{rows => (
|
|
231
|
+
<ComposedChart
|
|
232
|
+
ariaLabel="Samples by member"
|
|
233
|
+
data={rows}
|
|
234
|
+
valueFormat={count}
|
|
235
|
+
>
|
|
236
|
+
<ComposedChart.XAxis dataKey="member" />
|
|
237
|
+
<ComposedChart.YAxis />
|
|
238
|
+
{!result.loading && result.input.period.comparison && (
|
|
239
|
+
<ComposedChart.Bar
|
|
240
|
+
dataKey="previousCount"
|
|
241
|
+
name="Previous period"
|
|
242
|
+
fill="var(--atbl-muted)"
|
|
243
|
+
fillOpacity={0.45}
|
|
244
|
+
/>
|
|
245
|
+
)}
|
|
246
|
+
<ComposedChart.Bar dataKey="currentCount" name="Selected period" />
|
|
247
|
+
<ComposedChart.Tooltip />
|
|
248
|
+
<ComposedChart.Legend />
|
|
249
|
+
</ComposedChart>
|
|
250
|
+
)}
|
|
251
|
+
</VisualizationWidget>
|
|
252
|
+
));
|
|
253
|
+
const memberTableContent = memberView.content(result => (
|
|
254
|
+
<TableWidget
|
|
255
|
+
dataset={
|
|
256
|
+
result.loading || result.input.period.comparison
|
|
257
|
+
? byMember
|
|
258
|
+
: selectedMembers
|
|
259
|
+
}
|
|
260
|
+
source={result}
|
|
261
|
+
title={
|
|
262
|
+
result.loading || result.input.period.comparison
|
|
263
|
+
? 'Change by member'
|
|
264
|
+
: 'Samples by member'
|
|
265
|
+
}
|
|
266
|
+
/>
|
|
158
267
|
));
|
|
268
|
+
const rowsContent = rowsView.content(result => (
|
|
269
|
+
<TableWidget dataset={sampleRows} source={result} title="Sample details" />
|
|
270
|
+
));
|
|
271
|
+
// Show this notice when scope or display choices differ from the original finding.
|
|
272
|
+
// Back to finding restores both scope filters and display choices to their defaults.
|
|
273
|
+
function FindingScope() {
|
|
274
|
+
const filters = useAppFilters({
|
|
275
|
+
period: periodFilter,
|
|
276
|
+
groupName,
|
|
277
|
+
grain,
|
|
278
|
+
breakdown,
|
|
279
|
+
});
|
|
280
|
+
const scopeChanged =
|
|
281
|
+
!periodFilter.same(filters.values.period, periodFilter.defaultValue) ||
|
|
282
|
+
!groupName.same(filters.values.groupName, groupName.defaultValue);
|
|
283
|
+
const displayChanged =
|
|
284
|
+
!grain.same(filters.values.grain, grain.defaultValue) ||
|
|
285
|
+
!breakdown.same(filters.values.breakdown, breakdown.defaultValue);
|
|
286
|
+
if (!scopeChanged && !displayChanged) return null;
|
|
287
|
+
return (
|
|
288
|
+
<Notice
|
|
289
|
+
title={
|
|
290
|
+
scopeChanged
|
|
291
|
+
? 'Exploring a different scope'
|
|
292
|
+
: 'Viewing a different breakdown'
|
|
293
|
+
}
|
|
294
|
+
description={
|
|
295
|
+
<>
|
|
296
|
+
Original finding · {findingPeriodLabel} {periodFilter.policy.timeZone}{' '}
|
|
297
|
+
vs previous period ·{' '}
|
|
298
|
+
{groupName.describe?.(groupName.defaultValue) ??
|
|
299
|
+
groupName.defaultValue}
|
|
300
|
+
</>
|
|
301
|
+
}
|
|
302
|
+
action={
|
|
303
|
+
<Button size="compact" onClick={() => filters.resetAll()}>
|
|
304
|
+
Back to finding
|
|
305
|
+
</Button>
|
|
306
|
+
}
|
|
307
|
+
/>
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
const views = ['overview', 'data'] as const;
|
|
159
311
|
export function App() {
|
|
312
|
+
const [view, setView] = useViewTab(views, 'overview');
|
|
160
313
|
return (
|
|
161
|
-
<DataApp view={
|
|
162
|
-
<
|
|
314
|
+
<DataApp view={trendView} showToolbar={false}>
|
|
315
|
+
<Stack>
|
|
316
|
+
<FindingScope />
|
|
317
|
+
<Tabs selectedKey={view} onSelectionChange={setView}>
|
|
318
|
+
<TabList aria-label="Finding views">
|
|
319
|
+
<Tab id="overview">Overview</Tab>
|
|
320
|
+
<Tab id="data">Data</Tab>
|
|
321
|
+
</TabList>
|
|
322
|
+
<TabPanels>
|
|
323
|
+
<TabPanel id="overview">
|
|
324
|
+
<Stack>
|
|
325
|
+
<Grid columns={3}>
|
|
326
|
+
<GridItem span={2}>
|
|
327
|
+
<DataSection content={trendContent} />
|
|
328
|
+
</GridItem>
|
|
329
|
+
<GridItem>
|
|
330
|
+
<DataSection content={totalsContent} />
|
|
331
|
+
</GridItem>
|
|
332
|
+
</Grid>
|
|
333
|
+
<DataSection content={memberContent} />
|
|
334
|
+
</Stack>
|
|
335
|
+
</TabPanel>
|
|
336
|
+
<TabPanel id="data">
|
|
337
|
+
<Stack>
|
|
338
|
+
<DataSection content={memberTableContent} />
|
|
339
|
+
<DataSection content={rowsContent} />
|
|
340
|
+
</Stack>
|
|
341
|
+
</TabPanel>
|
|
342
|
+
</TabPanels>
|
|
343
|
+
</Tabs>
|
|
344
|
+
</Stack>
|
|
163
345
|
</DataApp>
|
|
164
346
|
);
|
|
165
347
|
}
|
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import { createDataContext } from '@altertable/data-app-react';
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
import { operations } from '#app/operations.ts';
|
|
4
|
+
|
|
5
|
+
const queryNames = {
|
|
6
|
+
...operations.sampleTotals.queryNames,
|
|
7
|
+
...operations.samplesOverTime.queryNames,
|
|
8
|
+
...operations.samplesByMember.queryNames,
|
|
9
|
+
...operations.sampleRows.queryNames,
|
|
10
|
+
};
|
|
3
11
|
export const sampleDataContext = createDataContext(queryNames)({
|
|
4
12
|
description:
|
|
5
|
-
'Fictional daily
|
|
13
|
+
'Fictional daily sample counts by group and segment. Comparisons use equal-length periods in UTC.',
|
|
6
14
|
glossary: {
|
|
15
|
+
sampleChange: {
|
|
16
|
+
term: 'Sample change',
|
|
17
|
+
definition:
|
|
18
|
+
'Selected-period samples minus the previous equal-length period in the same scope. Missing observations remain unavailable; they are not measured zeroes.',
|
|
19
|
+
queryNames: ['samplesByMember'],
|
|
20
|
+
},
|
|
7
21
|
sampleCount: {
|
|
8
22
|
term: 'Sample count',
|
|
9
|
-
definition:
|
|
10
|
-
|
|
23
|
+
definition:
|
|
24
|
+
'Number of samples recorded for each day, group, and segment.',
|
|
25
|
+
queryNames: Object.values(queryNames),
|
|
11
26
|
},
|
|
12
27
|
},
|
|
13
28
|
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
choiceFilter,
|
|
3
|
+
dateTimeRangeFilter,
|
|
4
|
+
displayChoice,
|
|
5
|
+
} from '@altertable/data-app/contract';
|
|
6
|
+
import { formatDateRange } from '@altertable/data-app/format';
|
|
7
|
+
|
|
8
|
+
// Replace this fictional finding period with the period supported by its evidence.
|
|
9
|
+
const findingPeriod = {
|
|
10
|
+
from: new Date('2026-03-09T00:00:00Z'),
|
|
11
|
+
to: new Date('2026-03-16T00:00:00Z'),
|
|
12
|
+
};
|
|
13
|
+
export function periodLabel(range: { from: Date; to: Date }) {
|
|
14
|
+
return formatDateRange({
|
|
15
|
+
start: range.from.toISOString().slice(0, 10),
|
|
16
|
+
end: new Date(range.to.getTime() - 1).toISOString().slice(0, 10),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
export const findingPeriodLabel = periodLabel(findingPeriod);
|
|
20
|
+
export const periodFilter = dateTimeRangeFilter({
|
|
21
|
+
key: 'period',
|
|
22
|
+
defaultValue: findingPeriod,
|
|
23
|
+
comparison: 'on',
|
|
24
|
+
// These bounds match the seeded demo history. Use the real source coverage.
|
|
25
|
+
minDate: '2026-01-05',
|
|
26
|
+
maxDate: '2026-03-29',
|
|
27
|
+
maxRangeDays: 28,
|
|
28
|
+
presets: [{ label: 'Finding period', range: findingPeriod }],
|
|
29
|
+
});
|
|
30
|
+
export const groupName = choiceFilter({
|
|
31
|
+
key: 'group',
|
|
32
|
+
label: 'Group',
|
|
33
|
+
defaultValue: 'Alpha',
|
|
34
|
+
options: [
|
|
35
|
+
{ id: 'all', label: 'All groups' },
|
|
36
|
+
{ id: 'Alpha', label: 'Alpha' },
|
|
37
|
+
{ id: 'Beta', label: 'Beta' },
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
export const grain = displayChoice({
|
|
41
|
+
key: 'grain',
|
|
42
|
+
label: 'Grain',
|
|
43
|
+
defaultValue: 'day',
|
|
44
|
+
options: [
|
|
45
|
+
{ id: 'day', label: 'Day' },
|
|
46
|
+
{ id: 'week', label: 'Week' },
|
|
47
|
+
],
|
|
48
|
+
presentation: { control: 'widget' },
|
|
49
|
+
});
|
|
50
|
+
export const breakdown = displayChoice({
|
|
51
|
+
key: 'breakdown',
|
|
52
|
+
label: 'Breakdown',
|
|
53
|
+
defaultValue: 'segment',
|
|
54
|
+
options: [
|
|
55
|
+
{ id: 'segment', label: 'Segment' },
|
|
56
|
+
{ id: 'group', label: 'Group' },
|
|
57
|
+
],
|
|
58
|
+
presentation: { control: 'widget' },
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const operationFilters = {
|
|
62
|
+
sampleTotals: { period: periodFilter, groupName },
|
|
63
|
+
samplesOverTime: { period: periodFilter, groupName, grain },
|
|
64
|
+
samplesByMember: { period: periodFilter, groupName, breakdown },
|
|
65
|
+
sampleRows: { period: periodFilter, groupName, grain, breakdown },
|
|
66
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mountDataApp } from '@altertable/data-app-react';
|
|
2
|
+
import { installLocalQueryLakehouse } from '@altertable/data-app/client';
|
|
2
3
|
|
|
3
4
|
import { App } from '#app/App.tsx';
|
|
4
5
|
import { dataApp } from '#config';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
installLocalQueryLakehouse();
|
|
8
8
|
mountDataApp({ app: dataApp, component: App });
|