@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,193 +1,743 @@
|
|
|
1
1
|
import { defineDataApp } from '@altertable/data-app';
|
|
2
2
|
import {
|
|
3
3
|
createDataContext,
|
|
4
|
+
mountDataApp,
|
|
4
5
|
createDataHooks,
|
|
5
6
|
DataApp,
|
|
6
7
|
DataSection,
|
|
7
|
-
DataValue,
|
|
8
|
-
TableWidget,
|
|
9
8
|
Grid,
|
|
10
|
-
Stack,
|
|
11
|
-
TextContent,
|
|
12
|
-
injectDataAppStyles,
|
|
13
|
-
mountDataApp,
|
|
14
9
|
MetricWidget,
|
|
15
|
-
|
|
10
|
+
TableWidget,
|
|
11
|
+
VisualizationWidget,
|
|
12
|
+
Stack,
|
|
16
13
|
} from '@altertable/data-app-react';
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
14
|
+
import { BarChart, ComposedChart } from '@altertable/data-app-react/ui';
|
|
15
|
+
import {
|
|
16
|
+
parseCount,
|
|
17
|
+
choiceFilter,
|
|
18
|
+
displayChoice,
|
|
19
|
+
} from '@altertable/data-app/contract';
|
|
20
|
+
import { formatDateRange } from '@altertable/data-app/format';
|
|
20
21
|
|
|
21
|
-
const dataApp = defineDataApp({
|
|
22
|
-
title
|
|
23
|
-
|
|
22
|
+
export const dataApp = defineDataApp({
|
|
23
|
+
// Replace the demo title, description, and scope labels with the app's identity.
|
|
24
|
+
title: 'Infrastructure costs',
|
|
25
|
+
description: 'USD · Fictional weekly allocations',
|
|
24
26
|
scope: { organization: 'demo', environment: 'sample' },
|
|
25
27
|
appearance: { theme: 'system' },
|
|
26
28
|
queries: {
|
|
27
|
-
|
|
29
|
+
costBreakdown: {
|
|
28
30
|
projections: {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
member_name: { type: 'string' },
|
|
32
|
+
cost_cents: { type: 'number' },
|
|
31
33
|
},
|
|
32
34
|
statement: `
|
|
33
|
-
WITH
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
WITH infrastructure_costs(month, service_name, customer_name, week_1, week_2, week_3, week_4) AS (
|
|
36
|
+
-- Fictional allocation batches in integer cents.
|
|
37
|
+
-- Replace this CTE with verified billing data.
|
|
38
|
+
VALUES
|
|
39
|
+
('2026-09', 'Compute', 'Atlas', 84000, 126000, 84000, 126000),
|
|
40
|
+
('2026-09', 'Compute', 'Beacon', 42000, 63000, 42000, 63000),
|
|
41
|
+
('2026-09', 'Compute', 'Cedar', 18000, 27000, 18000, 27000),
|
|
42
|
+
('2026-09', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
43
|
+
('2026-09', 'Storage', 'Beacon', 84000, 56000, 84000, 56000),
|
|
44
|
+
('2026-09', 'Storage', 'Cedar', 36000, 24000, 36000, 24000),
|
|
45
|
+
('2026-09', 'Networking', 'Atlas', 3000, 6000, 9000, 12000),
|
|
46
|
+
('2026-09', 'Networking', 'Beacon', 6000, 12000, 18000, 24000),
|
|
47
|
+
('2026-09', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
48
|
+
('2026-09', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
49
|
+
('2026-09', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
50
|
+
('2026-09', 'Logging', 'Cedar', 0, 0, 0, 0),
|
|
51
|
+
('2026-08', 'Compute', 'Atlas', 76000, 114000, 76000, 114000),
|
|
52
|
+
('2026-08', 'Compute', 'Beacon', 40000, 60000, 40000, 60000),
|
|
53
|
+
('2026-08', 'Compute', 'Cedar', 16000, 24000, 16000, 24000),
|
|
54
|
+
('2026-08', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
55
|
+
('2026-08', 'Storage', 'Beacon', 75000, 50000, 75000, 50000),
|
|
56
|
+
('2026-08', 'Storage', 'Cedar', 33000, 22000, 33000, 22000),
|
|
57
|
+
('2026-08', 'Networking', 'Atlas', 2000, 4000, 6000, 8000),
|
|
58
|
+
('2026-08', 'Networking', 'Beacon', 5000, 10000, 15000, 20000),
|
|
59
|
+
('2026-08', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
60
|
+
('2026-08', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
61
|
+
('2026-08', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
62
|
+
('2026-08', 'Logging', 'Cedar', 0, 0, 0, 0)
|
|
63
|
+
),
|
|
64
|
+
selected_costs AS (
|
|
65
|
+
SELECT service_name, customer_name,
|
|
66
|
+
week_1 + week_2 + week_3 + week_4 AS cost_cents
|
|
67
|
+
FROM infrastructure_costs
|
|
68
|
+
WHERE month = $month AND ($customerName = '' OR customer_name = $customerName)
|
|
69
|
+
)
|
|
70
|
+
SELECT CASE WHEN $breakdown = 'service' THEN service_name ELSE customer_name END AS member_name,
|
|
71
|
+
CAST(SUM(cost_cents) AS BIGINT) AS cost_cents
|
|
72
|
+
FROM selected_costs GROUP BY member_name
|
|
73
|
+
ORDER BY cost_cents DESC, member_name LIMIT $limit`,
|
|
37
74
|
params: {
|
|
38
|
-
|
|
75
|
+
month: { type: 'string', defaultValue: '2026-09' },
|
|
76
|
+
customerName: { type: 'string', defaultValue: '' },
|
|
77
|
+
breakdown: { type: 'string', defaultValue: 'service' },
|
|
39
78
|
limit: { type: 'number', defaultValue: 10 },
|
|
40
79
|
},
|
|
41
80
|
},
|
|
81
|
+
totalCost: {
|
|
82
|
+
projections: {
|
|
83
|
+
cost_cents: { type: 'number' },
|
|
84
|
+
customer_count: { type: 'number' },
|
|
85
|
+
},
|
|
86
|
+
statement: `
|
|
87
|
+
WITH infrastructure_costs(month, service_name, customer_name, week_1, week_2, week_3, week_4) AS (
|
|
88
|
+
-- Fictional allocation batches in integer cents.
|
|
89
|
+
-- Replace this CTE with verified billing data.
|
|
90
|
+
VALUES
|
|
91
|
+
('2026-09', 'Compute', 'Atlas', 84000, 126000, 84000, 126000),
|
|
92
|
+
('2026-09', 'Compute', 'Beacon', 42000, 63000, 42000, 63000),
|
|
93
|
+
('2026-09', 'Compute', 'Cedar', 18000, 27000, 18000, 27000),
|
|
94
|
+
('2026-09', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
95
|
+
('2026-09', 'Storage', 'Beacon', 84000, 56000, 84000, 56000),
|
|
96
|
+
('2026-09', 'Storage', 'Cedar', 36000, 24000, 36000, 24000),
|
|
97
|
+
('2026-09', 'Networking', 'Atlas', 3000, 6000, 9000, 12000),
|
|
98
|
+
('2026-09', 'Networking', 'Beacon', 6000, 12000, 18000, 24000),
|
|
99
|
+
('2026-09', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
100
|
+
('2026-09', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
101
|
+
('2026-09', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
102
|
+
('2026-09', 'Logging', 'Cedar', 0, 0, 0, 0),
|
|
103
|
+
('2026-08', 'Compute', 'Atlas', 76000, 114000, 76000, 114000),
|
|
104
|
+
('2026-08', 'Compute', 'Beacon', 40000, 60000, 40000, 60000),
|
|
105
|
+
('2026-08', 'Compute', 'Cedar', 16000, 24000, 16000, 24000),
|
|
106
|
+
('2026-08', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
107
|
+
('2026-08', 'Storage', 'Beacon', 75000, 50000, 75000, 50000),
|
|
108
|
+
('2026-08', 'Storage', 'Cedar', 33000, 22000, 33000, 22000),
|
|
109
|
+
('2026-08', 'Networking', 'Atlas', 2000, 4000, 6000, 8000),
|
|
110
|
+
('2026-08', 'Networking', 'Beacon', 5000, 10000, 15000, 20000),
|
|
111
|
+
('2026-08', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
112
|
+
('2026-08', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
113
|
+
('2026-08', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
114
|
+
('2026-08', 'Logging', 'Cedar', 0, 0, 0, 0)
|
|
115
|
+
),
|
|
116
|
+
selected_costs AS (
|
|
117
|
+
SELECT service_name, customer_name,
|
|
118
|
+
week_1 + week_2 + week_3 + week_4 AS cost_cents
|
|
119
|
+
FROM infrastructure_costs
|
|
120
|
+
WHERE month = $month AND ($customerName = '' OR customer_name = $customerName)
|
|
121
|
+
)
|
|
122
|
+
SELECT CAST(SUM(cost_cents) AS BIGINT) AS cost_cents,
|
|
123
|
+
COUNT(DISTINCT customer_name) AS customer_count
|
|
124
|
+
FROM selected_costs HAVING COUNT(*) > 0`,
|
|
125
|
+
params: {
|
|
126
|
+
month: { type: 'string', defaultValue: '2026-09' },
|
|
127
|
+
customerName: { type: 'string', defaultValue: '' },
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
costsByCustomer: {
|
|
131
|
+
projections: {
|
|
132
|
+
customer_name: { type: 'string' },
|
|
133
|
+
cost_cents: { type: 'number' },
|
|
134
|
+
},
|
|
135
|
+
statement: `
|
|
136
|
+
WITH infrastructure_costs(month, service_name, customer_name, week_1, week_2, week_3, week_4) AS (
|
|
137
|
+
-- Fictional allocation batches in integer cents.
|
|
138
|
+
-- Replace this CTE with verified billing data.
|
|
139
|
+
VALUES
|
|
140
|
+
('2026-09', 'Compute', 'Atlas', 84000, 126000, 84000, 126000),
|
|
141
|
+
('2026-09', 'Compute', 'Beacon', 42000, 63000, 42000, 63000),
|
|
142
|
+
('2026-09', 'Compute', 'Cedar', 18000, 27000, 18000, 27000),
|
|
143
|
+
('2026-09', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
144
|
+
('2026-09', 'Storage', 'Beacon', 84000, 56000, 84000, 56000),
|
|
145
|
+
('2026-09', 'Storage', 'Cedar', 36000, 24000, 36000, 24000),
|
|
146
|
+
('2026-09', 'Networking', 'Atlas', 3000, 6000, 9000, 12000),
|
|
147
|
+
('2026-09', 'Networking', 'Beacon', 6000, 12000, 18000, 24000),
|
|
148
|
+
('2026-09', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
149
|
+
('2026-09', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
150
|
+
('2026-09', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
151
|
+
('2026-09', 'Logging', 'Cedar', 0, 0, 0, 0),
|
|
152
|
+
('2026-08', 'Compute', 'Atlas', 76000, 114000, 76000, 114000),
|
|
153
|
+
('2026-08', 'Compute', 'Beacon', 40000, 60000, 40000, 60000),
|
|
154
|
+
('2026-08', 'Compute', 'Cedar', 16000, 24000, 16000, 24000),
|
|
155
|
+
('2026-08', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
156
|
+
('2026-08', 'Storage', 'Beacon', 75000, 50000, 75000, 50000),
|
|
157
|
+
('2026-08', 'Storage', 'Cedar', 33000, 22000, 33000, 22000),
|
|
158
|
+
('2026-08', 'Networking', 'Atlas', 2000, 4000, 6000, 8000),
|
|
159
|
+
('2026-08', 'Networking', 'Beacon', 5000, 10000, 15000, 20000),
|
|
160
|
+
('2026-08', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
161
|
+
('2026-08', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
162
|
+
('2026-08', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
163
|
+
('2026-08', 'Logging', 'Cedar', 0, 0, 0, 0)
|
|
164
|
+
),
|
|
165
|
+
selected_costs AS (
|
|
166
|
+
SELECT service_name, customer_name,
|
|
167
|
+
week_1 + week_2 + week_3 + week_4 AS cost_cents
|
|
168
|
+
FROM infrastructure_costs
|
|
169
|
+
WHERE month = $month AND ($customerName = '' OR customer_name = $customerName)
|
|
170
|
+
)
|
|
171
|
+
SELECT customer_name, CAST(SUM(cost_cents) AS BIGINT) AS cost_cents
|
|
172
|
+
FROM selected_costs WHERE service_name = $serviceName
|
|
173
|
+
GROUP BY customer_name ORDER BY cost_cents DESC, customer_name LIMIT $limit`,
|
|
174
|
+
params: {
|
|
175
|
+
month: { type: 'string', defaultValue: '2026-09' },
|
|
176
|
+
customerName: { type: 'string', defaultValue: '' },
|
|
177
|
+
serviceName: { type: 'string' },
|
|
178
|
+
limit: { type: 'number', defaultValue: 10 },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
costTrend: {
|
|
182
|
+
projections: {
|
|
183
|
+
period_start: { type: 'string' },
|
|
184
|
+
cost_cents: { type: 'number' },
|
|
185
|
+
},
|
|
186
|
+
statement: `
|
|
187
|
+
WITH infrastructure_costs(month, service_name, customer_name, week_1, week_2, week_3, week_4) AS (
|
|
188
|
+
-- Fictional allocation batches in integer cents.
|
|
189
|
+
-- Replace this CTE with verified billing data.
|
|
190
|
+
VALUES
|
|
191
|
+
('2026-09', 'Compute', 'Atlas', 84000, 126000, 84000, 126000),
|
|
192
|
+
('2026-09', 'Compute', 'Beacon', 42000, 63000, 42000, 63000),
|
|
193
|
+
('2026-09', 'Compute', 'Cedar', 18000, 27000, 18000, 27000),
|
|
194
|
+
('2026-09', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
195
|
+
('2026-09', 'Storage', 'Beacon', 84000, 56000, 84000, 56000),
|
|
196
|
+
('2026-09', 'Storage', 'Cedar', 36000, 24000, 36000, 24000),
|
|
197
|
+
('2026-09', 'Networking', 'Atlas', 3000, 6000, 9000, 12000),
|
|
198
|
+
('2026-09', 'Networking', 'Beacon', 6000, 12000, 18000, 24000),
|
|
199
|
+
('2026-09', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
200
|
+
('2026-09', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
201
|
+
('2026-09', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
202
|
+
('2026-09', 'Logging', 'Cedar', 0, 0, 0, 0),
|
|
203
|
+
('2026-08', 'Compute', 'Atlas', 76000, 114000, 76000, 114000),
|
|
204
|
+
('2026-08', 'Compute', 'Beacon', 40000, 60000, 40000, 60000),
|
|
205
|
+
('2026-08', 'Compute', 'Cedar', 16000, 24000, 16000, 24000),
|
|
206
|
+
('2026-08', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
207
|
+
('2026-08', 'Storage', 'Beacon', 75000, 50000, 75000, 50000),
|
|
208
|
+
('2026-08', 'Storage', 'Cedar', 33000, 22000, 33000, 22000),
|
|
209
|
+
('2026-08', 'Networking', 'Atlas', 2000, 4000, 6000, 8000),
|
|
210
|
+
('2026-08', 'Networking', 'Beacon', 5000, 10000, 15000, 20000),
|
|
211
|
+
('2026-08', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
212
|
+
('2026-08', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
213
|
+
('2026-08', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
214
|
+
('2026-08', 'Logging', 'Cedar', 0, 0, 0, 0)
|
|
215
|
+
),
|
|
216
|
+
-- The four fictional batch dates match the week_1 through week_4 columns.
|
|
217
|
+
weeks(day) AS (VALUES ('01'), ('08'), ('15'), ('22'))
|
|
218
|
+
SELECT $month || '-' || day AS period_start,
|
|
219
|
+
CAST(SUM(CASE day WHEN '01' THEN week_1 WHEN '08' THEN week_2
|
|
220
|
+
WHEN '15' THEN week_3 ELSE week_4 END) AS BIGINT) AS cost_cents
|
|
221
|
+
FROM infrastructure_costs CROSS JOIN weeks
|
|
222
|
+
WHERE month = $month AND ($customerName = '' OR customer_name = $customerName)
|
|
223
|
+
GROUP BY day ORDER BY day LIMIT $limit`,
|
|
224
|
+
params: {
|
|
225
|
+
month: { type: 'string', defaultValue: '2026-09' },
|
|
226
|
+
customerName: { type: 'string', defaultValue: '' },
|
|
227
|
+
limit: { type: 'number', defaultValue: 10 },
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
customerServiceMix: {
|
|
231
|
+
projections: {
|
|
232
|
+
customer_name: { type: 'string' },
|
|
233
|
+
service_name: { type: 'string' },
|
|
234
|
+
cost_cents: { type: 'number' },
|
|
235
|
+
},
|
|
236
|
+
statement: `
|
|
237
|
+
WITH infrastructure_costs(month, service_name, customer_name, week_1, week_2, week_3, week_4) AS (
|
|
238
|
+
-- Fictional allocation batches in integer cents.
|
|
239
|
+
-- Replace this CTE with verified billing data.
|
|
240
|
+
VALUES
|
|
241
|
+
('2026-09', 'Compute', 'Atlas', 84000, 126000, 84000, 126000),
|
|
242
|
+
('2026-09', 'Compute', 'Beacon', 42000, 63000, 42000, 63000),
|
|
243
|
+
('2026-09', 'Compute', 'Cedar', 18000, 27000, 18000, 27000),
|
|
244
|
+
('2026-09', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
245
|
+
('2026-09', 'Storage', 'Beacon', 84000, 56000, 84000, 56000),
|
|
246
|
+
('2026-09', 'Storage', 'Cedar', 36000, 24000, 36000, 24000),
|
|
247
|
+
('2026-09', 'Networking', 'Atlas', 3000, 6000, 9000, 12000),
|
|
248
|
+
('2026-09', 'Networking', 'Beacon', 6000, 12000, 18000, 24000),
|
|
249
|
+
('2026-09', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
250
|
+
('2026-09', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
251
|
+
('2026-09', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
252
|
+
('2026-09', 'Logging', 'Cedar', 0, 0, 0, 0),
|
|
253
|
+
('2026-08', 'Compute', 'Atlas', 76000, 114000, 76000, 114000),
|
|
254
|
+
('2026-08', 'Compute', 'Beacon', 40000, 60000, 40000, 60000),
|
|
255
|
+
('2026-08', 'Compute', 'Cedar', 16000, 24000, 16000, 24000),
|
|
256
|
+
('2026-08', 'Storage', 'Atlas', 24000, 16000, 24000, 16000),
|
|
257
|
+
('2026-08', 'Storage', 'Beacon', 75000, 50000, 75000, 50000),
|
|
258
|
+
('2026-08', 'Storage', 'Cedar', 33000, 22000, 33000, 22000),
|
|
259
|
+
('2026-08', 'Networking', 'Atlas', 2000, 4000, 6000, 8000),
|
|
260
|
+
('2026-08', 'Networking', 'Beacon', 5000, 10000, 15000, 20000),
|
|
261
|
+
('2026-08', 'Networking', 'Cedar', 3000, 6000, 9000, 12000),
|
|
262
|
+
('2026-08', 'Logging', 'Atlas', 0, 0, 0, 0),
|
|
263
|
+
('2026-08', 'Logging', 'Beacon', 0, 0, 0, 0),
|
|
264
|
+
('2026-08', 'Logging', 'Cedar', 0, 0, 0, 0)
|
|
265
|
+
),
|
|
266
|
+
selected_costs AS (
|
|
267
|
+
SELECT service_name, customer_name,
|
|
268
|
+
week_1 + week_2 + week_3 + week_4 AS cost_cents
|
|
269
|
+
FROM infrastructure_costs
|
|
270
|
+
WHERE month = $month AND ($customerName = '' OR customer_name = $customerName)
|
|
271
|
+
)
|
|
272
|
+
SELECT customer_name, service_name, CAST(SUM(cost_cents) AS BIGINT) AS cost_cents
|
|
273
|
+
FROM selected_costs GROUP BY customer_name, service_name
|
|
274
|
+
ORDER BY customer_name, service_name LIMIT $limit`,
|
|
275
|
+
params: {
|
|
276
|
+
month: { type: 'string', defaultValue: '2026-09' },
|
|
277
|
+
customerName: { type: 'string', defaultValue: '' },
|
|
278
|
+
limit: { type: 'number', defaultValue: 20 },
|
|
279
|
+
},
|
|
280
|
+
},
|
|
42
281
|
},
|
|
43
282
|
});
|
|
44
|
-
|
|
283
|
+
|
|
284
|
+
// These months match the fictional SQL rows.
|
|
285
|
+
// Replace them with months covered by the billing source.
|
|
286
|
+
const month = choiceFilter({
|
|
287
|
+
key: 'month',
|
|
288
|
+
label: 'Month',
|
|
289
|
+
defaultValue: '2026-09',
|
|
290
|
+
options: [
|
|
291
|
+
{ id: '2026-09', label: 'September 2026' },
|
|
292
|
+
{ id: '2026-08', label: 'August 2026' },
|
|
293
|
+
],
|
|
294
|
+
});
|
|
295
|
+
// These customers match the fictional SQL rows.
|
|
296
|
+
// Replace them with customers from the billing source.
|
|
297
|
+
const customer = choiceFilter({
|
|
298
|
+
key: 'customer',
|
|
299
|
+
label: 'Customer',
|
|
300
|
+
defaultValue: 'all',
|
|
301
|
+
options: [
|
|
302
|
+
{ id: 'all', label: 'All customers' },
|
|
303
|
+
{ id: 'Atlas', label: 'Atlas' },
|
|
304
|
+
{ id: 'Beacon', label: 'Beacon' },
|
|
305
|
+
{ id: 'Cedar', label: 'Cedar' },
|
|
306
|
+
],
|
|
307
|
+
});
|
|
308
|
+
const breakdown = displayChoice({
|
|
309
|
+
key: 'breakdown',
|
|
310
|
+
label: 'Breakdown',
|
|
311
|
+
defaultValue: 'service',
|
|
312
|
+
options: [
|
|
313
|
+
{ id: 'service', label: 'Service' },
|
|
314
|
+
{ id: 'customer', label: 'Customer' },
|
|
315
|
+
],
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
function parseService(value: unknown) {
|
|
45
319
|
if (
|
|
46
320
|
!value ||
|
|
47
321
|
typeof value !== 'object' ||
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
value.
|
|
322
|
+
Array.isArray(value) ||
|
|
323
|
+
!('serviceName' in value) ||
|
|
324
|
+
typeof value.serviceName !== 'string' ||
|
|
325
|
+
value.serviceName.trim().length === 0 ||
|
|
326
|
+
value.serviceName.length > 100
|
|
51
327
|
)
|
|
52
|
-
throw new Error('
|
|
53
|
-
return {
|
|
328
|
+
throw new Error('Choose a service to inspect its customer costs.');
|
|
329
|
+
return { serviceName: value.serviceName };
|
|
330
|
+
}
|
|
331
|
+
function queryScope(input: { month: string; customer: string }) {
|
|
332
|
+
return {
|
|
333
|
+
month: input.month,
|
|
334
|
+
customerName: input.customer === 'all' ? '' : input.customer,
|
|
335
|
+
};
|
|
54
336
|
}
|
|
55
|
-
const operations = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
337
|
+
export const operations = dataApp.defineOperations({
|
|
338
|
+
costBreakdown: dataApp.defineOperation({
|
|
339
|
+
filters: { month, customer, breakdown },
|
|
340
|
+
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
341
|
+
async run({ query }, input) {
|
|
342
|
+
const result = await query('costBreakdown', {
|
|
343
|
+
...queryScope(input),
|
|
344
|
+
breakdown: input.breakdown,
|
|
345
|
+
});
|
|
346
|
+
return result.rows.map(row => ({
|
|
347
|
+
memberName: row.member_name,
|
|
348
|
+
dimension: input.breakdown,
|
|
349
|
+
cost: parseCount(row.cost_cents) / 100,
|
|
350
|
+
}));
|
|
351
|
+
},
|
|
352
|
+
}),
|
|
353
|
+
totalCost: dataApp.defineOperation({
|
|
354
|
+
filters: { month, customer },
|
|
355
|
+
policy: { maxQueryRows: 1, maxDurationMs: 15000 },
|
|
356
|
+
async run({ query }, input) {
|
|
357
|
+
const result = await query('totalCost', queryScope(input));
|
|
358
|
+
const row = result.rows[0];
|
|
359
|
+
if (!row) return null;
|
|
360
|
+
const cost = parseCount(row.cost_cents) / 100;
|
|
361
|
+
const customerCount = parseCount(row.customer_count);
|
|
362
|
+
if (customerCount === 0)
|
|
363
|
+
throw new Error('Allocations must identify at least one customer.');
|
|
364
|
+
return {
|
|
365
|
+
cost,
|
|
366
|
+
customerCount,
|
|
367
|
+
averageCost: cost / customerCount,
|
|
368
|
+
};
|
|
369
|
+
},
|
|
370
|
+
}),
|
|
371
|
+
costsByCustomer: dataApp.defineOperation({
|
|
372
|
+
filters: { month, customer },
|
|
373
|
+
input: parseService,
|
|
374
|
+
checks: [{ serviceName: 'Compute' }],
|
|
375
|
+
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
376
|
+
async run({ query }, input) {
|
|
377
|
+
const result = await query('costsByCustomer', {
|
|
378
|
+
...queryScope(input),
|
|
379
|
+
serviceName: input.serviceName,
|
|
380
|
+
});
|
|
381
|
+
return result.rows.map(row => ({
|
|
382
|
+
customerName: row.customer_name,
|
|
383
|
+
cost: parseCount(row.cost_cents) / 100,
|
|
384
|
+
}));
|
|
385
|
+
},
|
|
386
|
+
}),
|
|
387
|
+
costTrend: dataApp.defineOperation({
|
|
388
|
+
filters: { month, customer },
|
|
63
389
|
policy: { maxQueryRows: 10, maxDurationMs: 15000 },
|
|
64
|
-
async run({ query },
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
|
|
68
|
-
|
|
390
|
+
async run({ query }, input) {
|
|
391
|
+
const result = await query('costTrend', queryScope(input));
|
|
392
|
+
return result.rows.map(row => ({
|
|
393
|
+
periodStart: row.period_start,
|
|
394
|
+
cost: parseCount(row.cost_cents) / 100,
|
|
69
395
|
}));
|
|
70
396
|
},
|
|
71
397
|
}),
|
|
398
|
+
customerServiceMix: dataApp.defineOperation({
|
|
399
|
+
filters: { month, customer },
|
|
400
|
+
policy: { maxQueryRows: 20, maxDurationMs: 15000 },
|
|
401
|
+
async run({ query }, input) {
|
|
402
|
+
const result = await query('customerServiceMix', queryScope(input));
|
|
403
|
+
// These service names match the fictional SQL rows and chart series.
|
|
404
|
+
// Update the pivot and chart series together when changing the services.
|
|
405
|
+
const customers = new Map<
|
|
406
|
+
string,
|
|
407
|
+
{
|
|
408
|
+
customerName: string;
|
|
409
|
+
Compute: number;
|
|
410
|
+
Storage: number;
|
|
411
|
+
Networking: number;
|
|
412
|
+
Logging: number;
|
|
413
|
+
total: number;
|
|
414
|
+
}
|
|
415
|
+
>();
|
|
416
|
+
for (const row of result.rows) {
|
|
417
|
+
const service = row.service_name;
|
|
418
|
+
if (
|
|
419
|
+
service !== 'Compute' &&
|
|
420
|
+
service !== 'Storage' &&
|
|
421
|
+
service !== 'Networking' &&
|
|
422
|
+
service !== 'Logging'
|
|
423
|
+
)
|
|
424
|
+
throw new Error('Unexpected fixture service.');
|
|
425
|
+
const entry = customers.get(row.customer_name) ?? {
|
|
426
|
+
customerName: row.customer_name,
|
|
427
|
+
Compute: 0,
|
|
428
|
+
Storage: 0,
|
|
429
|
+
Networking: 0,
|
|
430
|
+
Logging: 0,
|
|
431
|
+
total: 0,
|
|
432
|
+
};
|
|
433
|
+
const cost = parseCount(row.cost_cents) / 100;
|
|
434
|
+
entry[service] += cost;
|
|
435
|
+
entry.total += cost;
|
|
436
|
+
customers.set(row.customer_name, entry);
|
|
437
|
+
}
|
|
438
|
+
return [...customers.values()].sort(
|
|
439
|
+
(a, b) =>
|
|
440
|
+
b.total - a.total || a.customerName.localeCompare(b.customerName)
|
|
441
|
+
);
|
|
442
|
+
},
|
|
443
|
+
}),
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
const queryNames = {
|
|
447
|
+
...operations.costBreakdown.queryNames,
|
|
448
|
+
...operations.totalCost.queryNames,
|
|
449
|
+
...operations.costsByCustomer.queryNames,
|
|
450
|
+
...operations.costTrend.queryNames,
|
|
451
|
+
...operations.customerServiceMix.queryNames,
|
|
72
452
|
};
|
|
73
|
-
|
|
74
|
-
const
|
|
453
|
+
// Replace these example definitions and coverage with verified source metadata.
|
|
454
|
+
const costDataContext = createDataContext(queryNames)({
|
|
75
455
|
description:
|
|
76
|
-
'
|
|
456
|
+
'Fictional weekly customer allocations for August and September 2026. Scope filters apply to every chart and its contributing records.',
|
|
77
457
|
glossary: {
|
|
78
|
-
|
|
79
|
-
term: '
|
|
458
|
+
allocatedCost: {
|
|
459
|
+
term: 'Allocated cost',
|
|
460
|
+
definition:
|
|
461
|
+
'USD charges in the selected billing month and customer scope. Four recorded allocation batches, dated the 1st, 8th, 15th and 22nd, sum to each monthly allocation. Customers sum to services; services sum to the total. Zero is a recorded charge of zero.',
|
|
462
|
+
queryNames: Object.values(queryNames),
|
|
463
|
+
},
|
|
464
|
+
customerCount: {
|
|
465
|
+
term: 'Customers',
|
|
80
466
|
definition:
|
|
81
|
-
'
|
|
82
|
-
queryNames: [queryNames.
|
|
467
|
+
'Distinct customers with recorded allocations in the selected scope, including recorded zero charges.',
|
|
468
|
+
queryNames: [queryNames.totalCost],
|
|
469
|
+
},
|
|
470
|
+
averageCustomerCost: {
|
|
471
|
+
term: 'Average per customer',
|
|
472
|
+
definition:
|
|
473
|
+
'Total allocated cost divided by the number of distinct customers in the same selected scope, including customers with zero charges.',
|
|
474
|
+
queryNames: [queryNames.totalCost],
|
|
83
475
|
},
|
|
84
476
|
},
|
|
85
477
|
});
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
478
|
+
|
|
479
|
+
// Fictional charges use USD. Match this format to the real billing currency.
|
|
480
|
+
const costFormat = { kind: 'currency', currency: 'USD' } as const;
|
|
481
|
+
const { defineView, defineDetailView } = createDataHooks(
|
|
482
|
+
operations.createDataClient()
|
|
483
|
+
);
|
|
484
|
+
const emptyFallback = {
|
|
485
|
+
title: 'No allocations',
|
|
486
|
+
description: 'Choose another month or customer.',
|
|
487
|
+
};
|
|
488
|
+
const servicesView = defineView({
|
|
489
|
+
dataContext: costDataContext,
|
|
490
|
+
operation: 'costBreakdown',
|
|
491
|
+
isEmpty: rows => rows.length === 0,
|
|
492
|
+
emptyFallback,
|
|
493
|
+
});
|
|
494
|
+
const serviceCosts = servicesView.dataset({
|
|
495
|
+
name: 'Cost breakdown',
|
|
496
|
+
select: rows => rows,
|
|
497
|
+
rowKey: row => row.memberName,
|
|
498
|
+
columns: {
|
|
499
|
+
memberName: { label: 'Member', value: row => row.memberName },
|
|
500
|
+
cost: { label: 'Cost', value: row => row.cost, format: costFormat },
|
|
501
|
+
},
|
|
502
|
+
evidence: { id: 'cost-breakdown', glossaryIds: ['allocatedCost'] },
|
|
503
|
+
});
|
|
504
|
+
const totalView = defineView({
|
|
505
|
+
dataContext: costDataContext,
|
|
506
|
+
operation: 'totalCost',
|
|
507
|
+
isEmpty: total => total === null,
|
|
508
|
+
emptyFallback: { title: 'No total available' },
|
|
509
|
+
});
|
|
510
|
+
const totalCost = totalView.metric(
|
|
511
|
+
{
|
|
512
|
+
id: 'total-cost',
|
|
513
|
+
glossaryId: 'allocatedCost',
|
|
514
|
+
label: 'Total cost',
|
|
515
|
+
format: costFormat,
|
|
516
|
+
},
|
|
517
|
+
total => {
|
|
518
|
+
if (total === null)
|
|
519
|
+
throw new Error('No allocated total for this selection.');
|
|
520
|
+
return { current: total.cost };
|
|
521
|
+
}
|
|
522
|
+
);
|
|
523
|
+
const customerCount = totalView.metric(
|
|
524
|
+
{
|
|
525
|
+
id: 'customer-count',
|
|
526
|
+
glossaryId: 'customerCount',
|
|
527
|
+
label: 'Customers',
|
|
528
|
+
format: { kind: 'count' },
|
|
529
|
+
},
|
|
530
|
+
total => {
|
|
531
|
+
if (total === null)
|
|
532
|
+
throw new Error('No customer count for this selection.');
|
|
533
|
+
return { current: total.customerCount };
|
|
534
|
+
}
|
|
535
|
+
);
|
|
536
|
+
const averageCost = totalView.metric(
|
|
537
|
+
{
|
|
538
|
+
id: 'average-cost',
|
|
539
|
+
glossaryId: 'averageCustomerCost',
|
|
540
|
+
label: 'Average per customer',
|
|
541
|
+
format: costFormat,
|
|
96
542
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
543
|
+
total => {
|
|
544
|
+
if (total === null) throw new Error('No average cost for this selection.');
|
|
545
|
+
return { current: total.averageCost };
|
|
546
|
+
}
|
|
547
|
+
);
|
|
548
|
+
const totalContent = totalView.content(result => (
|
|
549
|
+
<Grid columns={3}>
|
|
550
|
+
<MetricWidget metric={totalCost} source={result} />
|
|
551
|
+
<MetricWidget metric={customerCount} source={result} />
|
|
552
|
+
<MetricWidget metric={averageCost} source={result} />
|
|
553
|
+
</Grid>
|
|
554
|
+
));
|
|
555
|
+
const customersView = defineDetailView({
|
|
556
|
+
id: 'service-customers',
|
|
557
|
+
title: 'Customer costs',
|
|
558
|
+
operation: 'costsByCustomer',
|
|
559
|
+
dataContext: costDataContext,
|
|
560
|
+
parseInput: operations.costsByCustomer.input,
|
|
561
|
+
describeInput: input =>
|
|
562
|
+
`${input.serviceName} · ${month.describe?.(input.month)} · USD`,
|
|
563
|
+
isEmpty: rows => rows.length === 0,
|
|
100
564
|
emptyFallback: {
|
|
101
|
-
title: 'No
|
|
102
|
-
description:
|
|
565
|
+
title: 'No customer allocations',
|
|
566
|
+
description:
|
|
567
|
+
'No allocations are recorded for this service in the selected month and customer scope.',
|
|
103
568
|
},
|
|
104
569
|
});
|
|
105
|
-
const
|
|
106
|
-
name: '
|
|
570
|
+
const customerCosts = customersView.dataset({
|
|
571
|
+
name: 'Customer allocations',
|
|
107
572
|
select: rows => rows,
|
|
108
|
-
rowKey: row => row.
|
|
573
|
+
rowKey: row => row.customerName,
|
|
109
574
|
columns: {
|
|
110
|
-
|
|
111
|
-
|
|
575
|
+
customerName: { label: 'Customer', value: row => row.customerName },
|
|
576
|
+
cost: { label: 'Cost', value: row => row.cost, format: costFormat },
|
|
112
577
|
},
|
|
113
|
-
evidence: {
|
|
114
|
-
|
|
115
|
-
|
|
578
|
+
evidence: { id: 'costs-by-customer', glossaryIds: ['allocatedCost'] },
|
|
579
|
+
});
|
|
580
|
+
const customersDetail = customersView.content(result => (
|
|
581
|
+
<TableWidget
|
|
582
|
+
dataset={customerCosts}
|
|
583
|
+
source={result}
|
|
584
|
+
title="Cost by customer"
|
|
585
|
+
pagination={false}
|
|
586
|
+
/>
|
|
587
|
+
));
|
|
588
|
+
const serviceActions = serviceCosts.actions(
|
|
589
|
+
action => ({
|
|
590
|
+
customers: action.detail({
|
|
591
|
+
label: 'View customers',
|
|
592
|
+
target: customersView,
|
|
593
|
+
when: row => row.dimension === 'service',
|
|
594
|
+
input: row => ({ serviceName: row.memberName }),
|
|
595
|
+
}),
|
|
596
|
+
}),
|
|
597
|
+
{ primary: 'customers' }
|
|
598
|
+
);
|
|
599
|
+
const breakdownContent = servicesView.content(result => {
|
|
600
|
+
const byService = result.loading || result.input.breakdown === 'service';
|
|
601
|
+
return (
|
|
602
|
+
<VisualizationWidget
|
|
603
|
+
dataset={serviceCosts}
|
|
604
|
+
source={result}
|
|
605
|
+
title={byService ? 'Cost by service' : 'Cost by customer'}
|
|
606
|
+
actions={serviceActions}
|
|
607
|
+
breakdown={servicesView.breakdown('breakdown')}
|
|
608
|
+
>
|
|
609
|
+
{(rows, actions) => (
|
|
610
|
+
<BarChart
|
|
611
|
+
ariaLabel={byService ? 'Costs by service' : 'Costs by customer'}
|
|
612
|
+
unit="USD"
|
|
613
|
+
showYAxis
|
|
614
|
+
scrollToEnd={false}
|
|
615
|
+
valueFormat={costFormat}
|
|
616
|
+
items={rows.map(row => ({
|
|
617
|
+
...row,
|
|
618
|
+
id: row.memberName,
|
|
619
|
+
label: row.memberName,
|
|
620
|
+
value: row.cost,
|
|
621
|
+
}))}
|
|
622
|
+
itemActions={actions}
|
|
623
|
+
/>
|
|
624
|
+
)}
|
|
625
|
+
</VisualizationWidget>
|
|
626
|
+
);
|
|
627
|
+
});
|
|
628
|
+
const trendView = defineView({
|
|
629
|
+
dataContext: costDataContext,
|
|
630
|
+
operation: 'costTrend',
|
|
631
|
+
isEmpty: rows => rows.length === 0,
|
|
632
|
+
emptyFallback,
|
|
633
|
+
});
|
|
634
|
+
const weeklyCosts = trendView.dataset({
|
|
635
|
+
name: 'Weekly allocations',
|
|
636
|
+
select: rows => rows,
|
|
637
|
+
rowKey: row => row.periodStart,
|
|
638
|
+
columns: {
|
|
639
|
+
periodStart: { label: 'Allocation date', value: row => row.periodStart },
|
|
640
|
+
cost: { label: 'Cost', value: row => row.cost, format: costFormat },
|
|
116
641
|
},
|
|
642
|
+
evidence: { id: 'cost-trend', glossaryIds: ['allocatedCost'] },
|
|
117
643
|
});
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
644
|
+
const trendContent = trendView.content(result => (
|
|
645
|
+
<VisualizationWidget
|
|
646
|
+
dataset={weeklyCosts}
|
|
647
|
+
source={result}
|
|
648
|
+
title="Weekly allocated cost"
|
|
649
|
+
>
|
|
650
|
+
{rows => (
|
|
651
|
+
<ComposedChart
|
|
652
|
+
data={rows}
|
|
653
|
+
ariaLabel="Costs over time"
|
|
654
|
+
valueFormat={costFormat}
|
|
655
|
+
>
|
|
656
|
+
<ComposedChart.XAxis
|
|
657
|
+
dataKey="periodStart"
|
|
658
|
+
tickFormatter={value =>
|
|
659
|
+
formatDateRange({ start: String(value), end: String(value) })
|
|
660
|
+
}
|
|
661
|
+
/>
|
|
662
|
+
<ComposedChart.YAxis domain={[0, 'auto']} />
|
|
663
|
+
<ComposedChart.Tooltip />
|
|
664
|
+
<ComposedChart.Line dataKey="cost" name="Allocated cost" />
|
|
665
|
+
</ComposedChart>
|
|
666
|
+
)}
|
|
667
|
+
</VisualizationWidget>
|
|
668
|
+
));
|
|
669
|
+
const mixView = defineView({
|
|
670
|
+
dataContext: costDataContext,
|
|
671
|
+
operation: 'customerServiceMix',
|
|
672
|
+
isEmpty: rows => rows.length === 0,
|
|
673
|
+
emptyFallback,
|
|
674
|
+
});
|
|
675
|
+
const customerMix = mixView.dataset({
|
|
676
|
+
name: 'Customer service mix',
|
|
677
|
+
select: rows => rows,
|
|
678
|
+
rowKey: row => row.customerName,
|
|
679
|
+
columns: {
|
|
680
|
+
customerName: { label: 'Customer', value: row => row.customerName },
|
|
681
|
+
Compute: { value: row => row.Compute, format: costFormat },
|
|
682
|
+
Storage: { value: row => row.Storage, format: costFormat },
|
|
683
|
+
Networking: { value: row => row.Networking, format: costFormat },
|
|
684
|
+
Logging: { value: row => row.Logging, format: costFormat },
|
|
124
685
|
},
|
|
125
|
-
|
|
126
|
-
);
|
|
127
|
-
const
|
|
128
|
-
<
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
686
|
+
evidence: { id: 'customer-service-mix', glossaryIds: ['allocatedCost'] },
|
|
687
|
+
});
|
|
688
|
+
const mixContent = mixView.content(result => (
|
|
689
|
+
<VisualizationWidget
|
|
690
|
+
dataset={customerMix}
|
|
691
|
+
source={result}
|
|
692
|
+
title="Service mix by customer"
|
|
693
|
+
>
|
|
694
|
+
{rows => (
|
|
695
|
+
<ComposedChart
|
|
696
|
+
data={rows}
|
|
697
|
+
ariaLabel="Service mix by customer"
|
|
698
|
+
valueFormat={costFormat}
|
|
699
|
+
>
|
|
700
|
+
<ComposedChart.XAxis dataKey="customerName" />
|
|
701
|
+
<ComposedChart.YAxis domain={[0, 'auto']} />
|
|
702
|
+
<ComposedChart.Tooltip />
|
|
703
|
+
<ComposedChart.Legend />
|
|
704
|
+
{/* These service keys must match the columns returned by customerServiceMix. */}
|
|
705
|
+
<ComposedChart.Bar dataKey="Compute" name="Compute" stackId="cost" />
|
|
706
|
+
<ComposedChart.Bar
|
|
707
|
+
dataKey="Storage"
|
|
708
|
+
name="Storage"
|
|
709
|
+
stackId="cost"
|
|
710
|
+
fill="var(--atbl-chart-2)"
|
|
711
|
+
/>
|
|
712
|
+
<ComposedChart.Bar
|
|
713
|
+
dataKey="Networking"
|
|
714
|
+
name="Networking"
|
|
715
|
+
stackId="cost"
|
|
716
|
+
fill="var(--atbl-chart-3)"
|
|
717
|
+
/>
|
|
718
|
+
<ComposedChart.Bar
|
|
719
|
+
dataKey="Logging"
|
|
720
|
+
name="Logging"
|
|
721
|
+
stackId="cost"
|
|
722
|
+
fill="var(--atbl-chart-4)"
|
|
723
|
+
/>
|
|
724
|
+
</ComposedChart>
|
|
725
|
+
)}
|
|
726
|
+
</VisualizationWidget>
|
|
149
727
|
));
|
|
150
728
|
function App() {
|
|
151
729
|
return (
|
|
152
|
-
<DataApp
|
|
153
|
-
view={sampleCountsView}
|
|
154
|
-
datasets={[sampleCounts]}
|
|
155
|
-
story={snapshot => {
|
|
156
|
-
const total = totalSamples.read(snapshot);
|
|
157
|
-
const scope = sampleCountsView.scope(snapshot);
|
|
158
|
-
return [
|
|
159
|
-
{
|
|
160
|
-
id: 'total-samples',
|
|
161
|
-
headline: `Total samples: ${formatMetric(total.value.current, totalSamples.definition.format)}`,
|
|
162
|
-
context: `Demonstration values for ${scope}.`,
|
|
163
|
-
visual: <MetricWidget metric={totalSamples} source={snapshot} />,
|
|
164
|
-
visualKind: 'metric',
|
|
165
|
-
evidence: totalSamples,
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
id: 'counts-by-group',
|
|
169
|
-
headline: 'Counts by group',
|
|
170
|
-
context: `Demonstration values for ${scope}.`,
|
|
171
|
-
visual: (
|
|
172
|
-
<TableWidget
|
|
173
|
-
dataset={sampleCounts}
|
|
174
|
-
source={snapshot}
|
|
175
|
-
pagination={false}
|
|
176
|
-
/>
|
|
177
|
-
),
|
|
178
|
-
evidence: sampleCounts,
|
|
179
|
-
},
|
|
180
|
-
];
|
|
181
|
-
}}
|
|
182
|
-
>
|
|
730
|
+
<DataApp view={servicesView} details={[customersDetail]}>
|
|
183
731
|
<Stack>
|
|
184
|
-
<
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
732
|
+
<DataSection content={totalContent} label="Cost summary" />
|
|
733
|
+
<Grid columns={2}>
|
|
734
|
+
<DataSection content={trendContent} label="Cost trend" />
|
|
735
|
+
<DataSection content={breakdownContent} label="Cost overview" />
|
|
736
|
+
</Grid>
|
|
737
|
+
<DataSection content={mixContent} label="Customer composition" />
|
|
188
738
|
</Stack>
|
|
189
739
|
</DataApp>
|
|
190
740
|
);
|
|
191
741
|
}
|
|
192
|
-
|
|
742
|
+
|
|
193
743
|
mountDataApp({ app: dataApp, component: App });
|