@arcfusionz/arc-analytic-ui 0.0.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/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/components/AnomalyCard/AnomalyCard.chart.d.ts +64 -0
- package/dist/components/AnomalyCard/AnomalyCard.chart.js +341 -0
- package/dist/components/AnomalyCard/AnomalyCard.d.ts +169 -0
- package/dist/components/AnomalyCard/AnomalyCard.js +1019 -0
- package/dist/components/AnomalyCard/AnomalyCard.model.d.ts +508 -0
- package/dist/components/AnomalyCard/AnomalyCard.model.js +553 -0
- package/dist/components/AnomalyCard/index.d.ts +4 -0
- package/dist/components/AnomalyCard/index.js +4 -0
- package/dist/components/ChartCard/ChartCard.chart.d.ts +72 -0
- package/dist/components/ChartCard/ChartCard.chart.js +1333 -0
- package/dist/components/ChartCard/ChartCard.d.ts +206 -0
- package/dist/components/ChartCard/ChartCard.js +718 -0
- package/dist/components/ChartCard/ChartCard.model.d.ts +452 -0
- package/dist/components/ChartCard/ChartCard.model.js +1223 -0
- package/dist/components/ChartCard/index.d.ts +4 -0
- package/dist/components/ChartCard/index.js +4 -0
- package/dist/components/ComparisonCard/ComparisonCard.chart.d.ts +80 -0
- package/dist/components/ComparisonCard/ComparisonCard.chart.js +337 -0
- package/dist/components/ComparisonCard/ComparisonCard.d.ts +200 -0
- package/dist/components/ComparisonCard/ComparisonCard.js +1325 -0
- package/dist/components/ComparisonCard/ComparisonCard.model.d.ts +309 -0
- package/dist/components/ComparisonCard/ComparisonCard.model.js +263 -0
- package/dist/components/ComparisonCard/index.d.ts +4 -0
- package/dist/components/ComparisonCard/index.js +4 -0
- package/dist/components/ForecastCard/ForecastCard.chart.d.ts +82 -0
- package/dist/components/ForecastCard/ForecastCard.chart.js +416 -0
- package/dist/components/ForecastCard/ForecastCard.d.ts +148 -0
- package/dist/components/ForecastCard/ForecastCard.js +1029 -0
- package/dist/components/ForecastCard/ForecastCard.model.d.ts +497 -0
- package/dist/components/ForecastCard/ForecastCard.model.js +554 -0
- package/dist/components/ForecastCard/index.d.ts +4 -0
- package/dist/components/ForecastCard/index.js +4 -0
- package/dist/components/HighlightCard/HighlightCard.chart.d.ts +122 -0
- package/dist/components/HighlightCard/HighlightCard.chart.js +660 -0
- package/dist/components/HighlightCard/HighlightCard.d.ts +202 -0
- package/dist/components/HighlightCard/HighlightCard.js +1286 -0
- package/dist/components/HighlightCard/HighlightCard.model.d.ts +692 -0
- package/dist/components/HighlightCard/HighlightCard.model.js +875 -0
- package/dist/components/HighlightCard/index.d.ts +4 -0
- package/dist/components/HighlightCard/index.js +4 -0
- package/dist/components/InsightCard/InsightCard.chart.d.ts +91 -0
- package/dist/components/InsightCard/InsightCard.chart.js +471 -0
- package/dist/components/InsightCard/InsightCard.d.ts +161 -0
- package/dist/components/InsightCard/InsightCard.js +961 -0
- package/dist/components/InsightCard/InsightCard.model.d.ts +405 -0
- package/dist/components/InsightCard/InsightCard.model.js +421 -0
- package/dist/components/InsightCard/index.d.ts +4 -0
- package/dist/components/InsightCard/index.js +4 -0
- package/dist/components/MetricCard/MetricCard.chart.d.ts +79 -0
- package/dist/components/MetricCard/MetricCard.chart.js +435 -0
- package/dist/components/MetricCard/MetricCard.d.ts +227 -0
- package/dist/components/MetricCard/MetricCard.js +1293 -0
- package/dist/components/MetricCard/MetricCard.model.d.ts +521 -0
- package/dist/components/MetricCard/MetricCard.model.js +627 -0
- package/dist/components/MetricCard/index.d.ts +4 -0
- package/dist/components/MetricCard/index.js +4 -0
- package/dist/components/ProfileCard/ProfileCard.chart.d.ts +64 -0
- package/dist/components/ProfileCard/ProfileCard.chart.js +427 -0
- package/dist/components/ProfileCard/ProfileCard.d.ts +140 -0
- package/dist/components/ProfileCard/ProfileCard.js +735 -0
- package/dist/components/ProfileCard/ProfileCard.model.d.ts +279 -0
- package/dist/components/ProfileCard/ProfileCard.model.js +244 -0
- package/dist/components/ProfileCard/index.d.ts +4 -0
- package/dist/components/ProfileCard/index.js +4 -0
- package/dist/components/ProgressCard/ProgressCard.chart.d.ts +73 -0
- package/dist/components/ProgressCard/ProgressCard.chart.js +373 -0
- package/dist/components/ProgressCard/ProgressCard.d.ts +137 -0
- package/dist/components/ProgressCard/ProgressCard.js +908 -0
- package/dist/components/ProgressCard/ProgressCard.model.d.ts +385 -0
- package/dist/components/ProgressCard/ProgressCard.model.js +389 -0
- package/dist/components/ProgressCard/index.d.ts +4 -0
- package/dist/components/ProgressCard/index.js +4 -0
- package/dist/components/ReportCard/ReportCard.chart.d.ts +45 -0
- package/dist/components/ReportCard/ReportCard.chart.js +231 -0
- package/dist/components/ReportCard/ReportCard.d.ts +153 -0
- package/dist/components/ReportCard/ReportCard.js +1118 -0
- package/dist/components/ReportCard/ReportCard.model.d.ts +392 -0
- package/dist/components/ReportCard/ReportCard.model.js +399 -0
- package/dist/components/ReportCard/index.d.ts +4 -0
- package/dist/components/ReportCard/index.js +4 -0
- package/dist/components/SankeyCard/SankeyCard.chart.d.ts +75 -0
- package/dist/components/SankeyCard/SankeyCard.chart.js +249 -0
- package/dist/components/SankeyCard/SankeyCard.d.ts +185 -0
- package/dist/components/SankeyCard/SankeyCard.js +788 -0
- package/dist/components/SankeyCard/SankeyCard.model.d.ts +501 -0
- package/dist/components/SankeyCard/SankeyCard.model.js +789 -0
- package/dist/components/SankeyCard/index.d.ts +4 -0
- package/dist/components/SankeyCard/index.js +4 -0
- package/dist/components/StatusCard/StatusCard.chart.d.ts +60 -0
- package/dist/components/StatusCard/StatusCard.chart.js +188 -0
- package/dist/components/StatusCard/StatusCard.d.ts +176 -0
- package/dist/components/StatusCard/StatusCard.js +989 -0
- package/dist/components/StatusCard/StatusCard.model.d.ts +555 -0
- package/dist/components/StatusCard/StatusCard.model.js +776 -0
- package/dist/components/StatusCard/index.d.ts +4 -0
- package/dist/components/StatusCard/index.js +4 -0
- package/dist/components/TableCard/TableCard.chart.d.ts +53 -0
- package/dist/components/TableCard/TableCard.chart.js +192 -0
- package/dist/components/TableCard/TableCard.d.ts +140 -0
- package/dist/components/TableCard/TableCard.js +811 -0
- package/dist/components/TableCard/TableCard.model.d.ts +381 -0
- package/dist/components/TableCard/TableCard.model.js +475 -0
- package/dist/components/TableCard/index.d.ts +4 -0
- package/dist/components/TableCard/index.js +4 -0
- package/dist/components/TargetCard/TargetCard.chart.d.ts +52 -0
- package/dist/components/TargetCard/TargetCard.chart.js +273 -0
- package/dist/components/TargetCard/TargetCard.d.ts +143 -0
- package/dist/components/TargetCard/TargetCard.js +910 -0
- package/dist/components/TargetCard/TargetCard.model.d.ts +468 -0
- package/dist/components/TargetCard/TargetCard.model.js +581 -0
- package/dist/components/TargetCard/index.d.ts +4 -0
- package/dist/components/TargetCard/index.js +4 -0
- package/dist/components/TreeCard/TreeCard.chart.d.ts +80 -0
- package/dist/components/TreeCard/TreeCard.chart.js +178 -0
- package/dist/components/TreeCard/TreeCard.d.ts +182 -0
- package/dist/components/TreeCard/TreeCard.js +1187 -0
- package/dist/components/TreeCard/TreeCard.model.d.ts +330 -0
- package/dist/components/TreeCard/TreeCard.model.js +401 -0
- package/dist/components/TreeCard/index.d.ts +4 -0
- package/dist/components/TreeCard/index.js +4 -0
- package/dist/components/TrendCard/TrendCard.chart.d.ts +75 -0
- package/dist/components/TrendCard/TrendCard.chart.js +393 -0
- package/dist/components/TrendCard/TrendCard.d.ts +224 -0
- package/dist/components/TrendCard/TrendCard.js +1053 -0
- package/dist/components/TrendCard/TrendCard.model.d.ts +545 -0
- package/dist/components/TrendCard/TrendCard.model.js +623 -0
- package/dist/components/TrendCard/index.d.ts +4 -0
- package/dist/components/TrendCard/index.js +4 -0
- package/dist/index.d.ts +76 -0
- package/dist/index.js +57 -0
- package/dist/lib/vega/ArcVegaChart.d.ts +24 -0
- package/dist/lib/vega/ArcVegaChart.js +42 -0
- package/dist/lib/vega/ArcVegaSurface.d.ts +13 -0
- package/dist/lib/vega/ArcVegaSurface.js +38 -0
- package/dist/lib/vega/axisTicks.js +156 -0
- package/dist/lib/vega/config.d.ts +29 -0
- package/dist/lib/vega/config.js +113 -0
- package/dist/lib/vega/embed.d.ts +29 -0
- package/dist/lib/vega/embed.js +29 -0
- package/dist/lib/vega/engine.d.ts +10 -0
- package/dist/lib/vega/engine.js +6 -0
- package/dist/lib/vega/formatters.d.ts +125 -0
- package/dist/lib/vega/formatters.js +277 -0
- package/dist/lib/vega/index.d.ts +11 -0
- package/dist/lib/vega/load.d.ts +13 -0
- package/dist/lib/vega/load.js +21 -0
- package/dist/lib/vega/time.d.ts +45 -0
- package/dist/lib/vega/time.js +105 -0
- package/dist/lib/vega/tokens.d.ts +73 -0
- package/dist/lib/vega/tokens.js +137 -0
- package/dist/lib/vega/tooltip.d.ts +45 -0
- package/dist/lib/vega/tooltip.js +124 -0
- package/dist/lib/vega/useArcVega.d.ts +43 -0
- package/dist/lib/vega/useArcVega.js +121 -0
- package/package.json +60 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
import { arcVegaConfig } from "../../lib/vega/config.js";
|
|
2
|
+
//#region src/components/TargetCard/TargetCard.chart.ts
|
|
3
|
+
/** One row `{ value, zero, ratio, tone }` — the reading, drawn as the bar from zero. */
|
|
4
|
+
const TARGET_ACTUAL_DATASET = "table";
|
|
5
|
+
/** One row `{ min, max, target }` — the x domain (always spanning zero, the target and every marker) and the target's position for the label layout. */
|
|
6
|
+
const TARGET_BOUNDS_DATASET = "bounds";
|
|
7
|
+
/** One or two rows `{ value, ratio, role }` with `role` `target` or `pace` — the ticks and their words. */
|
|
8
|
+
const TARGET_MARKERS_DATASET = "markers";
|
|
9
|
+
/** Zero or one row `{ from, to, ratio, tone }` — the projected extension beyond the reading. */
|
|
10
|
+
const TARGET_PROJECTION_DATASET = "projection";
|
|
11
|
+
/** The x domain's ends, read from the `bounds` dataset. */
|
|
12
|
+
const TARGET_MIN_PARAM = "target_x_min";
|
|
13
|
+
const TARGET_MAX_PARAM = "target_x_max";
|
|
14
|
+
/** The target's value, read from the `bounds` dataset — the pace word yields to the target word when the two would collide. */
|
|
15
|
+
const TARGET_MARKER_PARAM = "target_marker";
|
|
16
|
+
const TARGET_LABEL_ROW_PX = 16;
|
|
17
|
+
const PACE_OVERSHOOT_PX = 2;
|
|
18
|
+
const TARGET_OVERSHOOT_PX = 4;
|
|
19
|
+
const LABEL_EDGE_PX = 30;
|
|
20
|
+
const LABEL_GAP_PX = 48;
|
|
21
|
+
const PROJECTION_OPACITY = .25;
|
|
22
|
+
/**
|
|
23
|
+
* A fill that follows the reading's standing through the row's `tone`: the
|
|
24
|
+
* positive hue once the target is met, the negative hue once it is missed,
|
|
25
|
+
* the emphasis hue while it is open — three token values in the spec, so the
|
|
26
|
+
* spec stays structural while the data decides.
|
|
27
|
+
*/
|
|
28
|
+
function toneColor(tokens) {
|
|
29
|
+
return {
|
|
30
|
+
condition: [{
|
|
31
|
+
test: "datum.tone === 'positive'",
|
|
32
|
+
value: tokens.divergingPositive
|
|
33
|
+
}, {
|
|
34
|
+
test: "datum.tone === 'negative'",
|
|
35
|
+
value: tokens.divergingNegative
|
|
36
|
+
}],
|
|
37
|
+
value: tokens.emphasis
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Builds the bullet graph: a muted track across the whole domain, the reading
|
|
42
|
+
* as a bar from zero (length on a shared zero-based scale — Cleveland &
|
|
43
|
+
* McGill's channel for magnitude, Wilke's proportional ink), a lighter
|
|
44
|
+
* extension to the projection, a thin gray tick where the plan expects the
|
|
45
|
+
* reading to be by now and a heavier tick at the target, each with its word
|
|
46
|
+
* underneath — the pace word yielding when the two would collide — and a
|
|
47
|
+
* tooltip on every mark. The domain is explicit (`bounds`), so a reading past
|
|
48
|
+
* its target extends the scale rather than clipping, and a negative reading
|
|
49
|
+
* grows the track to the left of zero.
|
|
50
|
+
*/
|
|
51
|
+
function buildTargetBulletSpec(options, tokens) {
|
|
52
|
+
const { barHeight, height, labels, tooltip, targetLabel, paceLabel, valueFormat, valueTitle, targetTitle, paceTitle, projectionTitle, locale } = options;
|
|
53
|
+
const thickness = Math.min(24, barHeight);
|
|
54
|
+
const rowHeight = labels ? height - 16 : height;
|
|
55
|
+
const barTop = Math.round((rowHeight - thickness) / 2);
|
|
56
|
+
const barBottom = barTop + thickness;
|
|
57
|
+
const labelY = rowHeight + 2;
|
|
58
|
+
const xScale = {
|
|
59
|
+
domain: { expr: `[${TARGET_MIN_PARAM}, ${TARGET_MAX_PARAM}]` },
|
|
60
|
+
nice: false
|
|
61
|
+
};
|
|
62
|
+
const xField = {
|
|
63
|
+
field: "value",
|
|
64
|
+
type: "quantitative",
|
|
65
|
+
axis: null,
|
|
66
|
+
scale: xScale
|
|
67
|
+
};
|
|
68
|
+
const band = {
|
|
69
|
+
y: { value: barTop },
|
|
70
|
+
y2: { value: barBottom }
|
|
71
|
+
};
|
|
72
|
+
const valueTooltip = (title) => tooltip ? { tooltip: [{
|
|
73
|
+
field: "value",
|
|
74
|
+
type: "quantitative",
|
|
75
|
+
title,
|
|
76
|
+
format: valueFormat,
|
|
77
|
+
formatType: "arcNumber"
|
|
78
|
+
}] } : {};
|
|
79
|
+
const layers = [
|
|
80
|
+
{
|
|
81
|
+
data: { name: TARGET_BOUNDS_DATASET },
|
|
82
|
+
mark: {
|
|
83
|
+
type: "rect",
|
|
84
|
+
fill: tokens.muted,
|
|
85
|
+
cornerRadius: 2,
|
|
86
|
+
aria: false
|
|
87
|
+
},
|
|
88
|
+
encoding: {
|
|
89
|
+
x: {
|
|
90
|
+
field: "min",
|
|
91
|
+
type: "quantitative",
|
|
92
|
+
axis: null,
|
|
93
|
+
scale: xScale
|
|
94
|
+
},
|
|
95
|
+
x2: { field: "max" },
|
|
96
|
+
...band
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
data: { name: TARGET_PROJECTION_DATASET },
|
|
101
|
+
mark: {
|
|
102
|
+
type: "bar",
|
|
103
|
+
orient: "horizontal",
|
|
104
|
+
cornerRadiusEnd: 2,
|
|
105
|
+
fillOpacity: PROJECTION_OPACITY,
|
|
106
|
+
aria: false
|
|
107
|
+
},
|
|
108
|
+
encoding: {
|
|
109
|
+
x: {
|
|
110
|
+
field: "from",
|
|
111
|
+
type: "quantitative",
|
|
112
|
+
axis: null,
|
|
113
|
+
scale: xScale
|
|
114
|
+
},
|
|
115
|
+
x2: { field: "to" },
|
|
116
|
+
...band,
|
|
117
|
+
fill: toneColor(tokens),
|
|
118
|
+
...tooltip ? { tooltip: [{
|
|
119
|
+
field: "to",
|
|
120
|
+
type: "quantitative",
|
|
121
|
+
title: projectionTitle,
|
|
122
|
+
format: valueFormat,
|
|
123
|
+
formatType: "arcNumber"
|
|
124
|
+
}] } : {}
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
data: { name: TARGET_ACTUAL_DATASET },
|
|
129
|
+
mark: {
|
|
130
|
+
type: "bar",
|
|
131
|
+
orient: "horizontal",
|
|
132
|
+
cornerRadiusEnd: 2,
|
|
133
|
+
aria: false
|
|
134
|
+
},
|
|
135
|
+
encoding: {
|
|
136
|
+
x: xField,
|
|
137
|
+
x2: { field: "zero" },
|
|
138
|
+
...band,
|
|
139
|
+
fill: toneColor(tokens),
|
|
140
|
+
...valueTooltip(valueTitle)
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
data: { name: TARGET_MARKERS_DATASET },
|
|
145
|
+
transform: [{ filter: "datum.role === 'pace'" }],
|
|
146
|
+
mark: {
|
|
147
|
+
type: "rule",
|
|
148
|
+
stroke: tokens.reference,
|
|
149
|
+
strokeWidth: 1.5,
|
|
150
|
+
aria: false
|
|
151
|
+
},
|
|
152
|
+
encoding: {
|
|
153
|
+
x: xField,
|
|
154
|
+
y: { value: barTop - PACE_OVERSHOOT_PX },
|
|
155
|
+
y2: { value: barBottom + PACE_OVERSHOOT_PX },
|
|
156
|
+
...valueTooltip(paceTitle)
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
data: { name: TARGET_MARKERS_DATASET },
|
|
161
|
+
transform: [{ filter: "datum.role === 'target'" }],
|
|
162
|
+
mark: {
|
|
163
|
+
type: "rule",
|
|
164
|
+
stroke: tokens.foreground,
|
|
165
|
+
strokeWidth: 2,
|
|
166
|
+
aria: false
|
|
167
|
+
},
|
|
168
|
+
encoding: {
|
|
169
|
+
x: xField,
|
|
170
|
+
y: { value: barTop - TARGET_OVERSHOOT_PX },
|
|
171
|
+
y2: { value: barBottom + TARGET_OVERSHOOT_PX },
|
|
172
|
+
...valueTooltip(targetTitle)
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
];
|
|
176
|
+
if (tooltip) layers.push({
|
|
177
|
+
data: { name: TARGET_MARKERS_DATASET },
|
|
178
|
+
mark: {
|
|
179
|
+
type: "rule",
|
|
180
|
+
strokeWidth: 12,
|
|
181
|
+
opacity: 0,
|
|
182
|
+
aria: false
|
|
183
|
+
},
|
|
184
|
+
encoding: {
|
|
185
|
+
x: xField,
|
|
186
|
+
y: { value: 0 },
|
|
187
|
+
y2: { value: rowHeight },
|
|
188
|
+
tooltip: [{
|
|
189
|
+
field: "label",
|
|
190
|
+
type: "nominal",
|
|
191
|
+
title: " "
|
|
192
|
+
}, {
|
|
193
|
+
field: "value",
|
|
194
|
+
type: "quantitative",
|
|
195
|
+
title: valueTitle,
|
|
196
|
+
format: valueFormat,
|
|
197
|
+
formatType: "arcNumber"
|
|
198
|
+
}]
|
|
199
|
+
},
|
|
200
|
+
transform: [{
|
|
201
|
+
calculate: `datum.role === 'target' ? ${JSON.stringify(targetTitle)} : ${JSON.stringify(paceTitle)}`,
|
|
202
|
+
as: "label"
|
|
203
|
+
}]
|
|
204
|
+
});
|
|
205
|
+
if (labels) layers.push({
|
|
206
|
+
data: { name: TARGET_MARKERS_DATASET },
|
|
207
|
+
transform: [{
|
|
208
|
+
calculate: `datum.role === 'target' ? ${JSON.stringify(targetLabel)} : ${JSON.stringify(paceLabel)}`,
|
|
209
|
+
as: "label"
|
|
210
|
+
}],
|
|
211
|
+
mark: {
|
|
212
|
+
type: "text",
|
|
213
|
+
baseline: "top",
|
|
214
|
+
fontSize: 11,
|
|
215
|
+
font: tokens.fontSans,
|
|
216
|
+
fill: tokens.axisLabel,
|
|
217
|
+
align: { expr: `scale('x', datum.value) > width - ${LABEL_EDGE_PX} ? 'right' : scale('x', datum.value) < ${LABEL_EDGE_PX} ? 'left' : 'center'` },
|
|
218
|
+
aria: false
|
|
219
|
+
},
|
|
220
|
+
encoding: {
|
|
221
|
+
x: xField,
|
|
222
|
+
y: { value: labelY },
|
|
223
|
+
text: {
|
|
224
|
+
field: "label",
|
|
225
|
+
type: "nominal"
|
|
226
|
+
},
|
|
227
|
+
opacity: {
|
|
228
|
+
condition: {
|
|
229
|
+
test: `datum.role === 'target' || abs(scale('x', datum.value) - scale('x', ${TARGET_MARKER_PARAM})) >= ${LABEL_GAP_PX}`,
|
|
230
|
+
value: 1
|
|
231
|
+
},
|
|
232
|
+
value: 0
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
const bounds = (field, fallback) => `length(data('${TARGET_BOUNDS_DATASET}')) ? data('${TARGET_BOUNDS_DATASET}')[0].${field} : ${fallback}`;
|
|
237
|
+
const params = [
|
|
238
|
+
{
|
|
239
|
+
name: TARGET_MIN_PARAM,
|
|
240
|
+
expr: bounds("min", 0)
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
name: TARGET_MAX_PARAM,
|
|
244
|
+
expr: bounds("max", 1)
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
name: TARGET_MARKER_PARAM,
|
|
248
|
+
expr: bounds("target", 1)
|
|
249
|
+
}
|
|
250
|
+
];
|
|
251
|
+
return {
|
|
252
|
+
$schema: "https://vega.github.io/schema/vega-lite/v6.json",
|
|
253
|
+
width: 240,
|
|
254
|
+
height,
|
|
255
|
+
autosize: {
|
|
256
|
+
type: "fit",
|
|
257
|
+
contains: "padding"
|
|
258
|
+
},
|
|
259
|
+
padding: {
|
|
260
|
+
left: 1,
|
|
261
|
+
right: 1,
|
|
262
|
+
top: 0,
|
|
263
|
+
bottom: 0
|
|
264
|
+
},
|
|
265
|
+
background: "transparent",
|
|
266
|
+
data: { name: TARGET_ACTUAL_DATASET },
|
|
267
|
+
params,
|
|
268
|
+
layer: layers,
|
|
269
|
+
config: arcVegaConfig(tokens, { locale })
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
//#endregion
|
|
273
|
+
export { TARGET_ACTUAL_DATASET, TARGET_BOUNDS_DATASET, TARGET_LABEL_ROW_PX, TARGET_MARKERS_DATASET, TARGET_MARKER_PARAM, TARGET_MAX_PARAM, TARGET_MIN_PARAM, TARGET_PROJECTION_DATASET, buildTargetBulletSpec };
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ArcTimeGranularity } from "../../lib/vega/formatters.js";
|
|
2
|
+
import { TargetCardLabels, TargetCardSize, TargetCardStatus, TargetDeltaMode, TargetGoodDirection, TargetHeadline, TargetPeriod } from "./TargetCard.model.js";
|
|
3
|
+
import { ReactNode } from "react";
|
|
4
|
+
import { BoxProps } from "@arcfusionz/arc-primitive-ui";
|
|
5
|
+
import { TopLevelSpec } from "vega-lite";
|
|
6
|
+
import { Result } from "vega-embed";
|
|
7
|
+
//#region src/components/TargetCard/TargetCard.d.ts
|
|
8
|
+
interface TargetCardProps extends Omit<BoxProps, "children" | "padding" | "title"> {
|
|
9
|
+
/** The goal's name — the tile's heading. Pass `name` too when this is not plain text. */
|
|
10
|
+
label: ReactNode;
|
|
11
|
+
/** Plain-text name used in the generated descriptions and control labels. Defaults to `label` when it is a string. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Definition of the goal, shown in a tooltip behind an info control beside the label and exposed to assistive technology as the control's description. */
|
|
14
|
+
hint?: string;
|
|
15
|
+
/** The reading so far — what has been reached, spent or counted. `null`/`undefined` renders the empty (or no-match) state. */
|
|
16
|
+
value?: number | null;
|
|
17
|
+
/**
|
|
18
|
+
* The goal. Draws the target tick and gives the reading its attainment;
|
|
19
|
+
* pass `null` while unknown to keep the frame, and the card says no target
|
|
20
|
+
* is set (`data-insufficient`) when a reading arrives without one. Zero is
|
|
21
|
+
* no target — attainment has no ratio against it.
|
|
22
|
+
*/
|
|
23
|
+
target?: number | null;
|
|
24
|
+
/**
|
|
25
|
+
* Number format for the reading, the target, the badge, the plot, the table
|
|
26
|
+
* and the tooltip — one grammar so nothing rounds two ways:
|
|
27
|
+
* `number[:digits]`, `integer`, `compact[:digits]`, `percent[:digits]`,
|
|
28
|
+
* `currency:CODE[:digits|compact]`. Default `compact` (`3.8M`).
|
|
29
|
+
*/
|
|
30
|
+
format?: string;
|
|
31
|
+
/** Custom formatter for values. Takes precedence over `format` everywhere a value is rendered. */
|
|
32
|
+
formatValue?: (value: number) => string;
|
|
33
|
+
/** Unit shown after the reading in the muted role (`signups`, `ms`). Prefer `format="currency:…"` for money. */
|
|
34
|
+
unit?: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* How the target is reached: `up` (default) — reach at least the target: a
|
|
37
|
+
* quota, a goal; `down` — stay at or under it: a budget, an error cap. It
|
|
38
|
+
* decides the badge's polarity, the pace words (`ahead of pace` / `under
|
|
39
|
+
* pace`) and when the target counts as met or missed.
|
|
40
|
+
*/
|
|
41
|
+
goodDirection?: TargetGoodDirection;
|
|
42
|
+
/**
|
|
43
|
+
* What the big number is: `attainment` (default) — the percentage of the
|
|
44
|
+
* target reached, with the reading and the target on the line below; or
|
|
45
|
+
* `value` — the reading itself, with the attainment below. Stamped as
|
|
46
|
+
* `data-headline`.
|
|
47
|
+
*/
|
|
48
|
+
headline?: TargetHeadline;
|
|
49
|
+
/**
|
|
50
|
+
* The goal period as `{ start, end, label? }`. Date-only ISO strings are
|
|
51
|
+
* inclusive calendar dates in the card's `timeZone` (`"2026-09-01"` –
|
|
52
|
+
* `"2026-09-30"` is the whole of September); `Date`s and date-times are
|
|
53
|
+
* exact instants. With `updatedAt` as "now" it gives the elapsed share, the
|
|
54
|
+
* pace marker (`target × elapsed`), the run-rate projection and the
|
|
55
|
+
* verdict; `label` names it on the period line. Pass stable values (ISO
|
|
56
|
+
* strings or memoized Dates): the period is re-resolved when they change.
|
|
57
|
+
*/
|
|
58
|
+
period?: TargetPeriod;
|
|
59
|
+
/**
|
|
60
|
+
* What the plan expects to be reached by `updatedAt`, when the plan is not a
|
|
61
|
+
* straight line — a seasonal curve, working days, a phased rollout. Replaces
|
|
62
|
+
* the linear `target × elapsed` as the pace marker and the badge's
|
|
63
|
+
* reference; `null` disables pace even with a `period`.
|
|
64
|
+
*/
|
|
65
|
+
expected?: number | null;
|
|
66
|
+
/**
|
|
67
|
+
* The product's own forecast of where the reading lands at the period's end.
|
|
68
|
+
* Replaces the linear run rate (`value / elapsed`) as the projected extension
|
|
69
|
+
* and the projection line; `null` hides the projection even with a `period`.
|
|
70
|
+
*/
|
|
71
|
+
projected?: number | null;
|
|
72
|
+
/**
|
|
73
|
+
* How far behind the plan's expectation, as a share of the target, still
|
|
74
|
+
* counts as `at-risk` rather than `off-track`. Default `0.05` — five points
|
|
75
|
+
* of the target.
|
|
76
|
+
*/
|
|
77
|
+
tolerance?: number;
|
|
78
|
+
/** `percent` (default) is the change relative to the reference — the plan's expectation, or the target; `absolute` is the difference in the value's units (percentage points for a `percent` format). */
|
|
79
|
+
deltaMode?: TargetDeltaMode;
|
|
80
|
+
/** Write the marker words (`Target`, `Pace`) under their ticks. Default `true`; `false` for a very narrow tile — the tooltip, table and description still name them. */
|
|
81
|
+
markerLabels?: boolean;
|
|
82
|
+
/** The takeaway in a sentence, rendered beside the AI mark under the plot. Wrap values in `<strong>` to set them in bold. */
|
|
83
|
+
insight?: ReactNode;
|
|
84
|
+
/** The transport's status. `loading` with data already present is a refresh: the previous render stays under the veil. Default `ready`. */
|
|
85
|
+
status?: TargetCardStatus;
|
|
86
|
+
/** The consumer's filter is active — a missing reading then reads as no-match rather than empty, with a clear-filters action when `onClearFilters` is set. */
|
|
87
|
+
filtered?: boolean;
|
|
88
|
+
/** The data is older than the product's freshness rule (TanStack Query's `isStale`). Shows a badge and stamps `data-stale`. */
|
|
89
|
+
stale?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* When the data was last true. Rendered as an "as of" line (the date by
|
|
92
|
+
* default — see `updatedAtFormat`), included in the description, and the
|
|
93
|
+
* "now" pacing is measured at — without it a `period` yields no pace, so
|
|
94
|
+
* baselines never depend on the wall clock.
|
|
95
|
+
*/
|
|
96
|
+
updatedAt?: Date | string | number;
|
|
97
|
+
/**
|
|
98
|
+
* How `updatedAt` is written, as a time-grammar granularity — `day`
|
|
99
|
+
* (default, `Sep 19, 2026`), `datetime` (`Sep 19, 2026, 04:30 PM`), `time`
|
|
100
|
+
* (`04:30 PM`), `month` (`Sep 2026`), `year` — or a formatter for a custom
|
|
101
|
+
* form. Applies to the as-of line and the description alike, in the card's
|
|
102
|
+
* `locale` and `timeZone`.
|
|
103
|
+
*/
|
|
104
|
+
updatedAtFormat?: ArcTimeGranularity | ((date: Date) => string);
|
|
105
|
+
/** Recovery action for the error state; renders a retry button when set. */
|
|
106
|
+
onRetry?: () => void;
|
|
107
|
+
/** Recovery action for the no-match state; renders a clear-filters button when set. */
|
|
108
|
+
onClearFilters?: () => void;
|
|
109
|
+
/** Density: `sm` for dense grids, `md` (default), `lg` for a hero goal. Scales type, padding, the bar thickness and the plot height. */
|
|
110
|
+
size?: TargetCardSize;
|
|
111
|
+
/** Heading level of the label for the document outline. Default 3 — tiles usually sit under a page's h2. */
|
|
112
|
+
titleLevel?: 2 | 3 | 4 | 5 | 6;
|
|
113
|
+
/** BCP 47 locale for every number and date. Defaults to the runtime's. Thai products on the Gregorian calendar pass `th-TH-u-ca-gregory`. */
|
|
114
|
+
locale?: string;
|
|
115
|
+
/** IANA time zone for the period's calendar dates and the as-of date. Defaults to the runtime's — pass it for deterministic output and single-business-zone reporting. */
|
|
116
|
+
timeZone?: string;
|
|
117
|
+
/** Overrides for every rendered or announced string. */
|
|
118
|
+
labels?: Partial<TargetCardLabels>;
|
|
119
|
+
/** Replaces the generated accessible description of the whole card (the figure's `aria-describedby` text). */
|
|
120
|
+
description?: string;
|
|
121
|
+
/** Trailing header slot — a ghost `Button` or `Menu` for drill-through, export, or settings. */
|
|
122
|
+
action?: ReactNode;
|
|
123
|
+
/** Open the details popover on first render, anchored to the card. */
|
|
124
|
+
defaultTableOpen?: boolean;
|
|
125
|
+
/** Hide the header info button for the details popover. Only when another surface exposes the same figures to keyboard and screen-reader users. */
|
|
126
|
+
hideTableToggle?: boolean;
|
|
127
|
+
/** Called with vega-embed's result once the bullet graph mounts — for `view` access in advanced compositions. */
|
|
128
|
+
onEmbed?: (result: Result) => void;
|
|
129
|
+
/** Escape hatch: transform the bullet graph spec before it renders. Voids the token and accessibility guarantees for whatever it changes. */
|
|
130
|
+
patchSpec?: (spec: TopLevelSpec) => TopLevelSpec;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A goal-tracking tile for dashboard grids: how much of a target is reached,
|
|
134
|
+
* whether the reading is ahead of or behind the plan at this point in the
|
|
135
|
+
* period, where the run rate lands, and the verdict — on a Few-style bullet
|
|
136
|
+
* graph (the reading as a bar from zero, a pace tick and a target tick, the
|
|
137
|
+
* projection as a lighter extension) with every loading, empty, error and
|
|
138
|
+
* stale state — layout-stable, with a generated text equivalent and a details
|
|
139
|
+
* table in an info popover.
|
|
140
|
+
*/
|
|
141
|
+
declare const TargetCard: import("react").ForwardRefExoticComponent<TargetCardProps & import("react").RefAttributes<HTMLElement>>;
|
|
142
|
+
//#endregion
|
|
143
|
+
export { TargetCard, TargetCardProps };
|