-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathchart-gallery.dataset.ts
More file actions
51 lines (47 loc) · 2.49 KB
/
Copy pathchart-gallery.dataset.ts
File metadata and controls
51 lines (47 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) 2025 ObjectStack. Licensed under the Apache-2.0 license.
import { defineDataset } from '@objectstack/spec/ui';
/**
* Datasets backing the Chart Gallery dashboard (ADR-0021). Every gallery widget
* binds to one of these and selects dimensions/measures BY NAME, so the same
* metric ("task count", "hours", "budget") is defined once.
*/
/** Task analytics — counts, hours, progress over showcase_task. */
export const ShowcaseTaskDataset = defineDataset({
name: 'showcase_task_metrics',
label: 'Task Metrics',
object: 'showcase_task',
dimensions: [
{ name: 'status', label: 'Status', field: 'status', type: 'string' },
{ name: 'priority', label: 'Priority', field: 'priority', type: 'string' },
{ name: 'progress', label: 'Progress', field: 'progress', type: 'number' },
{ name: 'created_at', label: 'Created', field: 'created_at', type: 'date', dateGranularity: 'month' },
],
measures: [
{ name: 'task_count', label: 'Tasks', aggregate: 'count' },
{ name: 'est_hours', label: 'Estimated Hours', aggregate: 'sum', field: 'estimate_hours', format: '0.0' },
{ name: 'avg_estimate', label: 'Avg Estimate', aggregate: 'avg', field: 'estimate_hours', format: '0.0' },
{ name: 'avg_progress', label: 'Avg Progress', aggregate: 'avg', field: 'progress', format: '0.0' },
],
});
/** Project analytics — budget / spend over showcase_project. */
export const ShowcaseProjectDataset = defineDataset({
name: 'showcase_project_metrics',
label: 'Project Metrics',
object: 'showcase_project',
dimensions: [
{ name: 'account', label: 'Account', field: 'account', type: 'lookup' },
// status / health added for the Operations dashboard — power the
// "by health" chart and the filtered KPI tiles (active / at-risk).
{ name: 'status', label: 'Status', field: 'status', type: 'string' },
{ name: 'health', label: 'Health', field: 'health', type: 'string' },
],
measures: [
{ name: 'project_count', label: 'Projects', aggregate: 'count' },
// `budget`/`spent` are currency fields with NO declared currency code, so a
// hardcoded "$" misrepresents the amount (an amount with unspecified
// currency must not show a $ symbol). Use a plain grouped-number format;
// declare a `currency` on the field to get a locale-correct symbol via Intl.
{ name: 'budget_sum', label: 'Total Budget', aggregate: 'sum', field: 'budget', format: '0,0' },
{ name: 'spent_sum', label: 'Total Spent', aggregate: 'sum', field: 'spent', format: '0,0' },
],
});