@altertable/data-app-examples 0.76.0 → 0.77.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 +60 -57
- package/templates/starter-finding-data-app/index.tsx +224 -166
- package/templates/starter-local-data-app/AGENTS.md +9 -9
- package/templates/starter-local-data-app/README.md +1 -1
- package/templates/starter-local-data-app/package.json +3 -3
- package/templates/starter-local-finding-data-app/AGENTS.md +9 -9
- package/templates/starter-local-finding-data-app/README.md +2 -2
- package/templates/starter-local-finding-data-app/app.ts +44 -33
- package/templates/starter-local-finding-data-app/package.json +3 -3
- package/templates/starter-local-finding-data-app/src/App.tsx +98 -113
- package/templates/starter-local-finding-data-app/src/data-context.ts +8 -2
- package/templates/starter-local-finding-data-app/src/filters.ts +48 -0
- package/templates/starter-local-finding-data-app/src/operations.ts +52 -34
- package/templates/starter-local-metric-data-app/AGENTS.md +9 -9
- package/templates/starter-local-metric-data-app/README.md +2 -2
- package/templates/starter-local-metric-data-app/package.json +3 -3
- package/templates/starter-local-metric-data-app/src/App.tsx +66 -67
- package/templates/starter-local-metric-data-app/src/filters.ts +20 -0
- package/templates/starter-local-metric-data-app/src/operations.ts +32 -39
- package/templates/starter-metric-data-app/index.tsx +110 -107
|
@@ -4,33 +4,20 @@ import {
|
|
|
4
4
|
DataSection,
|
|
5
5
|
VisualizationWidget,
|
|
6
6
|
Stack,
|
|
7
|
-
choiceVariable,
|
|
8
7
|
} from '@altertable/data-app-react';
|
|
9
8
|
import { BarChart } from '@altertable/data-app-react/ui';
|
|
10
9
|
import { createDataClient } from '@altertable/data-app/client';
|
|
11
10
|
|
|
12
11
|
import { sampleDataContext } from '#app/data-context.ts';
|
|
12
|
+
import { operationFilters } from '#app/filters.ts';
|
|
13
13
|
import type { operations } from '#app/operations.ts';
|
|
14
|
-
const {
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
const { defineView } = createDataHooks(
|
|
15
|
+
createDataClient<typeof operations>({ filters: operationFilters })
|
|
16
|
+
);
|
|
17
|
+
const sampleCountsView = defineView({
|
|
17
18
|
dataContext: sampleDataContext,
|
|
18
19
|
operation: 'sampleCountsByGroup',
|
|
19
|
-
|
|
20
|
-
groupName: choiceVariable({
|
|
21
|
-
key: 'group',
|
|
22
|
-
label: 'Group',
|
|
23
|
-
defaultValue: 'all',
|
|
24
|
-
options: [
|
|
25
|
-
{ id: 'all', label: 'All groups' },
|
|
26
|
-
{ id: 'Alpha', label: 'Alpha' },
|
|
27
|
-
{ id: 'Beta', label: 'Beta' },
|
|
28
|
-
],
|
|
29
|
-
}),
|
|
30
|
-
},
|
|
31
|
-
describeInput: ({ groupName }) =>
|
|
32
|
-
groupName === 'all' ? 'all groups' : groupName,
|
|
33
|
-
isEmpty: result => result.groups.length === 0,
|
|
20
|
+
isEmpty: rows => rows.length === 0,
|
|
34
21
|
emptyFallback: {
|
|
35
22
|
title: 'No matching groups',
|
|
36
23
|
description: 'No observations are available for this query.',
|
|
@@ -38,7 +25,7 @@ const sampleCountsView = defineDataView({
|
|
|
38
25
|
});
|
|
39
26
|
const sampleCounts = sampleCountsView.dataset({
|
|
40
27
|
name: 'Sample counts',
|
|
41
|
-
select:
|
|
28
|
+
select: rows => rows,
|
|
42
29
|
rowKey: row => row.groupName,
|
|
43
30
|
columns: {
|
|
44
31
|
groupName: { label: 'Group', value: row => row.groupName },
|
|
@@ -49,9 +36,18 @@ const sampleCounts = sampleCountsView.dataset({
|
|
|
49
36
|
glossaryIds: ['sampleCount'],
|
|
50
37
|
},
|
|
51
38
|
});
|
|
52
|
-
const
|
|
39
|
+
const segmentCountsView = defineView({
|
|
40
|
+
dataContext: sampleDataContext,
|
|
41
|
+
operation: 'sampleCountsBySegment',
|
|
42
|
+
isEmpty: rows => rows.length === 0,
|
|
43
|
+
emptyFallback: {
|
|
44
|
+
title: 'No matching segments',
|
|
45
|
+
description: 'No observations are available for this query.',
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
const segmentCounts = segmentCountsView.dataset({
|
|
53
49
|
name: 'Counts by segment',
|
|
54
|
-
select:
|
|
50
|
+
select: rows => rows,
|
|
55
51
|
rowKey: row => row.segmentName,
|
|
56
52
|
columns: {
|
|
57
53
|
segmentName: { label: 'Segment', value: row => row.segmentName },
|
|
@@ -70,55 +66,58 @@ const groupActions = sampleCounts.actions(
|
|
|
70
66
|
{ primary: 'drill' }
|
|
71
67
|
);
|
|
72
68
|
// Keep only the breakdowns and interactions relevant to the requested metric.
|
|
73
|
-
const
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
</
|
|
69
|
+
const groupContent = sampleCountsView.content(result => (
|
|
70
|
+
<VisualizationWidget
|
|
71
|
+
dataset={sampleCounts}
|
|
72
|
+
source={result}
|
|
73
|
+
title="Sample count"
|
|
74
|
+
description="Select a group to filter both charts; choose All groups to reset."
|
|
75
|
+
actions={groupActions}
|
|
76
|
+
>
|
|
77
|
+
{(rows, actions) => (
|
|
78
|
+
<BarChart
|
|
79
|
+
ariaLabel="Sample counts by group"
|
|
80
|
+
unit="samples"
|
|
81
|
+
items={rows.map(row => ({
|
|
82
|
+
...row,
|
|
83
|
+
id: row.groupName,
|
|
84
|
+
label: row.groupName,
|
|
85
|
+
value: row.sampleCount,
|
|
86
|
+
}))}
|
|
87
|
+
itemActions={actions}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
</VisualizationWidget>
|
|
91
|
+
));
|
|
92
|
+
const segmentContent = segmentCountsView.content(result => (
|
|
93
|
+
<VisualizationWidget
|
|
94
|
+
dataset={segmentCounts}
|
|
95
|
+
source={result}
|
|
96
|
+
title="Samples by segment"
|
|
97
|
+
description="Segment breakdown for the selected group scope."
|
|
98
|
+
>
|
|
99
|
+
{(rows, actions) => (
|
|
100
|
+
<BarChart
|
|
101
|
+
ariaLabel="Sample counts by segment"
|
|
102
|
+
unit="samples"
|
|
103
|
+
items={rows.map(row => ({
|
|
104
|
+
...row,
|
|
105
|
+
id: row.segmentName,
|
|
106
|
+
label: row.segmentName,
|
|
107
|
+
value: row.sampleCount,
|
|
108
|
+
}))}
|
|
109
|
+
itemActions={actions}
|
|
110
|
+
/>
|
|
111
|
+
)}
|
|
112
|
+
</VisualizationWidget>
|
|
117
113
|
));
|
|
118
114
|
export function App() {
|
|
119
115
|
return (
|
|
120
116
|
<DataApp view={sampleCountsView} showToolbar={false}>
|
|
121
|
-
<
|
|
117
|
+
<Stack>
|
|
118
|
+
<DataSection content={groupContent} label="Sample count" />
|
|
119
|
+
<DataSection content={segmentContent} label="Samples by segment" />
|
|
120
|
+
</Stack>
|
|
122
121
|
</DataApp>
|
|
123
122
|
);
|
|
124
123
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { choiceFilter } from '@altertable/data-app/contract';
|
|
2
|
+
|
|
3
|
+
// Declare each filter once in this browser-safe module: operations read them on
|
|
4
|
+
// the server, and the browser client renders their controls.
|
|
5
|
+
const groupName = choiceFilter({
|
|
6
|
+
key: 'group',
|
|
7
|
+
label: 'Group',
|
|
8
|
+
defaultValue: 'all',
|
|
9
|
+
options: [
|
|
10
|
+
{ id: 'all', label: 'All groups' },
|
|
11
|
+
{ id: 'Alpha', label: 'Alpha' },
|
|
12
|
+
{ id: 'Beta', label: 'Beta' },
|
|
13
|
+
],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
/** The filters each operation reads. */
|
|
17
|
+
export const operationFilters = {
|
|
18
|
+
sampleCountsByGroup: { groupName },
|
|
19
|
+
sampleCountsBySegment: { groupName },
|
|
20
|
+
};
|
|
@@ -1,50 +1,43 @@
|
|
|
1
1
|
import { parseCount } from '@altertable/data-app/contract';
|
|
2
2
|
|
|
3
|
+
import { operationFilters } from '#app/filters.ts';
|
|
3
4
|
import { dataApp } from '#config';
|
|
5
|
+
|
|
6
|
+
/** The fixture queries read an empty group name as every group. */
|
|
7
|
+
function queryGroup(groupName: string) {
|
|
8
|
+
return groupName === 'all' ? '' : groupName;
|
|
9
|
+
}
|
|
4
10
|
export const operations = {
|
|
5
11
|
sampleCountsByGroup: dataApp.defineOperation({
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
filters: operationFilters.sampleCountsByGroup,
|
|
13
|
+
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
14
|
+
async run({ query }, { groupName }) {
|
|
15
|
+
const queryResult = await query('sampleCountsByGroup', {
|
|
16
|
+
groupName: queryGroup(groupName),
|
|
17
|
+
});
|
|
18
|
+
return queryResult.rows.map(
|
|
19
|
+
(row): { groupName: 'Alpha' | 'Beta'; sampleCount: number } => {
|
|
20
|
+
if (row.group_name !== 'Alpha' && row.group_name !== 'Beta')
|
|
21
|
+
throw new Error('Unexpected fixture group.');
|
|
22
|
+
return {
|
|
23
|
+
groupName: row.group_name,
|
|
24
|
+
sampleCount: parseCount(row.sample_count),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
);
|
|
16
28
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{ groupName: 'Beta' },
|
|
21
|
-
],
|
|
29
|
+
}),
|
|
30
|
+
sampleCountsBySegment: dataApp.defineOperation({
|
|
31
|
+
filters: operationFilters.sampleCountsBySegment,
|
|
22
32
|
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
23
33
|
async run({ query }, { groupName }) {
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
]);
|
|
32
|
-
return {
|
|
33
|
-
groups: groups.rows.map(
|
|
34
|
-
(row): { groupName: 'Alpha' | 'Beta'; sampleCount: number } => {
|
|
35
|
-
if (row.group_name !== 'Alpha' && row.group_name !== 'Beta')
|
|
36
|
-
throw new Error('Unexpected fixture group.');
|
|
37
|
-
return {
|
|
38
|
-
groupName: row.group_name,
|
|
39
|
-
sampleCount: parseCount(row.sample_count),
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
),
|
|
43
|
-
segments: segments.rows.map(row => ({
|
|
44
|
-
segmentName: row.segment_name,
|
|
45
|
-
sampleCount: parseCount(row.sample_count),
|
|
46
|
-
})),
|
|
47
|
-
};
|
|
34
|
+
const queryResult = await query('sampleCountsBySegment', {
|
|
35
|
+
groupName: queryGroup(groupName),
|
|
36
|
+
});
|
|
37
|
+
return queryResult.rows.map(row => ({
|
|
38
|
+
segmentName: row.segment_name,
|
|
39
|
+
sampleCount: parseCount(row.sample_count),
|
|
40
|
+
}));
|
|
48
41
|
},
|
|
49
42
|
}),
|
|
50
43
|
};
|
|
@@ -10,11 +10,10 @@ import {
|
|
|
10
10
|
DataSection,
|
|
11
11
|
VisualizationWidget,
|
|
12
12
|
Stack,
|
|
13
|
-
choiceVariable,
|
|
14
13
|
} from '@altertable/data-app-react';
|
|
15
14
|
import { BarChart } from '@altertable/data-app-react/ui';
|
|
16
15
|
import { createDataClient } from '@altertable/data-app/client';
|
|
17
|
-
import { parseCount } from '@altertable/data-app/contract';
|
|
16
|
+
import { choiceFilter, parseCount } from '@altertable/data-app/contract';
|
|
18
17
|
const dataApp = defineDataApp({
|
|
19
18
|
title: 'Sample metric',
|
|
20
19
|
description: 'Fixture counts by group; replace with the requested metric.',
|
|
@@ -53,54 +52,60 @@ SELECT group_name, sample_count FROM SEMANTIC_VIEW(
|
|
|
53
52
|
},
|
|
54
53
|
},
|
|
55
54
|
});
|
|
55
|
+
// Declare each filter once; operations list the filters they read, and views,
|
|
56
|
+
// controls, and scope derive from them.
|
|
57
|
+
const groupName = choiceFilter({
|
|
58
|
+
key: 'group',
|
|
59
|
+
label: 'Group',
|
|
60
|
+
defaultValue: 'all',
|
|
61
|
+
options: [
|
|
62
|
+
{ id: 'all', label: 'All groups' },
|
|
63
|
+
{ id: 'Alpha', label: 'Alpha' },
|
|
64
|
+
{ id: 'Beta', label: 'Beta' },
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
/** The fixture queries read an empty group name as every group. */
|
|
68
|
+
function queryGroup(groupName: string) {
|
|
69
|
+
return groupName === 'all' ? '' : groupName;
|
|
70
|
+
}
|
|
56
71
|
const operations = {
|
|
57
72
|
sampleCountsByGroup: dataApp.defineOperation({
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
filters: { groupName },
|
|
74
|
+
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
75
|
+
async run({ query }, { groupName }) {
|
|
76
|
+
const queryResult = await query('sampleCountsByGroup', {
|
|
77
|
+
groupName: queryGroup(groupName),
|
|
78
|
+
});
|
|
79
|
+
return queryResult.rows.map(
|
|
80
|
+
(row): { groupName: 'Alpha' | 'Beta'; sampleCount: number } => {
|
|
81
|
+
if (row.group_name !== 'Alpha' && row.group_name !== 'Beta')
|
|
82
|
+
throw new Error('Unexpected fixture group.');
|
|
83
|
+
return {
|
|
84
|
+
groupName: row.group_name,
|
|
85
|
+
sampleCount: parseCount(row.sample_count),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
);
|
|
68
89
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{ groupName: 'Beta' },
|
|
73
|
-
],
|
|
90
|
+
}),
|
|
91
|
+
sampleCountsBySegment: dataApp.defineOperation({
|
|
92
|
+
filters: { groupName },
|
|
74
93
|
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
75
94
|
async run({ query }, { groupName }) {
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
]);
|
|
84
|
-
return {
|
|
85
|
-
groups: groups.rows.map(
|
|
86
|
-
(row): { groupName: 'Alpha' | 'Beta'; sampleCount: number } => {
|
|
87
|
-
if (row.group_name !== 'Alpha' && row.group_name !== 'Beta')
|
|
88
|
-
throw new Error('Unexpected fixture group.');
|
|
89
|
-
return {
|
|
90
|
-
groupName: row.group_name,
|
|
91
|
-
sampleCount: parseCount(row.sample_count),
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
),
|
|
95
|
-
segments: segments.rows.map(row => ({
|
|
96
|
-
segmentName: row.segment_name,
|
|
97
|
-
sampleCount: parseCount(row.sample_count),
|
|
98
|
-
})),
|
|
99
|
-
};
|
|
95
|
+
const queryResult = await query('sampleCountsBySegment', {
|
|
96
|
+
groupName: queryGroup(groupName),
|
|
97
|
+
});
|
|
98
|
+
return queryResult.rows.map(row => ({
|
|
99
|
+
segmentName: row.segment_name,
|
|
100
|
+
sampleCount: parseCount(row.sample_count),
|
|
101
|
+
}));
|
|
100
102
|
},
|
|
101
103
|
}),
|
|
102
104
|
};
|
|
103
|
-
const queryNames =
|
|
105
|
+
const queryNames = {
|
|
106
|
+
...operations.sampleCountsByGroup.queryNames,
|
|
107
|
+
...operations.sampleCountsBySegment.queryNames,
|
|
108
|
+
};
|
|
104
109
|
const sampleDataContext = createDataContext(queryNames)({
|
|
105
110
|
description:
|
|
106
111
|
'The starter_sample_counts semantic view measures fictional samples by group and segment. Replace it with the requested semantic metric before publishing.',
|
|
@@ -115,25 +120,11 @@ const sampleDataContext = createDataContext(queryNames)({
|
|
|
115
120
|
},
|
|
116
121
|
},
|
|
117
122
|
});
|
|
118
|
-
const {
|
|
119
|
-
const sampleCountsView =
|
|
123
|
+
const { defineView } = createDataHooks(createDataClient({ operations }));
|
|
124
|
+
const sampleCountsView = defineView({
|
|
120
125
|
dataContext: sampleDataContext,
|
|
121
126
|
operation: 'sampleCountsByGroup',
|
|
122
|
-
|
|
123
|
-
groupName: choiceVariable({
|
|
124
|
-
key: 'group',
|
|
125
|
-
label: 'Group',
|
|
126
|
-
defaultValue: 'all',
|
|
127
|
-
options: [
|
|
128
|
-
{ id: 'all', label: 'All groups' },
|
|
129
|
-
{ id: 'Alpha', label: 'Alpha' },
|
|
130
|
-
{ id: 'Beta', label: 'Beta' },
|
|
131
|
-
],
|
|
132
|
-
}),
|
|
133
|
-
},
|
|
134
|
-
describeInput: ({ groupName }) =>
|
|
135
|
-
groupName === 'all' ? 'all groups' : groupName,
|
|
136
|
-
isEmpty: result => result.groups.length === 0,
|
|
127
|
+
isEmpty: rows => rows.length === 0,
|
|
137
128
|
emptyFallback: {
|
|
138
129
|
title: 'No matching groups',
|
|
139
130
|
description: 'No observations are available for this query.',
|
|
@@ -141,7 +132,7 @@ const sampleCountsView = defineDataView({
|
|
|
141
132
|
});
|
|
142
133
|
const sampleCounts = sampleCountsView.dataset({
|
|
143
134
|
name: 'Sample counts',
|
|
144
|
-
select:
|
|
135
|
+
select: rows => rows,
|
|
145
136
|
rowKey: row => row.groupName,
|
|
146
137
|
columns: {
|
|
147
138
|
groupName: { label: 'Group', value: row => row.groupName },
|
|
@@ -152,9 +143,18 @@ const sampleCounts = sampleCountsView.dataset({
|
|
|
152
143
|
glossaryIds: ['sampleCount'],
|
|
153
144
|
},
|
|
154
145
|
});
|
|
155
|
-
const
|
|
146
|
+
const segmentCountsView = defineView({
|
|
147
|
+
dataContext: sampleDataContext,
|
|
148
|
+
operation: 'sampleCountsBySegment',
|
|
149
|
+
isEmpty: rows => rows.length === 0,
|
|
150
|
+
emptyFallback: {
|
|
151
|
+
title: 'No matching segments',
|
|
152
|
+
description: 'No observations are available for this query.',
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
const segmentCounts = segmentCountsView.dataset({
|
|
156
156
|
name: 'Counts by segment',
|
|
157
|
-
select:
|
|
157
|
+
select: rows => rows,
|
|
158
158
|
rowKey: row => row.segmentName,
|
|
159
159
|
columns: {
|
|
160
160
|
segmentName: { label: 'Segment', value: row => row.segmentName },
|
|
@@ -173,55 +173,58 @@ const groupActions = sampleCounts.actions(
|
|
|
173
173
|
{ primary: 'drill' }
|
|
174
174
|
);
|
|
175
175
|
// Keep only the breakdowns and interactions relevant to the requested metric.
|
|
176
|
-
const
|
|
177
|
-
<
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
</
|
|
176
|
+
const groupContent = sampleCountsView.content(result => (
|
|
177
|
+
<VisualizationWidget
|
|
178
|
+
dataset={sampleCounts}
|
|
179
|
+
source={result}
|
|
180
|
+
title="Sample count"
|
|
181
|
+
description="Select a group to filter both charts; choose All groups to reset."
|
|
182
|
+
actions={groupActions}
|
|
183
|
+
>
|
|
184
|
+
{(rows, actions) => (
|
|
185
|
+
<BarChart
|
|
186
|
+
ariaLabel="Sample counts by group"
|
|
187
|
+
unit="samples"
|
|
188
|
+
items={rows.map(row => ({
|
|
189
|
+
...row,
|
|
190
|
+
id: row.groupName,
|
|
191
|
+
label: row.groupName,
|
|
192
|
+
value: row.sampleCount,
|
|
193
|
+
}))}
|
|
194
|
+
itemActions={actions}
|
|
195
|
+
/>
|
|
196
|
+
)}
|
|
197
|
+
</VisualizationWidget>
|
|
198
|
+
));
|
|
199
|
+
const segmentContent = segmentCountsView.content(result => (
|
|
200
|
+
<VisualizationWidget
|
|
201
|
+
dataset={segmentCounts}
|
|
202
|
+
source={result}
|
|
203
|
+
title="Samples by segment"
|
|
204
|
+
description="Segment breakdown for the selected group scope."
|
|
205
|
+
>
|
|
206
|
+
{(rows, actions) => (
|
|
207
|
+
<BarChart
|
|
208
|
+
ariaLabel="Sample counts by segment"
|
|
209
|
+
unit="samples"
|
|
210
|
+
items={rows.map(row => ({
|
|
211
|
+
...row,
|
|
212
|
+
id: row.segmentName,
|
|
213
|
+
label: row.segmentName,
|
|
214
|
+
value: row.sampleCount,
|
|
215
|
+
}))}
|
|
216
|
+
itemActions={actions}
|
|
217
|
+
/>
|
|
218
|
+
)}
|
|
219
|
+
</VisualizationWidget>
|
|
220
220
|
));
|
|
221
221
|
function App() {
|
|
222
222
|
return (
|
|
223
223
|
<DataApp view={sampleCountsView} showToolbar={false}>
|
|
224
|
-
<
|
|
224
|
+
<Stack>
|
|
225
|
+
<DataSection content={groupContent} label="Sample count" />
|
|
226
|
+
<DataSection content={segmentContent} label="Samples by segment" />
|
|
227
|
+
</Stack>
|
|
225
228
|
</DataApp>
|
|
226
229
|
);
|
|
227
230
|
}
|