@dxvis/flatbi 0.1.0 → 0.2.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/cli/bin.mjs +142 -23
- package/dist/runtime/index.html +4 -4
- package/docs/recipes.md +42 -0
- package/docs/spec-reference.md +8 -1
- package/package.json +1 -1
- package/schema/dash.schema.json +36 -1
- package/skills/flatbi/SKILL.md +1 -1
package/docs/recipes.md
CHANGED
|
@@ -211,3 +211,45 @@ layout:
|
|
|
211
211
|
- [by_tier:6, by_cat:6]
|
|
212
212
|
theme: { mode: dark, accent: "#5eead4", density: compact }
|
|
213
213
|
```
|
|
214
|
+
|
|
215
|
+
## 8. Multi-model dashboard sharing a global `date_range` filter via computed `time:` aliasing
|
|
216
|
+
|
|
217
|
+
When two sources name their date columns differently (`order_date` vs `shipped_date`), alias one with a computed dimension `{ name: order_date, sql: shipped_date }` and point `time:` at it so a single global `date_range` filter reaches both models without creating an extra wrapper `sql:` source. Each model anchors relative presets (`ytd`, `last_30_days`, etc.) to its own `asOf` date (the latest date in that model's `time:` column), and `compare: previous_period` shifts the bounded window back by an equal number of days.
|
|
218
|
+
|
|
219
|
+
```yaml
|
|
220
|
+
dash: 1
|
|
221
|
+
title: Sales & fulfillment cadence
|
|
222
|
+
currency: USD
|
|
223
|
+
sources:
|
|
224
|
+
orders: { file: data/orders.csv }
|
|
225
|
+
shipments:
|
|
226
|
+
sql: |
|
|
227
|
+
SELECT order_date AS shipped_date, region, amount
|
|
228
|
+
FROM orders
|
|
229
|
+
models:
|
|
230
|
+
sales:
|
|
231
|
+
source: orders
|
|
232
|
+
time: order_date
|
|
233
|
+
dimensions: [region]
|
|
234
|
+
measures:
|
|
235
|
+
revenue: { agg: sum, sql: amount, format: currency, label: Order revenue }
|
|
236
|
+
fulfillment:
|
|
237
|
+
source: shipments
|
|
238
|
+
time: order_date
|
|
239
|
+
dimensions:
|
|
240
|
+
- { name: order_date, sql: shipped_date }
|
|
241
|
+
- region
|
|
242
|
+
measures:
|
|
243
|
+
shipped_revenue: { agg: sum, sql: amount, format: currency, label: Shipped revenue }
|
|
244
|
+
filters:
|
|
245
|
+
- { field: order_date, type: date_range, default: last_7_days }
|
|
246
|
+
- { field: region, type: multi_select }
|
|
247
|
+
tiles:
|
|
248
|
+
sales_rev: { type: kpi, model: sales, value: revenue, compare: previous_period }
|
|
249
|
+
shipped_rev: { type: kpi, model: fulfillment, value: shipped_revenue, compare: previous_period }
|
|
250
|
+
sales_by_region: { type: bar, model: sales, x: region, y: revenue }
|
|
251
|
+
shipped_by_region: { type: bar, model: fulfillment, x: region, y: shipped_revenue }
|
|
252
|
+
layout:
|
|
253
|
+
- [sales_rev:6, shipped_rev:6]
|
|
254
|
+
- [sales_by_region:6, shipped_by_region:6]
|
|
255
|
+
```
|
package/docs/spec-reference.md
CHANGED
|
@@ -54,7 +54,7 @@ A named, flat table built from one source.
|
|
|
54
54
|
| Key | Type | Required | Description |
|
|
55
55
|
|---|---|---|---|
|
|
56
56
|
| `source` | string | yes | The source the model reads. |
|
|
57
|
-
| `time` | string | no | The model's main date dimension, enabling time grains, date-range filters and KPI comparisons. |
|
|
57
|
+
| `time` | string | no | The model's main date dimension (a source column or a computed `{ name, sql }` dimension), enabling time grains, date-range filters and KPI comparisons. |
|
|
58
58
|
| `dimensions` | list of items of several kinds (see below) | no | Dimensions of the model that tiles and filters may group or filter by. |
|
|
59
59
|
| `measures` | mapping of IDs (see below) | no | The model's measures, by measure ID. |
|
|
60
60
|
|
|
@@ -93,6 +93,7 @@ The total of an expression over the rows.
|
|
|
93
93
|
| `agg` | `sum` | yes | The aggregation, which selects this kind of measure. |
|
|
94
94
|
| `sql` | string | yes | Row-level DuckDB expression to add up, such as a column. |
|
|
95
95
|
| `where` | string | no | Row-level DuckDB predicate, such as `status = 'paid'`. Only rows where it is true count toward the measure. |
|
|
96
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
96
97
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
97
98
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
98
99
|
|
|
@@ -105,6 +106,7 @@ The number of rows.
|
|
|
105
106
|
| `agg` | `count` | yes | The aggregation, which selects this kind of measure. |
|
|
106
107
|
| `sql` | string | no | Row-level DuckDB expression. When set, only rows where it is not null count. |
|
|
107
108
|
| `where` | string | no | Row-level DuckDB predicate, such as `status = 'paid'`. Only rows where it is true count toward the measure. |
|
|
109
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
108
110
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
109
111
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
110
112
|
|
|
@@ -117,6 +119,7 @@ The number of distinct values of an expression, not counting missing ones.
|
|
|
117
119
|
| `agg` | `count_distinct` | yes | The aggregation, which selects this kind of measure. |
|
|
118
120
|
| `sql` | string | yes | Row-level DuckDB expression whose distinct values are counted, such as an ID. |
|
|
119
121
|
| `where` | string | no | Row-level DuckDB predicate, such as `status = 'paid'`. Only rows where it is true count toward the measure. |
|
|
122
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
120
123
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
121
124
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
122
125
|
|
|
@@ -129,6 +132,7 @@ The smallest value of an expression over the rows.
|
|
|
129
132
|
| `agg` | `min` | yes | The aggregation, which selects this kind of measure. |
|
|
130
133
|
| `sql` | string | yes | Row-level DuckDB expression, such as a column. |
|
|
131
134
|
| `where` | string | no | Row-level DuckDB predicate, such as `status = 'paid'`. Only rows where it is true count toward the measure. |
|
|
135
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
132
136
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
133
137
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
134
138
|
|
|
@@ -141,6 +145,7 @@ The largest value of an expression over the rows.
|
|
|
141
145
|
| `agg` | `max` | yes | The aggregation, which selects this kind of measure. |
|
|
142
146
|
| `sql` | string | yes | Row-level DuckDB expression, such as a column. |
|
|
143
147
|
| `where` | string | no | Row-level DuckDB predicate, such as `status = 'paid'`. Only rows where it is true count toward the measure. |
|
|
148
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
144
149
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
145
150
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
146
151
|
|
|
@@ -153,6 +158,7 @@ The average of an expression over the rows where it has a value.
|
|
|
153
158
|
| `agg` | `avg` | yes | The aggregation, which selects this kind of measure. |
|
|
154
159
|
| `sql` | string | yes | Row-level DuckDB expression to average, such as a column. |
|
|
155
160
|
| `where` | string | no | Row-level DuckDB predicate, such as `status = 'paid'`. Only rows where it is true count toward the measure. |
|
|
161
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
156
162
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
157
163
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
158
164
|
|
|
@@ -163,6 +169,7 @@ A ratio or other arithmetic over measures, computed after they aggregate, so it
|
|
|
163
169
|
| Key | Type | Required | Description |
|
|
164
170
|
|---|---|---|---|
|
|
165
171
|
| `formula` | string | yes | Arithmetic over other measures of the model: `+ - * /`, parentheses and numbers, such as `revenue / orders`. |
|
|
172
|
+
| `label` | string | no | Display name shown in chart legends, tooltips, table headers and default tile titles. |
|
|
166
173
|
| `format` | `integer` or `number` or `percent` or `currency` or `compact` | no | How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`. |
|
|
167
174
|
| `decimals` | number | no | Number of decimal places to show (0 to 20). |
|
|
168
175
|
|
package/package.json
CHANGED
package/schema/dash.schema.json
CHANGED
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"time": {
|
|
104
104
|
"type": "string",
|
|
105
105
|
"minLength": 1,
|
|
106
|
-
"description": "The model's main date dimension, enabling time grains, date-range filters and KPI comparisons."
|
|
106
|
+
"description": "The model's main date dimension (a source column or a computed `{ name, sql }` dimension), enabling time grains, date-range filters and KPI comparisons."
|
|
107
107
|
},
|
|
108
108
|
"dimensions": {
|
|
109
109
|
"description": "Dimensions of the model that tiles and filters may group or filter by.",
|
|
@@ -184,6 +184,11 @@
|
|
|
184
184
|
"type": "string",
|
|
185
185
|
"minLength": 1
|
|
186
186
|
},
|
|
187
|
+
"label": {
|
|
188
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
189
|
+
"type": "string",
|
|
190
|
+
"minLength": 1
|
|
191
|
+
},
|
|
187
192
|
"format": {
|
|
188
193
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
189
194
|
"type": "string",
|
|
@@ -227,6 +232,11 @@
|
|
|
227
232
|
"type": "string",
|
|
228
233
|
"minLength": 1
|
|
229
234
|
},
|
|
235
|
+
"label": {
|
|
236
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
237
|
+
"type": "string",
|
|
238
|
+
"minLength": 1
|
|
239
|
+
},
|
|
230
240
|
"format": {
|
|
231
241
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
232
242
|
"type": "string",
|
|
@@ -269,6 +279,11 @@
|
|
|
269
279
|
"type": "string",
|
|
270
280
|
"minLength": 1
|
|
271
281
|
},
|
|
282
|
+
"label": {
|
|
283
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
284
|
+
"type": "string",
|
|
285
|
+
"minLength": 1
|
|
286
|
+
},
|
|
272
287
|
"format": {
|
|
273
288
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
274
289
|
"type": "string",
|
|
@@ -312,6 +327,11 @@
|
|
|
312
327
|
"type": "string",
|
|
313
328
|
"minLength": 1
|
|
314
329
|
},
|
|
330
|
+
"label": {
|
|
331
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
332
|
+
"type": "string",
|
|
333
|
+
"minLength": 1
|
|
334
|
+
},
|
|
315
335
|
"format": {
|
|
316
336
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
317
337
|
"type": "string",
|
|
@@ -355,6 +375,11 @@
|
|
|
355
375
|
"type": "string",
|
|
356
376
|
"minLength": 1
|
|
357
377
|
},
|
|
378
|
+
"label": {
|
|
379
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
380
|
+
"type": "string",
|
|
381
|
+
"minLength": 1
|
|
382
|
+
},
|
|
358
383
|
"format": {
|
|
359
384
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
360
385
|
"type": "string",
|
|
@@ -398,6 +423,11 @@
|
|
|
398
423
|
"type": "string",
|
|
399
424
|
"minLength": 1
|
|
400
425
|
},
|
|
426
|
+
"label": {
|
|
427
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
428
|
+
"type": "string",
|
|
429
|
+
"minLength": 1
|
|
430
|
+
},
|
|
401
431
|
"format": {
|
|
402
432
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
403
433
|
"type": "string",
|
|
@@ -431,6 +461,11 @@
|
|
|
431
461
|
"minLength": 1,
|
|
432
462
|
"description": "Arithmetic over other measures of the model: `+ - * /`, parentheses and numbers, such as `revenue / orders`."
|
|
433
463
|
},
|
|
464
|
+
"label": {
|
|
465
|
+
"description": "Display name shown in chart legends, tooltips, table headers and default tile titles.",
|
|
466
|
+
"type": "string",
|
|
467
|
+
"minLength": 1
|
|
468
|
+
},
|
|
434
469
|
"format": {
|
|
435
470
|
"description": "How the measure's numbers display: `integer`, `number`, `percent`, `currency` or `compact`.",
|
|
436
471
|
"type": "string",
|
package/skills/flatbi/SKILL.md
CHANGED
|
@@ -15,7 +15,7 @@ Follow these five steps in order:
|
|
|
15
15
|
2. **Write the spec** — Create or update `*.dash.yaml` starting with `dash: 1`, defining `sources`, `models` (dimensions, time field, measures, formulas), `filters`, `tiles`, and 12-column `layout`. Use the exact column names returned by `inspect`. Only dimensions, filters, and fields shown by tiles enter the embedded slim table, and `count_distinct` stores rank keys rather than raw IDs or emails.
|
|
16
16
|
3. **Check until clean** — Run `flatbi check` on the spec. Each finding reports `file:line:col CODE message` with allowed values and nearest-match suggestions. Resolve every finding until `check` reports zero errors and zero actionable warnings.
|
|
17
17
|
4. **Render** — Run `flatbi render` on the spec to capture a full-page PNG screenshot and evaluate visual findings (`text-clipped`, `legend-overflow`, `too-many-categories`, `low-contrast`, `tiny-text`). Optionally run `npx impeccable detect` on the built HTML for an extra polish check when available. Run `flatbi build` to write the shareable offline HTML file.
|
|
18
|
-
5. **Look** — Open and visually inspect the rendered PNG image directly to verify layout hierarchy, label spacing,
|
|
18
|
+
5. **Look** — Open and visually inspect the rendered PNG image directly to verify layout hierarchy, label spacing, chart legibility, and that every tile displays meaningful data. Adjust the spec (such as widening a span or adding a limit) and repeat `check` and `render` if anything looks cramped or unclear.
|
|
19
19
|
|
|
20
20
|
## Operate-mode dashboard guidance
|
|
21
21
|
|