@dxvis/flatbi 0.0.0-stage → 0.1.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/.claude-plugin/marketplace.json +21 -0
- package/.claude-plugin/plugin.json +13 -0
- package/LICENSE +21 -0
- package/README.md +96 -2
- package/dist/cli/bin.mjs +7553 -0
- package/dist/runtime/index.html +43 -0
- package/docs/recipes.md +213 -0
- package/docs/spec-reference.md +640 -0
- package/docs/tile-guide.md +25 -0
- package/llms.txt +55 -0
- package/package.json +66 -4
- package/schema/dash.schema.json +1784 -0
- package/skills/flatbi/SKILL.md +40 -0
package/docs/recipes.md
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# Copy-paste recipes
|
|
2
|
+
|
|
3
|
+
Every recipe below is a complete, valid `*.dash.yaml` spec targeting [`examples/data/orders.csv`](../examples/data/orders.csv) (run `flatbi check` on any of them with zero findings). Copy the section you need and replace field names with the columns from `flatbi inspect`.
|
|
4
|
+
|
|
5
|
+
## 1. Executive KPIs with period comparison, target, and sparkline
|
|
6
|
+
|
|
7
|
+
Pair `compare: previous_period` with a bounded `date_range` default (relative to the data's `asOf` date) so both the current window and the prior window contain rows.
|
|
8
|
+
|
|
9
|
+
```yaml
|
|
10
|
+
dash: 1
|
|
11
|
+
title: Executive KPIs
|
|
12
|
+
currency: USD
|
|
13
|
+
sources:
|
|
14
|
+
orders: { file: data/orders.csv }
|
|
15
|
+
models:
|
|
16
|
+
sales:
|
|
17
|
+
source: orders
|
|
18
|
+
time: order_date
|
|
19
|
+
dimensions: [region, category]
|
|
20
|
+
measures:
|
|
21
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
22
|
+
target_rev: { agg: sum, sql: "amount * 0.9", format: currency }
|
|
23
|
+
orders: { agg: count, format: integer }
|
|
24
|
+
aov: { formula: revenue / orders, format: currency }
|
|
25
|
+
filters:
|
|
26
|
+
- { field: order_date, type: date_range, default: last_7_days }
|
|
27
|
+
tiles:
|
|
28
|
+
revenue: { type: kpi, value: revenue, compare: previous_period, spark: true }
|
|
29
|
+
vs_target: { type: kpi, value: revenue, target: target_rev, good: up, title: Revenue vs target }
|
|
30
|
+
aov: { type: kpi, value: aov, compare: previous_period }
|
|
31
|
+
layout:
|
|
32
|
+
- [revenue:4, vs_target:4, aov:4]
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## 2. Time-series `line` and stacked `area` trends
|
|
36
|
+
|
|
37
|
+
Use `@day`, `@week`, `@month`, `@quarter`, or `@year` on a date field. Missing periods render as gaps on `line` and `area` tiles.
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
dash: 1
|
|
41
|
+
title: Revenue trends
|
|
42
|
+
currency: USD
|
|
43
|
+
sources:
|
|
44
|
+
orders: { file: data/orders.csv }
|
|
45
|
+
models:
|
|
46
|
+
sales:
|
|
47
|
+
source: orders
|
|
48
|
+
time: order_date
|
|
49
|
+
dimensions: [region]
|
|
50
|
+
measures:
|
|
51
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
52
|
+
units: { agg: sum, sql: quantity, format: integer }
|
|
53
|
+
tiles:
|
|
54
|
+
daily_rev: { type: line, x: order_date@day, y: revenue, color: region }
|
|
55
|
+
daily_units: { type: area, x: order_date@day, y: units, color: region, stack: normal }
|
|
56
|
+
layout:
|
|
57
|
+
- [daily_rev]
|
|
58
|
+
- [daily_units]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 3. Bar variants: horizontal, multi-measure, percent-stacked, `limit`, and per-tile `where`
|
|
62
|
+
|
|
63
|
+
```yaml
|
|
64
|
+
dash: 1
|
|
65
|
+
title: Category and region breakdown
|
|
66
|
+
currency: USD
|
|
67
|
+
sources:
|
|
68
|
+
orders: { file: data/orders.csv }
|
|
69
|
+
models:
|
|
70
|
+
sales:
|
|
71
|
+
source: orders
|
|
72
|
+
dimensions: [region, category]
|
|
73
|
+
measures:
|
|
74
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
75
|
+
units: { agg: sum, sql: quantity, format: integer }
|
|
76
|
+
orders: { agg: count, format: integer }
|
|
77
|
+
tiles:
|
|
78
|
+
top_regions: { type: bar, x: region, y: revenue, horizontal: true, limit: 3 }
|
|
79
|
+
cat_mix: { type: bar, x: region, y: revenue, color: category, stack: percent }
|
|
80
|
+
tech_only:
|
|
81
|
+
type: bar
|
|
82
|
+
title: Technology revenue by region
|
|
83
|
+
x: region
|
|
84
|
+
y: [revenue, units]
|
|
85
|
+
where: { category: Technology }
|
|
86
|
+
sort: -revenue
|
|
87
|
+
layout:
|
|
88
|
+
- [top_regions:6, cat_mix:6]
|
|
89
|
+
- [tech_only]
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## 4. `combo` (bar + line) and `scatter` relationship tiles
|
|
93
|
+
|
|
94
|
+
```yaml
|
|
95
|
+
dash: 1
|
|
96
|
+
title: Volume, ticket size, and regional scatter
|
|
97
|
+
currency: USD
|
|
98
|
+
sources:
|
|
99
|
+
orders: { file: data/orders.csv }
|
|
100
|
+
models:
|
|
101
|
+
sales:
|
|
102
|
+
source: orders
|
|
103
|
+
time: order_date
|
|
104
|
+
dimensions: [region]
|
|
105
|
+
measures:
|
|
106
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
107
|
+
orders: { agg: count, format: integer }
|
|
108
|
+
units: { agg: sum, sql: quantity, format: integer }
|
|
109
|
+
aov: { formula: revenue / orders, format: currency }
|
|
110
|
+
tiles:
|
|
111
|
+
rev_and_aov: { type: combo, x: order_date@day, y: revenue, y2: aov }
|
|
112
|
+
region_plot: { type: scatter, by: region, x: orders, y: revenue, size: units, color: region }
|
|
113
|
+
layout:
|
|
114
|
+
- [rev_and_aov:7, region_plot:5]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## 5. Part-to-whole `donut` and two-dimensional `heatmap`
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
dash: 1
|
|
121
|
+
title: Mix and regional heatmap
|
|
122
|
+
currency: USD
|
|
123
|
+
sources:
|
|
124
|
+
orders: { file: data/orders.csv }
|
|
125
|
+
models:
|
|
126
|
+
sales:
|
|
127
|
+
source: orders
|
|
128
|
+
dimensions: [region, category]
|
|
129
|
+
measures:
|
|
130
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
131
|
+
tiles:
|
|
132
|
+
by_category: { type: donut, by: category, value: revenue }
|
|
133
|
+
matrix: { type: heatmap, x: region, y: category, color: revenue }
|
|
134
|
+
layout:
|
|
135
|
+
- [by_category:5, matrix:7]
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## 6. Interactive `table` (inline bars & conditional colour) and `text` caveats
|
|
139
|
+
|
|
140
|
+
```yaml
|
|
141
|
+
dash: 1
|
|
142
|
+
title: Order detail and methodology
|
|
143
|
+
currency: USD
|
|
144
|
+
sources:
|
|
145
|
+
orders: { file: data/orders.csv }
|
|
146
|
+
models:
|
|
147
|
+
sales:
|
|
148
|
+
source: orders
|
|
149
|
+
dimensions: [region, category]
|
|
150
|
+
measures:
|
|
151
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
152
|
+
orders: { agg: count, format: integer }
|
|
153
|
+
aov: { formula: revenue / orders, format: currency }
|
|
154
|
+
tiles:
|
|
155
|
+
breakdown:
|
|
156
|
+
type: table
|
|
157
|
+
columns:
|
|
158
|
+
- region
|
|
159
|
+
- category
|
|
160
|
+
- { field: revenue, bar: true }
|
|
161
|
+
- { field: orders, color: scale }
|
|
162
|
+
- { field: aov, color: positive }
|
|
163
|
+
sort: -revenue
|
|
164
|
+
limit: 20
|
|
165
|
+
notes:
|
|
166
|
+
type: text
|
|
167
|
+
title: Methodology
|
|
168
|
+
size: s
|
|
169
|
+
md: |
|
|
170
|
+
Totals reflect gross order revenue across all regions.
|
|
171
|
+
Click any row in **Breakdown** to cross-filter by region and category.
|
|
172
|
+
layout:
|
|
173
|
+
- [breakdown:8, notes:4]
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## 7. Computed & ordered dimensions, filters, `sql:` source, and dark compact theme
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
dash: 1
|
|
180
|
+
title: Enriched orders (dark compact)
|
|
181
|
+
locale: en-US
|
|
182
|
+
currency: USD
|
|
183
|
+
sources:
|
|
184
|
+
raw_orders: { file: data/orders.csv }
|
|
185
|
+
enriched_orders:
|
|
186
|
+
sql: |
|
|
187
|
+
SELECT *, amount / quantity AS unit_price
|
|
188
|
+
FROM raw_orders
|
|
189
|
+
WHERE amount > 0
|
|
190
|
+
models:
|
|
191
|
+
sales:
|
|
192
|
+
source: enriched_orders
|
|
193
|
+
time: order_date
|
|
194
|
+
dimensions:
|
|
195
|
+
- region
|
|
196
|
+
- category
|
|
197
|
+
- { name: basket_tier, sql: "CASE WHEN amount >= 500 THEN 'Large' WHEN amount >= 150 THEN 'Medium' ELSE 'Small' END", order: [Small, Medium, Large] }
|
|
198
|
+
measures:
|
|
199
|
+
revenue: { agg: sum, sql: amount, format: currency }
|
|
200
|
+
avg_unit_price: { agg: avg, sql: unit_price, format: currency }
|
|
201
|
+
filters:
|
|
202
|
+
- { field: order_date, type: date_range, default: all }
|
|
203
|
+
- { field: region, type: select }
|
|
204
|
+
- { field: category, type: multi_select }
|
|
205
|
+
tiles:
|
|
206
|
+
revenue: { type: kpi, value: revenue, size: s }
|
|
207
|
+
by_tier: { type: bar, x: basket_tier, y: revenue, size: m }
|
|
208
|
+
by_cat: { type: bar, x: category, y: avg_unit_price, size: m }
|
|
209
|
+
layout:
|
|
210
|
+
- [revenue]
|
|
211
|
+
- [by_tier:6, by_cat:6]
|
|
212
|
+
theme: { mode: dark, accent: "#5eead4", density: compact }
|
|
213
|
+
```
|