@graphenedata/cli 0.0.15 → 0.0.17
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/README.md +174 -0
- package/dist/cli/bigQuery-OQUNH3VT.js +75 -0
- package/dist/cli/bigQuery-OQUNH3VT.js.map +7 -0
- package/dist/cli/chunk-56K2FF57.js +53 -0
- package/dist/cli/chunk-56K2FF57.js.map +7 -0
- package/dist/cli/chunk-TZTTALAV.js +12868 -0
- package/dist/cli/chunk-TZTTALAV.js.map +7 -0
- package/dist/cli/cli.js +260 -11196
- package/dist/cli/clickhouse-S3BJSKND.js +65 -0
- package/dist/cli/clickhouse-S3BJSKND.js.map +7 -0
- package/dist/cli/duckdb-TKVMONRK.js +87 -0
- package/dist/cli/duckdb-TKVMONRK.js.map +7 -0
- package/dist/cli/serve2-S2LL4D4D.js +448 -0
- package/dist/cli/serve2-S2LL4D4D.js.map +7 -0
- package/dist/cli/snowflake-3VPDEYYP.js +128 -0
- package/dist/cli/snowflake-3VPDEYYP.js.map +7 -0
- package/dist/index.d.ts +63 -0
- package/dist/lang/index.d.ts +63 -0
- package/dist/skills/graphene/SKILL.md +156 -95
- package/dist/skills/graphene/references/big-value.md +6 -41
- package/dist/skills/graphene/references/date-range.md +64 -0
- package/dist/skills/graphene/references/dropdown.md +3 -4
- package/dist/skills/graphene/references/echarts.md +162 -0
- package/dist/skills/graphene/references/gsql.md +55 -25
- package/dist/skills/graphene/references/model-gsql.md +70 -0
- package/dist/skills/graphene/references/table.md +13 -14
- package/dist/skills/graphene/references/text-input.md +2 -1
- package/dist/ui/app.css +239 -340
- package/dist/ui/component-utilities/dataShaping.ts +484 -0
- package/dist/ui/component-utilities/dataSummary.ts +57 -0
- package/dist/ui/component-utilities/enrich.ts +793 -0
- package/dist/ui/component-utilities/format.ts +177 -0
- package/dist/ui/component-utilities/inputUtils.ts +44 -8
- package/dist/ui/component-utilities/theme.ts +200 -0
- package/dist/ui/component-utilities/themeStores.ts +21 -8
- package/dist/ui/component-utilities/types.ts +70 -0
- package/dist/ui/components/AreaChart.svelte +57 -105
- package/dist/ui/components/BarChart.svelte +71 -129
- package/dist/ui/components/BigValue.svelte +24 -40
- package/dist/ui/components/Column.svelte +10 -18
- package/dist/ui/components/DateRange.svelte +54 -21
- package/dist/ui/components/Dropdown.svelte +47 -26
- package/dist/ui/components/DropdownOption.svelte +1 -2
- package/dist/ui/components/ECharts.svelte +181 -67
- package/dist/ui/components/InlineDelta.svelte +50 -31
- package/dist/ui/components/LineChart.svelte +54 -125
- package/dist/ui/components/PieChart.svelte +27 -37
- package/dist/ui/components/QueryLoad.svelte +77 -45
- package/dist/ui/components/Row.svelte +2 -1
- package/dist/ui/components/ScatterPlot.svelte +52 -0
- package/dist/ui/components/Skeleton.svelte +32 -0
- package/dist/ui/components/Table.svelte +3 -2
- package/dist/ui/components/TableGroupRow.svelte +28 -36
- package/dist/ui/components/TableHarness.svelte +32 -0
- package/dist/ui/components/TableHeader.svelte +34 -59
- package/dist/ui/components/TableRow.svelte +14 -38
- package/dist/ui/components/TableSubtotalRow.svelte +18 -21
- package/dist/ui/components/TableTotalRow.svelte +27 -37
- package/dist/ui/components/TextInput.svelte +13 -12
- package/dist/ui/components/Value.svelte +25 -0
- package/dist/ui/components/_Table.svelte +72 -70
- package/dist/ui/internal/ChartGallery.svelte +527 -0
- package/dist/ui/internal/ErrorDisplay.svelte +22 -97
- package/dist/ui/internal/LocalApp.svelte +84 -19
- package/dist/ui/internal/PageNavGroup.svelte +269 -0
- package/dist/ui/internal/Sidebar.svelte +178 -0
- package/dist/ui/internal/SidebarToggle.svelte +47 -0
- package/dist/ui/internal/StyleGallery.svelte +244 -0
- package/dist/ui/internal/clientCache.ts +2 -2
- package/dist/ui/internal/pageInputs.svelte.js +292 -0
- package/dist/ui/internal/queryEngine.ts +112 -129
- package/dist/ui/internal/runSocket.ts +31 -14
- package/dist/ui/internal/sidebar.svelte.js +18 -0
- package/dist/ui/internal/telemetry.ts +51 -16
- package/dist/ui/internal/types.d.ts +7 -0
- package/dist/ui/web.js +30 -11
- package/package.json +40 -38
- package/dist/skills/graphene/references/area-chart.md +0 -95
- package/dist/skills/graphene/references/bar-chart.md +0 -112
- package/dist/skills/graphene/references/line-chart.md +0 -108
- package/dist/skills/graphene/references/pie-chart.md +0 -29
- package/dist/skills/graphene/references/value-formats.md +0 -104
- package/dist/ui/component-utilities/autoFormatting.js +0 -280
- package/dist/ui/component-utilities/builtInFormats.js +0 -481
- package/dist/ui/component-utilities/chartContext.js +0 -12
- package/dist/ui/component-utilities/chartWindowDebug.js +0 -21
- package/dist/ui/component-utilities/checkInputs.js +0 -84
- package/dist/ui/component-utilities/convert.js +0 -15
- package/dist/ui/component-utilities/dateParsing.js +0 -56
- package/dist/ui/component-utilities/dropdownContext.ts +0 -1
- package/dist/ui/component-utilities/echarts.js +0 -252
- package/dist/ui/component-utilities/echartsThemes.js +0 -443
- package/dist/ui/component-utilities/formatTitle.js +0 -24
- package/dist/ui/component-utilities/formatting.js +0 -241
- package/dist/ui/component-utilities/getColumnExtents.js +0 -79
- package/dist/ui/component-utilities/getColumnSummary.js +0 -62
- package/dist/ui/component-utilities/getCompletedData.js +0 -122
- package/dist/ui/component-utilities/getDistinctCount.js +0 -7
- package/dist/ui/component-utilities/getDistinctValues.js +0 -15
- package/dist/ui/component-utilities/getSeriesConfig.js +0 -231
- package/dist/ui/component-utilities/getSortedData.js +0 -9
- package/dist/ui/component-utilities/getStackPercentages.js +0 -45
- package/dist/ui/component-utilities/getStackedData.js +0 -19
- package/dist/ui/component-utilities/getYAxisIndex.js +0 -15
- package/dist/ui/component-utilities/globalContexts.js +0 -1
- package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +0 -119
- package/dist/ui/component-utilities/replaceNulls.js +0 -16
- package/dist/ui/component-utilities/tableUtils.ts +0 -107
- package/dist/ui/component-utilities/tidyWithTypes.js +0 -9
- package/dist/ui/components/Area.svelte +0 -214
- package/dist/ui/components/Bar.svelte +0 -347
- package/dist/ui/components/Chart.svelte +0 -995
- package/dist/ui/components/Line.svelte +0 -227
- package/dist/ui/internal/NavSidebar.svelte +0 -396
- package/dist/ui/internal/theme.ts +0 -60
- package/dist/ui/public/inter-latin-ext.woff2 +0 -0
- package/dist/ui/public/inter-latin.woff2 +0 -0
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
|
|
2
1
|
---
|
|
3
2
|
name: graphene
|
|
4
3
|
description: How to use Graphene, our framework for data modeling, analysis, and visualization.
|
|
4
|
+
allowed-tools: Bash(npx graphene:*) Bash(pnpm graphene:*) Bash(yarn graphene:*) Bash(bun run graphene:*)
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
-
Graphene is a framework for doing data analysis and BI as code. Schema definitions and semantic models are in `.gsql` files, dashboards in `.md`.
|
|
7
|
+
Graphene is a framework for doing data analysis and BI as code. Schema definitions and semantic models are in `.gsql` files, dashboards/notebooks (called pages) in `.md`.
|
|
8
8
|
|
|
9
9
|
# GSQL
|
|
10
10
|
GSQL extends ANSI SQL with dimensions, measures, and join relationships. Declare them in `table` statements:
|
|
11
11
|
|
|
12
12
|
```sql
|
|
13
13
|
table orders (
|
|
14
|
-
id
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
id bigint
|
|
15
|
+
created_at datetime
|
|
16
|
+
user_id bigint
|
|
17
|
+
amount float #units=usd
|
|
18
|
+
status string
|
|
18
19
|
join one users on user_id = users.id -- many orders per user
|
|
19
20
|
is_complete: status = 'Complete' -- dimension (scalar expression)
|
|
20
|
-
revenue: sum(amount) -- measure (agg expression)
|
|
21
|
-
avg_order: revenue / count(*) -- measures can compose
|
|
21
|
+
revenue: sum(amount) -- measure (agg expression) #units=usd
|
|
22
|
+
avg_order: revenue / count(*) -- measures can compose #units=usd
|
|
22
23
|
)
|
|
23
24
|
table users (
|
|
24
|
-
id
|
|
25
|
-
name
|
|
25
|
+
id bigint
|
|
26
|
+
name varchar
|
|
26
27
|
join many orders on id = orders.user_id
|
|
27
28
|
)
|
|
28
29
|
```
|
|
@@ -43,139 +44,199 @@ Dimensions and measures are like macros that expand inline when GSQL compiles to
|
|
|
43
44
|
- OK: `floor(revenue)`, `revenue / cost`
|
|
44
45
|
- OK: `sum(case when is_complete then 1 else 0 end)` or `group by is_complete` (because `is_complete` is a dimension, not a measure)
|
|
45
46
|
|
|
47
|
+
### Arrays
|
|
48
|
+
- Array columns and casts use `array<T>` syntax in GSQL, for example `tags array<string>` or `cast(tags as array<string>)`
|
|
49
|
+
- Arrays can be expanded in queries with `cross join unnest(tags) as tag`
|
|
50
|
+
|
|
46
51
|
### Special features
|
|
47
52
|
- `group by all` is implied when aggregates exist, and does not need to be put in GSQL
|
|
48
53
|
- Agg function `pXX(column)` computes the XXth percentile (e.g., p50, p975, p9999)
|
|
54
|
+
- `select`, `from`, `order by`, etc. in any order
|
|
49
55
|
|
|
50
|
-
###
|
|
51
|
-
-
|
|
52
|
-
-
|
|
56
|
+
### Supported
|
|
57
|
+
- All scalar, agg, and window functions of the connected database
|
|
58
|
+
- ANSI joins, CTEs, subqueries, set operations
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
### Not supported
|
|
61
|
+
- Table functions
|
|
62
|
+
- UDFs
|
|
63
|
+
- `pivot`, `lateral`
|
|
64
|
+
- `variant`, `object`, `record` types
|
|
65
|
+
|
|
66
|
+
# Pages
|
|
67
|
+
Graphene pages extend Markdown with the following:
|
|
56
68
|
- GSQL queries in code fences
|
|
57
|
-
- Visualization
|
|
69
|
+
- Visualization and input components
|
|
58
70
|
|
|
59
71
|
````md
|
|
60
|
-
|
|
61
|
-
|
|
72
|
+
---
|
|
73
|
+
title: My First Dashboard
|
|
74
|
+
layout: dashboard
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
```sql sales_by_status
|
|
78
|
+
select extract(year from created_at) AS year, status, revenue
|
|
79
|
+
from orders
|
|
80
|
+
where status <> 'cancelled'
|
|
62
81
|
```
|
|
63
|
-
|
|
64
|
-
<BigValue data="
|
|
82
|
+
|
|
83
|
+
<BigValue data="orders" value="revenue" />
|
|
84
|
+
<BarChart data="sales_by_status" x="year" y="revenue" splitBy="status"/>
|
|
65
85
|
````
|
|
66
86
|
|
|
67
|
-
Queries can be referenced by other queries in the `from` or `join` to form DAGs of data
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- Row
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
-
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
87
|
+
Queries can be referenced by other queries in the `from` or `join` to form DAGs of data logic within the page.
|
|
88
|
+
|
|
89
|
+
## Page frontmatter
|
|
90
|
+
You can add YAML frontmatter at the top of a page. The following attributes are supported:
|
|
91
|
+
- `title`: title displayed at the top of the page
|
|
92
|
+
- `layout`: `notebook` is the default, good for prose interspersed with charts. `dashboard` has a wider max-width, for chart-heavy pages with lots of `<Row>`s.
|
|
93
|
+
|
|
94
|
+
## Viz and display components
|
|
95
|
+
- LineChart: title, data, x, y, y2, splitBy, sort, height, width
|
|
96
|
+
- AreaChart: title, data, x, y, y2, splitBy, arrange (`stack` (default) or `stack100`), sort, height, width
|
|
97
|
+
- BarChart: title, data, x, y, y2, splitBy, arrange (`stack` (default), `group`, or `stack100`), label (true or false (default); shows labels above bars), sort, height, width
|
|
98
|
+
- ScatterPlot: title, data, x, y, splitBy, height, width
|
|
99
|
+
- PieChart: title, data, category, value, height, width
|
|
100
|
+
- ECharts: data, height, width, renderer
|
|
101
|
+
- BigValue: title, data, value
|
|
102
|
+
- Table: title, data, rows, sortable, sort, groupBy, groupType, subtotals, totalRow, link, showLinkCol, rowShading, rowLines, rowNumbers, compact, headerColor, headerFontColor, totalRowColor, totalFontColor, backgroundColor, emptyMessage
|
|
103
|
+
- Column (sub-component of Table): id (column name), title, description, align, wrap, wrapTitle, colGroup, contentType, totalAgg, redNegatives
|
|
104
|
+
- Value: data, column, row
|
|
105
|
+
- Row (layout container, distributes children horizontally): No attributes
|
|
106
|
+
|
|
107
|
+
Notes on common attributes:
|
|
108
|
+
- `data` can also point at a modeled GSQL table.
|
|
109
|
+
- Any attribute that accepts a column can also accept an arbitrary GSQL expression. These attributes are x, y, y2, splitBy, category, value, link, groupBy, scaleColumn
|
|
110
|
+
- `splitBy` creates a series for each distinct value in the column (long format data).
|
|
111
|
+
- `y` can take a comma-separated list of columns/expressions, to map multiple fields to the same y-axis as separate series (wide format data).
|
|
112
|
+
- `sort` takes a column name followed by `asc` or `desc`, eg. `my_col desc`. Useful when you want something sorted differently than its inherent alphanumeric ordering.
|
|
113
|
+
- `height` and `width` accept any CSS size units eg. `240px` or `50%`.
|
|
114
|
+
|
|
115
|
+
### `<ECharts>`
|
|
116
|
+
To create visualizations or customizations beyond Graphene's out-of-the-box components, specify an ECharts config via `<ECharts>`.
|
|
117
|
+
|
|
118
|
+
This example creates a stacked bar chart with a purple x-axis.
|
|
119
|
+
|
|
120
|
+
```md
|
|
121
|
+
<ECharts data="sales_by_status">
|
|
122
|
+
title: {text: "Annual Revenue by Status"},
|
|
123
|
+
xAxis: {axisLine: {lineStyle: {color: 'purple'}}},
|
|
124
|
+
series: [{type: "bar", stack: "bar-stack", encode: {x: "year", y: "revenue", splitBy: "status"}],
|
|
125
|
+
</ECharts>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
Use `encode` to map objects to the columns of the data source. In Graphene, `encode` also accepts `splitBy` which automatically expands one template into multiple series. For bar charts, `splitBy` can be a two-item list (`[groupBy, stackBy]`) for grouped+stacked bars.
|
|
129
|
+
|
|
130
|
+
Graphene will handle axes, layout, and styles for you, so you can omit those configurations unless you explicitly want to override them.
|
|
131
|
+
|
|
132
|
+
Unsupported:
|
|
133
|
+
- `{@colName}` formatter templates (but `{a}`, `{b}`, `{c}` work)
|
|
134
|
+
- Javascript of any kind
|
|
135
|
+
|
|
136
|
+
### `<Value>`
|
|
137
|
+
`<Value>` is used for inlining SQL-derived values within markdown text. You can place them anywhere in markdown, including headers, and they can be styled with `**` or `_`.
|
|
138
|
+
|
|
139
|
+
```md
|
|
140
|
+
### Top 3 Most Active Airplane Models
|
|
141
|
+
1. **<Value data=top_airplane_models column=manufacturer_model row=0 />** ...
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Input components
|
|
145
|
+
- Dropdown: title, name, data, value (column to populate list with), label, defaultValue, multiple
|
|
146
|
+
- TextInput: title, name, placeholder
|
|
147
|
+
- DateRange: title, name, data, dates, start, end, defaultValue, presetRanges, description
|
|
148
|
+
|
|
149
|
+
Inject input values into queries by referring to their `name` attribute as `$name` in GSQL.
|
|
114
150
|
|
|
115
151
|
````md
|
|
116
152
|
<Dropdown name=status .../>
|
|
153
|
+
|
|
117
154
|
```sql my_query
|
|
118
155
|
select ...
|
|
119
156
|
where status = $status
|
|
120
157
|
```
|
|
121
158
|
````
|
|
122
159
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
- Currency: usd, usd0-usd2, usd0k, usd0m, usd0b (etc.), (also eur, gbp, etc.)
|
|
127
|
-
- Percent: pct, pct0, pct1, pct2, pct3
|
|
128
|
-
- Dates: shortdate, longdate, fulldate, mdy, dmy, hms, ddd, dddd, mmm, mmmm, yyyy
|
|
129
|
-
- Excel: "$#,##0.00", "0.0%", "m/d/yy" (etc.)
|
|
160
|
+
DateRange components emit two referenceable values via `${name}_start` and `${name}_end`.
|
|
161
|
+
|
|
162
|
+
Input values also sync into the page URL query string (eg. `localhost:4000/my_dashboard?status=cancelled`), so reloads and shared links preserve the same dashboard state.
|
|
130
163
|
|
|
131
164
|
# CLI
|
|
132
165
|
|
|
133
|
-
`graphene check`
|
|
166
|
+
Invoke the CLI via your project's package manager (e.g. `pnpm graphene check`, `npm exec graphene run`).
|
|
134
167
|
|
|
135
168
|
```bash
|
|
136
169
|
graphene check # Check diagnostics across all .gsql files in the project
|
|
137
170
|
graphene check path/to/file.gsql # Check diagnostics for one specific gsql file
|
|
138
171
|
graphene check path/to/page.md # Check diagnostics for one specific markdown file
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
`graphene run` supports both query execution and markdown page runs.
|
|
142
172
|
|
|
143
|
-
```bash
|
|
144
173
|
graphene run "from flights select count() as total" # Run inline GSQL and print results
|
|
174
|
+
graphene run 'from flights where carrier = $carrier select count() as total' --input carrier=AA # Provide parameter input values
|
|
145
175
|
graphene run - # Read GSQL from stdin and print results
|
|
146
176
|
|
|
147
177
|
graphene run path/to/page.md # Run the page and save a full-page screenshot
|
|
178
|
+
graphene run path/to/page.md --input carrier=AA # Run the page with input values, overriding page defaults
|
|
179
|
+
|
|
180
|
+
# `-c/--chart` can target either a chart title or the chart's `queryId`. For charts without titles use `graphene list` to see the exact IDs for charts on a page.
|
|
148
181
|
graphene run path/to/page.md -c "Chart Title" # Run the page and screenshot one chart by title
|
|
182
|
+
graphene run path/to/page.md -c 'Query (data="query_name" x="category" y="total")' # Run the page and screenshot one chart by queryId
|
|
183
|
+
|
|
184
|
+
# `-q/--query` can target anything usable in a chart `data` prop (for example, a gsql table or a named code-fenced query in the markdown file).
|
|
149
185
|
graphene run path/to/page.md -q query_name # Run a named query/table from the markdown context and print results
|
|
150
|
-
|
|
186
|
+
graphene run path/to/page.md -q query_name --input carrier=AA # Run a parameterized named query/table
|
|
151
187
|
|
|
152
|
-
|
|
188
|
+
# `--input` values are strings. Repeat the flag to pass multiple values for one input.
|
|
189
|
+
graphene run path/to/page.md --input carrier=AA --input carrier=DL
|
|
153
190
|
|
|
154
|
-
|
|
191
|
+
graphene compile "[GSQL]" # Show the compiled, dialect-specific SQL
|
|
155
192
|
|
|
156
|
-
|
|
193
|
+
# `schema` is for implementation/migration purposes and is NOT for exploring GSQL models
|
|
194
|
+
graphene schema # List datasets/schemas in the connected database
|
|
195
|
+
graphene schema my_dataset # List schemas (or tables) in a dataset
|
|
196
|
+
graphene schema my_dataset.table # Print the GSQL table statement for a database table
|
|
157
197
|
|
|
158
|
-
|
|
159
|
-
graphene
|
|
198
|
+
graphene serve # Start the local dev server (foreground)
|
|
199
|
+
graphene serve --bg # Start the local dev server in the background
|
|
200
|
+
graphene stop # Stop the background dev server
|
|
160
201
|
```
|
|
161
202
|
|
|
162
203
|
# Best practices
|
|
163
|
-
-
|
|
164
|
-
- Use check
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
204
|
+
- **Leverage models** - Use modeled joins, dimensions, and measures whenever possible
|
|
205
|
+
- Use `check` after editing .gsql files to catch syntax errors
|
|
206
|
+
- Use `run path/to/page.md` after editing a page to catch runtime errors and to review the screenshot
|
|
207
|
+
- Use `run path/to/page.md -c "[Chart Title | Query ID]"` after editing an ECharts component to view the screenshot
|
|
208
|
+
- When iterating on code-fenced GSQL queries, use `run path/to/page.md -q query_name` instead of `run "[GSQL]"`
|
|
209
|
+
- Rely on Graphene's defaults for value formatting and chart styles before trying to override in SQL or ECharts
|
|
210
|
+
- Keep numbers grounded - Use the `<Value/>` component in prose instead of hard-coding numbers
|
|
211
|
+
- When adding viz, think like Edward Tufte. What is _the_ most effective way to illustrate the data?
|
|
212
|
+
|
|
213
|
+
If the user asks:
|
|
214
|
+
- An open-ended question => notebook
|
|
215
|
+
- To create a page for monitoring purposes => dashboard
|
|
216
|
+
- A more straightforward, tactical question => no page, answer in chat
|
|
217
|
+
|
|
218
|
+
## Notebook guide
|
|
219
|
+
- Use `layout: notebook` in frontmatter
|
|
220
|
+
- Queries should be point-in-time via absolute time filters
|
|
221
|
+
- Page should read like a narrative with prose interspersed with tables or visuals
|
|
222
|
+
- Try to use the most scientifically rigorous means possible to derive insights: think like a statistician or data scientist
|
|
223
|
+
|
|
224
|
+
## Dashboard guide
|
|
225
|
+
- Use `layout: dashboard` in frontmatter
|
|
226
|
+
- Queries generally use relative time filters eg. last 3 months. If user doesn't specify, ask.
|
|
227
|
+
- Avoid narratives - Don't use headers, prose, other markdown content much if at all
|
|
228
|
+
- Use `<Row>` to create grids to fit the maximum amount of information in the viewport
|
|
229
|
+
- Ask the user if they would like any inputs to dynamically filter things
|
|
168
230
|
|
|
169
231
|
# Reference documentation
|
|
170
232
|
Consult the reference documentation for more detailed information on using Graphene.
|
|
233
|
+
For semantic modeling with GSQL references, read `references/model-gsql.md`.
|
|
171
234
|
|
|
172
|
-
- references/area-chart.md
|
|
173
|
-
- references/bar-chart.md
|
|
174
235
|
- references/big-value.md
|
|
236
|
+
- references/date-range.md
|
|
175
237
|
- references/dropdown.md
|
|
238
|
+
- references/echarts.md
|
|
176
239
|
- references/gsql.md
|
|
177
|
-
- references/
|
|
178
|
-
- references/pie-chart.md
|
|
240
|
+
- references/model-gsql.md
|
|
179
241
|
- references/table.md
|
|
180
242
|
- references/text-input.md
|
|
181
|
-
- references/value-formats.md
|
|
@@ -1,55 +1,20 @@
|
|
|
1
|
-
Use
|
|
1
|
+
Use a BigValue to display a single large value standalone.
|
|
2
2
|
|
|
3
3
|
Here's an example:
|
|
4
4
|
|
|
5
5
|
```markdown
|
|
6
6
|
<BigValue
|
|
7
|
-
data=
|
|
7
|
+
data=orders
|
|
8
8
|
value=num_orders
|
|
9
|
-
|
|
10
|
-
comparison=order_growth
|
|
11
|
-
comparisonFmt=pct1
|
|
12
|
-
comparisonTitle="vs. Last Month"
|
|
9
|
+
title="Total Orders"
|
|
13
10
|
/>
|
|
14
11
|
```
|
|
15
12
|
|
|
16
13
|
# Attributes
|
|
17
14
|
|
|
18
|
-
## Data
|
|
19
|
-
|
|
20
15
|
| Attribute | Description | Required | Options | Default |
|
|
21
16
|
|------|-------------|----------|---------|---------|
|
|
22
17
|
| data | GSQL query or table name | true | query name | - |
|
|
23
|
-
| value | Column or expression to pull the main value from
|
|
24
|
-
| title | Title
|
|
25
|
-
|
|
|
26
|
-
| maxWidth | Adds a max-width to the component | false | % or px value | - |
|
|
27
|
-
| fmt | Sets format for the value ([see available formats](#value-formatting)) | false | Excel-style format, built-in format | - |
|
|
28
|
-
| emptySet | Sets behaviour for empty datasets. Can throw an error, a warning, or allow empty. When set to 'error', empty datasets will block builds in `build:strict`. Note this only applies to initial page load - empty datasets caused by input component changes (dropdowns, etc.) are allowed. | false | `error`, `warn`, `pass` | `error` |
|
|
29
|
-
| emptyMessage | Text to display when an empty dataset is received - only applies when `emptySet` is 'warn' or 'pass', or when the empty dataset is a result of an input component change (dropdowns, etc.). | false | string | `"No records"` |
|
|
30
|
-
| link | Used to navigate to other pages. Can be a full external link like `"https://google.com"` or an internal link like `"/sales/performance"` | false | - | - |
|
|
31
|
-
|
|
32
|
-
## Comparison
|
|
33
|
-
|
|
34
|
-
| Attribute | Description | Required | Options | Default |
|
|
35
|
-
|------|-------------|----------|---------|---------|
|
|
36
|
-
| comparison | Column or expression to pull the comparison value from. | false | column name, stored expression name, GSQL expression | - |
|
|
37
|
-
| comparisonTitle | Text to the right of the comparison. | false | string | Title of the comparison column. |
|
|
38
|
-
| comparisonDelta | Whether to display delta symbol and color | false | `true`, `false` | `true` |
|
|
39
|
-
| downIsGood | If present, negative comparison values appear in green, and positive values appear in red. | false | `true`, `false` | `false` |
|
|
40
|
-
| neutralMin | Sets the bottom of the range for 'neutral' values - neutral values appear in grey rather than red or green | false | number | `0` |
|
|
41
|
-
| neutralMax | Sets the top of the range for 'neutral' values - neutral values appear in grey rather than red or green | false | number | `0` |
|
|
42
|
-
| comparisonFmt | Sets format for the comparison ([see available formats](#value-formatting)) | false | Excel-style format, built-in format | - |
|
|
43
|
-
|
|
44
|
-
## Sparkline
|
|
45
|
-
|
|
46
|
-
| Attribute | Description | Required | Options | Default |
|
|
47
|
-
|------|-------------|----------|---------|---------|
|
|
48
|
-
| sparkline | Column or expression to pull the date from to create the sparkline. | false | column name, stored expression name, GSQL expression | - |
|
|
49
|
-
| sparklineType | Chart type for sparkline | false | `line`, `area`, `bar` | `line` |
|
|
50
|
-
| sparklineValueFmt | Formatting for tooltip values | false | format code | same as fmt if supplied |
|
|
51
|
-
| sparklineDateFmt | Formatting for tooltip dates | false | format code | `YYYY-MM-DD` |
|
|
52
|
-
| sparklineColor | Color of visualization | false | CSS name, hexademical, RGB, HSL | - |
|
|
53
|
-
| sparklineYScale | Whether to truncate the y-axis of the chart to enhance visibility | false | `true`, `false` | `false` |
|
|
54
|
-
| connectGroup | Group name to connect this sparkline to other charts for synchronized tooltip hovering. Charts with the same `connectGroup` name will become connected | false | string | - |
|
|
55
|
-
| description | Adds an info icon with description tooltip on hover | false | string | - |
|
|
18
|
+
| value | Column or expression to pull the main value from | true | column name, stored expression name, GSQL expression | - |
|
|
19
|
+
| title | Title displayed above the value | false | string | - |
|
|
20
|
+
| subtitle | Subtitle displayed below the title | false | string | - |
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Creates a date range picker with start/end date inputs and optional preset ranges. The selected range can be used to filter queries or in markdown.
|
|
2
|
+
|
|
3
|
+
Here's an example:
|
|
4
|
+
|
|
5
|
+
````markdown
|
|
6
|
+
```sql sales
|
|
7
|
+
select date, revenue from orders
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
<DateRange
|
|
11
|
+
title="Date Range"
|
|
12
|
+
name=date_filter
|
|
13
|
+
data=sales
|
|
14
|
+
dates=date
|
|
15
|
+
/>
|
|
16
|
+
````
|
|
17
|
+
|
|
18
|
+
The selected start and end dates are then referenced in GSQL as `$date_filter_start` and `$date_filter_end`. For example:
|
|
19
|
+
|
|
20
|
+
```sql
|
|
21
|
+
select date, revenue
|
|
22
|
+
from orders
|
|
23
|
+
where date >= $date_filter_start and date < $date_filter_end
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Date range selections sync into the page URL query string as `{name}_start` and `{name}_end`, eg. `localhost:4000/my_dashboard?date_filter_start=2024-01-01&date_filter_end=2024-02-01`.
|
|
27
|
+
|
|
28
|
+
# Attributes
|
|
29
|
+
|
|
30
|
+
| Attribute | Description | Required | Options | Default |
|
|
31
|
+
|------|-------------|----------|---------|---------|
|
|
32
|
+
| name | Name of the date range, used to reference the selected value elsewhere as `"$name.start"` and `"$name.end"` | true | - | - |
|
|
33
|
+
| data | GSQL query or table name to infer the date domain from | false | query name | - |
|
|
34
|
+
| dates | Column name from the query containing date values, used to determine the min/max of the domain | false | column name | - |
|
|
35
|
+
| start | Initial start date | false | date string or Date | - |
|
|
36
|
+
| end | Initial end date | false | date string or Date | - |
|
|
37
|
+
| defaultValue | Preset label to apply on first load (e.g., `"Last 30 Days"`) | false | preset label | - |
|
|
38
|
+
| presetRanges | List of preset range labels to show in the dropdown. Accepts a comma-separated string or an array. | false | preset labels | See defaults below |
|
|
39
|
+
| title | Title to display above the input | false | string | - |
|
|
40
|
+
| description | Subtitle text displayed below the title | false | string | - |
|
|
41
|
+
|
|
42
|
+
# Preset ranges
|
|
43
|
+
|
|
44
|
+
By default, the following presets are available in the dropdown:
|
|
45
|
+
|
|
46
|
+
- Last 7 Days
|
|
47
|
+
- Last 30 Days
|
|
48
|
+
- Last 90 Days
|
|
49
|
+
- Last 365 Days
|
|
50
|
+
- Last Month
|
|
51
|
+
- Last Year
|
|
52
|
+
- Month to Date
|
|
53
|
+
- Month to Today
|
|
54
|
+
- Year to Date
|
|
55
|
+
- Year to Today
|
|
56
|
+
- All Time
|
|
57
|
+
|
|
58
|
+
The `Last N Days` and `Last N Months` patterns are also supported for any number N (e.g., `"Last 14 Days"`, `"Last 6 Months"`).
|
|
59
|
+
|
|
60
|
+
You can override the list with the `presetRanges` prop:
|
|
61
|
+
|
|
62
|
+
```markdown
|
|
63
|
+
<DateRange name="date_filter" presetRanges="Last 7 Days, Last 30 Days, Last Year" />
|
|
64
|
+
```
|
|
@@ -24,6 +24,8 @@ from orders
|
|
|
24
24
|
where status = $status_dropdown
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
+
Dropdown selections also sync into the page URL query string. Single-select dropdowns use one key, and multi-select dropdowns repeat the key for each selected value.
|
|
28
|
+
|
|
27
29
|
# Attributes
|
|
28
30
|
|
|
29
31
|
| Attribute | Description | Required | Options | Default |
|
|
@@ -31,16 +33,13 @@ where status = $status_dropdown
|
|
|
31
33
|
| name | Name of the dropdown, used to reference the selected value elsewhere as `"$name"` | true | - | - |
|
|
32
34
|
| data | GSQL query or table name | false | query name | - |
|
|
33
35
|
| value | Column name from the query containing values to pick from | false | column name | - |
|
|
34
|
-
| multiple | Enables multi-select which returns a list | false | `true`, `false` | `false` |
|
|
36
|
+
| multiple | Enables multi-select which returns a list and syncs repeated values into the URL query string | false | `true`, `false` | `false` |
|
|
35
37
|
| defaultValue | Value to use when the dropdown is first loaded. Must be one of the options in the dropdown. Lists supported for multi-select. | false | value from dropdown, list of values e.g. `"Value 1, Value 2"` | - |
|
|
36
38
|
| selectAllByDefault | Selects and returns all values, multiple attribute required | false | `true`, `false` | `false` |
|
|
37
39
|
| noDefault | Stops any default from being selected. Overrides any set `defaultValue`. | false | boolean | `false` |
|
|
38
40
|
| disableSelectAll | Removes the `"Select all"` button. Recommended for large datasets. | false | boolean | `false` |
|
|
39
41
|
| label | Column name from the query containing labels to display instead of the values (e.g., you may want to have the drop-down use `customer_id` as the value, but show `customer_name` to your users) | false | column name | Uses the column in value |
|
|
40
42
|
| title | Title to display above the dropdown | false | string | - |
|
|
41
|
-
| order | Column to sort options by, with optional ordering keyword | false | column name [ `asc`, `desc` ] | Ascending based on dropdown value (or label, if specified) |
|
|
42
|
-
| where | SQL where fragment to filter options by (e.g., where sales > 40000) | false | SQL where clause | - |
|
|
43
|
-
| hideDuringPrint | Hide the component when the report is printed | false | `true`, `false` | `true` |
|
|
44
43
|
| description | Adds an info icon with description tooltip on hover | false | string | - |
|
|
45
44
|
|
|
46
45
|
# DropdownOption sub-component
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
Use `ECharts` when you need chart behavior that goes beyond the built-in chart components.
|
|
2
|
+
|
|
3
|
+
Graphene charts are powered by Apache ECharts (v6). In markdown, you define the ECharts option object **inside the `<ECharts>` tag body**.
|
|
4
|
+
|
|
5
|
+
Example:
|
|
6
|
+
|
|
7
|
+
```markdown
|
|
8
|
+
<ECharts data="sales_by_month">
|
|
9
|
+
title: {text: "Revenue"},
|
|
10
|
+
tooltip: {trigger: "axis"},
|
|
11
|
+
series: [{type: "line", encode: {x: "month", y: "revenue"}}],
|
|
12
|
+
</ECharts>
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
# Attributes
|
|
16
|
+
|
|
17
|
+
| Attribute | Description | Required | Options | Default |
|
|
18
|
+
|----------|-------------|----------|---------|---------|
|
|
19
|
+
| data | GSQL query or table name | true | query/table name | - |
|
|
20
|
+
| height | Chart height in px or CSS size string | false | number, string | `240px` |
|
|
21
|
+
| width | Chart width in px or CSS size string | false | number, string | `100%` |
|
|
22
|
+
| renderer | ECharts renderer | false | `svg`, `canvas` | `svg` |
|
|
23
|
+
|
|
24
|
+
## Config body syntax
|
|
25
|
+
|
|
26
|
+
Inside `<ECharts>...</ECharts>`, Graphene parses the config as JSON5:
|
|
27
|
+
- Unquoted keys are allowed (`xAxis: {}`)
|
|
28
|
+
- Trailing commas are allowed
|
|
29
|
+
- You can wrap the whole thing in `{ ... }` or omit the outer braces
|
|
30
|
+
- Inline Javascript is not allowed
|
|
31
|
+
|
|
32
|
+
## What Graphene handles automatically
|
|
33
|
+
|
|
34
|
+
You don't need to configure these — Graphene applies them by default:
|
|
35
|
+
|
|
36
|
+
- Axes: created if missing, types inferred from field metadata (time, category, value), tick formatting applied
|
|
37
|
+
- Layout: grid padding computed to prevent title/legend overlap
|
|
38
|
+
- Style: color palette, fonts, axis borders, split lines, and series marker defaults (via the Graphene theme)
|
|
39
|
+
|
|
40
|
+
Your config typically only needs to specify the series `type`, `encode` mappings, and any explicit overrides to the above.
|
|
41
|
+
|
|
42
|
+
## Encode fields by series type
|
|
43
|
+
|
|
44
|
+
Each series type maps columns via `encode`. Graphene accepts:
|
|
45
|
+
|
|
46
|
+
| Series type | Encode fields |
|
|
47
|
+
|-------------|---------------|
|
|
48
|
+
| `bar`, `line`, `scatter`, `candlestick`, `heatmap`, `effectScatter` | `x`, `y`, `splitBy` |
|
|
49
|
+
| `pie`, `funnel` | `itemName`, `value` |
|
|
50
|
+
| `treemap` | `itemName`, `value` |
|
|
51
|
+
| `sankey`, `chord` | `source`, `target`, `value` |
|
|
52
|
+
| `themeRiver` | `single`, `value`, `seriesName` |
|
|
53
|
+
|
|
54
|
+
For a beeswarm, use a `scatter` series and set `jitter` (plus optional `jitterOverlap`/`jitterMargin`) on the categorical axis.
|
|
55
|
+
|
|
56
|
+
## Customizing with split hints
|
|
57
|
+
|
|
58
|
+
To keep configs concise, Graphene supports a split hint:
|
|
59
|
+
|
|
60
|
+
- `encode.splitBy: "field"`: split one series template into one series per distinct field value
|
|
61
|
+
- `encode.splitBy: ["groupField", "stackField"]` (bar only): expands to grouped+stacked bars, where the first field groups and the second stacks
|
|
62
|
+
- with a single split field, `series.stack` decides stacked vs grouped behavior
|
|
63
|
+
- `stackPercentage: true`: convert stacked values to percentages (100% stacked)
|
|
64
|
+
|
|
65
|
+
Examples:
|
|
66
|
+
|
|
67
|
+
```markdown
|
|
68
|
+
<ECharts data="sales_by_month_and_region">
|
|
69
|
+
title: {text: "Revenue by Region"},
|
|
70
|
+
series: [{
|
|
71
|
+
type: 'bar',
|
|
72
|
+
encode: {x: 'month', y: 'revenue', splitBy: 'region'},
|
|
73
|
+
stack: 'revenue-stack',
|
|
74
|
+
stackPercentage: true
|
|
75
|
+
}]
|
|
76
|
+
</ECharts>
|
|
77
|
+
|
|
78
|
+
<!-- Char that is both grouped by region and stacked by channel -->
|
|
79
|
+
<ECharts data="sales_by_month_region_channel">
|
|
80
|
+
title: {text: "Revenue by Region and Channel"},
|
|
81
|
+
series: [{
|
|
82
|
+
type: 'bar',
|
|
83
|
+
encode: {x: 'month', y: 'revenue', splitBy: ['region', 'channel']},
|
|
84
|
+
stack: 'revenue-stack',
|
|
85
|
+
stackPercentage: true
|
|
86
|
+
}]
|
|
87
|
+
/>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## More examples
|
|
91
|
+
|
|
92
|
+
### Heatmap
|
|
93
|
+
|
|
94
|
+
```markdown
|
|
95
|
+
<ECharts data="delay_by_hour_and_day" height=520px>
|
|
96
|
+
title: {text: "Avg Delay by Hour & Day of Week (min)"},
|
|
97
|
+
tooltip: {trigger: 'item'},
|
|
98
|
+
visualMap: {
|
|
99
|
+
min: -5, max: 30,
|
|
100
|
+
calculable: true,
|
|
101
|
+
orient: 'horizontal',
|
|
102
|
+
left: 'center',
|
|
103
|
+
bottom: 4,
|
|
104
|
+
inRange: {color: ['#5B8F9E', '#e4eff3', '#D4A94C']},
|
|
105
|
+
},
|
|
106
|
+
xAxis: {type: 'category', position: 'top', data: ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']},
|
|
107
|
+
yAxis: {type: 'category', inverse: true, data: ['6am','7am','8am','9am','10am','11am','12pm']},
|
|
108
|
+
series: [{type: 'heatmap', encode: {x: 'day_label', y: 'hour_label', value: 'avg_delay'}}],
|
|
109
|
+
</ECharts>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Scatter/bubble
|
|
113
|
+
|
|
114
|
+
```markdown
|
|
115
|
+
<ECharts data="airport_stats" height=480px>
|
|
116
|
+
title: {text: "Departure vs Arrival Delay by Airport"},
|
|
117
|
+
tooltip: {trigger: 'item'},
|
|
118
|
+
visualMap: {
|
|
119
|
+
dimension: 'flight_count',
|
|
120
|
+
type: 'continuous',
|
|
121
|
+
min: 0, max: 3000,
|
|
122
|
+
inRange: {symbolSize: [4, 32]},
|
|
123
|
+
show: false,
|
|
124
|
+
},
|
|
125
|
+
xAxis: {type: 'value', name: 'Avg Departure Delay (min)', nameLocation: 'middle', nameGap: 22},
|
|
126
|
+
yAxis: {type: 'value', name: 'Avg Arrival Delay (min)', nameLocation: 'middle', nameGap: 20},
|
|
127
|
+
series: [{
|
|
128
|
+
type: 'scatter',
|
|
129
|
+
encode: {x: 'avg_dep_delay', y: 'avg_arr_delay', itemName: 'code'},
|
|
130
|
+
tooltip: {formatter: '{b}'},
|
|
131
|
+
}],
|
|
132
|
+
</ECharts>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Lollipop
|
|
136
|
+
|
|
137
|
+
Combine a `pictorialBar` series (the stem) with a `scatter` series (the dot) on a category y-axis.
|
|
138
|
+
|
|
139
|
+
```markdown
|
|
140
|
+
<ECharts data="avg_delay_by_carrier">
|
|
141
|
+
title: {text: "Avg Delay by Carrier (min)"},
|
|
142
|
+
xAxis: {type: 'value'},
|
|
143
|
+
yAxis: {type: 'category', inverse: true, encode: {y: 'carrier'}},
|
|
144
|
+
series: [
|
|
145
|
+
{
|
|
146
|
+
type: 'pictorialBar',
|
|
147
|
+
symbol: 'rect',
|
|
148
|
+
symbolSize: ['100%', 2],
|
|
149
|
+
symbolPosition: 'end',
|
|
150
|
+
encode: {x: 'avg_delay', y: 'carrier'},
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: 'scatter',
|
|
154
|
+
symbolSize: 12,
|
|
155
|
+
encode: {x: 'avg_delay', y: 'carrier', itemName: 'carrier'},
|
|
156
|
+
label: {show: true, position: 'right', formatter: '{b}', fontSize: 11},
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
</ECharts>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For common chart types, prefer `BarChart`, `LineChart`, `AreaChart`, `ScatterPlot`, and `PieChart`. Use `ECharts` when you need deeper customization.
|