@graphenedata/cli 0.0.15 → 0.0.16

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.
Files changed (117) hide show
  1. package/README.md +138 -0
  2. package/dist/cli/bigQuery-I3F46SC6.js +75 -0
  3. package/dist/cli/bigQuery-I3F46SC6.js.map +7 -0
  4. package/dist/cli/chunk-OVWODUTJ.js +12849 -0
  5. package/dist/cli/chunk-OVWODUTJ.js.map +7 -0
  6. package/dist/cli/chunk-QAXEOZ43.js +53 -0
  7. package/dist/cli/chunk-QAXEOZ43.js.map +7 -0
  8. package/dist/cli/cli.js +234 -11197
  9. package/dist/cli/clickhouse-ZN5AN2UL.js +64 -0
  10. package/dist/cli/clickhouse-ZN5AN2UL.js.map +7 -0
  11. package/dist/cli/duckdb-IYBIO5KJ.js +87 -0
  12. package/dist/cli/duckdb-IYBIO5KJ.js.map +7 -0
  13. package/dist/cli/serve2-TNN5EROW.js +447 -0
  14. package/dist/cli/serve2-TNN5EROW.js.map +7 -0
  15. package/dist/cli/snowflake-MOQB5GA4.js +128 -0
  16. package/dist/cli/snowflake-MOQB5GA4.js.map +7 -0
  17. package/dist/index.d.ts +63 -0
  18. package/dist/lang/index.d.ts +63 -0
  19. package/dist/skills/graphene/SKILL.md +150 -96
  20. package/dist/skills/graphene/references/big-value.md +6 -41
  21. package/dist/skills/graphene/references/date-range.md +64 -0
  22. package/dist/skills/graphene/references/dropdown.md +3 -4
  23. package/dist/skills/graphene/references/echarts.md +162 -0
  24. package/dist/skills/graphene/references/gsql.md +55 -25
  25. package/dist/skills/graphene/references/model-gsql.md +72 -0
  26. package/dist/skills/graphene/references/table.md +13 -14
  27. package/dist/skills/graphene/references/text-input.md +2 -1
  28. package/dist/ui/app.css +239 -340
  29. package/dist/ui/component-utilities/dataShaping.ts +484 -0
  30. package/dist/ui/component-utilities/dataSummary.ts +57 -0
  31. package/dist/ui/component-utilities/enrich.ts +763 -0
  32. package/dist/ui/component-utilities/format.ts +177 -0
  33. package/dist/ui/component-utilities/inputUtils.ts +44 -8
  34. package/dist/ui/component-utilities/theme.ts +200 -0
  35. package/dist/ui/component-utilities/themeStores.ts +21 -8
  36. package/dist/ui/component-utilities/types.ts +70 -0
  37. package/dist/ui/components/AreaChart.svelte +57 -105
  38. package/dist/ui/components/BarChart.svelte +71 -129
  39. package/dist/ui/components/BigValue.svelte +24 -40
  40. package/dist/ui/components/Column.svelte +10 -18
  41. package/dist/ui/components/DateRange.svelte +54 -21
  42. package/dist/ui/components/Dropdown.svelte +47 -26
  43. package/dist/ui/components/DropdownOption.svelte +1 -2
  44. package/dist/ui/components/ECharts.svelte +181 -67
  45. package/dist/ui/components/InlineDelta.svelte +50 -31
  46. package/dist/ui/components/LineChart.svelte +54 -125
  47. package/dist/ui/components/PieChart.svelte +27 -37
  48. package/dist/ui/components/QueryLoad.svelte +77 -45
  49. package/dist/ui/components/Row.svelte +2 -1
  50. package/dist/ui/components/ScatterPlot.svelte +52 -0
  51. package/dist/ui/components/Skeleton.svelte +32 -0
  52. package/dist/ui/components/Table.svelte +3 -2
  53. package/dist/ui/components/TableGroupRow.svelte +28 -36
  54. package/dist/ui/components/TableHarness.svelte +32 -0
  55. package/dist/ui/components/TableHeader.svelte +34 -59
  56. package/dist/ui/components/TableRow.svelte +14 -38
  57. package/dist/ui/components/TableSubtotalRow.svelte +18 -21
  58. package/dist/ui/components/TableTotalRow.svelte +27 -37
  59. package/dist/ui/components/TextInput.svelte +13 -12
  60. package/dist/ui/components/Value.svelte +25 -0
  61. package/dist/ui/components/_Table.svelte +72 -70
  62. package/dist/ui/internal/ChartGallery.svelte +527 -0
  63. package/dist/ui/internal/ErrorDisplay.svelte +22 -97
  64. package/dist/ui/internal/LocalApp.svelte +80 -17
  65. package/dist/ui/internal/PageNavGroup.svelte +269 -0
  66. package/dist/ui/internal/Sidebar.svelte +178 -0
  67. package/dist/ui/internal/SidebarToggle.svelte +47 -0
  68. package/dist/ui/internal/StyleGallery.svelte +244 -0
  69. package/dist/ui/internal/clientCache.ts +2 -2
  70. package/dist/ui/internal/pageInputs.svelte.js +292 -0
  71. package/dist/ui/internal/queryEngine.ts +102 -117
  72. package/dist/ui/internal/runSocket.ts +32 -12
  73. package/dist/ui/internal/sidebar.svelte.js +18 -0
  74. package/dist/ui/internal/telemetry.ts +51 -16
  75. package/dist/ui/internal/types.d.ts +7 -0
  76. package/dist/ui/web.js +28 -11
  77. package/package.json +36 -38
  78. package/dist/skills/graphene/references/area-chart.md +0 -95
  79. package/dist/skills/graphene/references/bar-chart.md +0 -112
  80. package/dist/skills/graphene/references/line-chart.md +0 -108
  81. package/dist/skills/graphene/references/pie-chart.md +0 -29
  82. package/dist/skills/graphene/references/value-formats.md +0 -104
  83. package/dist/ui/component-utilities/autoFormatting.js +0 -280
  84. package/dist/ui/component-utilities/builtInFormats.js +0 -481
  85. package/dist/ui/component-utilities/chartContext.js +0 -12
  86. package/dist/ui/component-utilities/chartWindowDebug.js +0 -21
  87. package/dist/ui/component-utilities/checkInputs.js +0 -84
  88. package/dist/ui/component-utilities/convert.js +0 -15
  89. package/dist/ui/component-utilities/dateParsing.js +0 -56
  90. package/dist/ui/component-utilities/dropdownContext.ts +0 -1
  91. package/dist/ui/component-utilities/echarts.js +0 -252
  92. package/dist/ui/component-utilities/echartsThemes.js +0 -443
  93. package/dist/ui/component-utilities/formatTitle.js +0 -24
  94. package/dist/ui/component-utilities/formatting.js +0 -241
  95. package/dist/ui/component-utilities/getColumnExtents.js +0 -79
  96. package/dist/ui/component-utilities/getColumnSummary.js +0 -62
  97. package/dist/ui/component-utilities/getCompletedData.js +0 -122
  98. package/dist/ui/component-utilities/getDistinctCount.js +0 -7
  99. package/dist/ui/component-utilities/getDistinctValues.js +0 -15
  100. package/dist/ui/component-utilities/getSeriesConfig.js +0 -231
  101. package/dist/ui/component-utilities/getSortedData.js +0 -9
  102. package/dist/ui/component-utilities/getStackPercentages.js +0 -45
  103. package/dist/ui/component-utilities/getStackedData.js +0 -19
  104. package/dist/ui/component-utilities/getYAxisIndex.js +0 -15
  105. package/dist/ui/component-utilities/globalContexts.js +0 -1
  106. package/dist/ui/component-utilities/helpers/getCompletedData.helpers.js +0 -119
  107. package/dist/ui/component-utilities/replaceNulls.js +0 -16
  108. package/dist/ui/component-utilities/tableUtils.ts +0 -107
  109. package/dist/ui/component-utilities/tidyWithTypes.js +0 -9
  110. package/dist/ui/components/Area.svelte +0 -214
  111. package/dist/ui/components/Bar.svelte +0 -347
  112. package/dist/ui/components/Chart.svelte +0 -995
  113. package/dist/ui/components/Line.svelte +0 -227
  114. package/dist/ui/internal/NavSidebar.svelte +0 -396
  115. package/dist/ui/internal/theme.ts +0 -60
  116. package/dist/ui/public/inter-latin-ext.woff2 +0 -0
  117. package/dist/ui/public/inter-latin.woff2 +0 -0
@@ -1,28 +1,28 @@
1
-
2
1
  ---
3
2
  name: graphene
4
3
  description: How to use Graphene, our framework for data modeling, analysis, and visualization.
5
4
  ---
6
5
 
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`.
6
+ 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
7
 
9
8
  # GSQL
10
9
  GSQL extends ANSI SQL with dimensions, measures, and join relationships. Declare them in `table` statements:
11
10
 
12
11
  ```sql
13
12
  table orders (
14
- id BIGINT
15
- user_id BIGINT
16
- amount FLOAT
17
- status STRING
13
+ id bigint
14
+ created_at datetime
15
+ user_id bigint
16
+ amount float #units=usd
17
+ status string
18
18
  join one users on user_id = users.id -- many orders per user
19
19
  is_complete: status = 'Complete' -- dimension (scalar expression)
20
- revenue: sum(amount) -- measure (agg expression)
21
- avg_order: revenue / count(*) -- measures can compose
20
+ revenue: sum(amount) -- measure (agg expression) #units=usd
21
+ avg_order: revenue / count(*) -- measures can compose #units=usd
22
22
  )
23
23
  table users (
24
- id BIGINT
25
- name VARCHAR
24
+ id bigint
25
+ name varchar
26
26
  join many orders on id = orders.user_id
27
27
  )
28
28
  ```
@@ -43,139 +43,193 @@ Dimensions and measures are like macros that expand inline when GSQL compiles to
43
43
  - OK: `floor(revenue)`, `revenue / cost`
44
44
  - 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
45
 
46
+ ### Arrays
47
+ - Array columns and casts use `array<T>` syntax in GSQL, for example `tags array<string>` or `cast(tags as array<string>)`
48
+ - Arrays can be expanded in queries with `cross join unnest(tags) as tag`
49
+
46
50
  ### Special features
47
51
  - `group by all` is implied when aggregates exist, and does not need to be put in GSQL
48
52
  - Agg function `pXX(column)` computes the XXth percentile (e.g., p50, p975, p9999)
53
+ - `select`, `from`, `order by`, etc. in any order
49
54
 
50
- ### Unsupported
51
- - Set operations (`union`, etc.)
52
- - Semi-structured data types (`VARIANT`, `OBJECT`, `ARRAY`)
55
+ ### Supported
56
+ - All scalar, agg, and window functions of the connected database
57
+ - ANSI joins, CTEs, subqueries, set operations
53
58
 
54
- # Dashboards
55
- Graphene dashboards extend Markdown with the following:
59
+ ### Not supported
60
+ - Table functions
61
+ - UDFs
62
+ - `pivot`, `lateral`
63
+ - `variant`, `object`, `record` types
64
+
65
+ # Pages
66
+ Graphene pages extend Markdown with the following:
56
67
  - GSQL queries in code fences
57
- - Visualization components reference query names
68
+ - Visualization and input components
58
69
 
59
70
  ````md
60
- ```sql sales_by_category
61
- select category, revenue from orders
71
+ ---
72
+ title: My First Dashboard
73
+ layout: dashboard
74
+ ---
75
+
76
+ ```sql sales_by_status
77
+ select extract(year from created_at) AS year, status, revenue
78
+ from orders
79
+ where status <> 'cancelled'
62
80
  ```
63
- <BarChart data="sales_by_category" x="category" y="revenue" />
64
- <BigValue data="sales_by_category" value="revenue" />
81
+
82
+ <BigValue data="orders" value="revenue" />
83
+ <BarChart data="sales_by_status" x="year" y="revenue" splitBy="status"/>
65
84
  ````
66
85
 
67
- Queries can be referenced by other queries in the `from` or `join` to form DAGs of data transformations within the dashboard.
68
- `data` can be a query name or a table name. Attributes that accept columns also accept GSQL expressions.
69
-
70
- ## Components
71
- ### Visualizations
72
- - BarChart: data, x, y, y2, series, title, subtitle, xFmt, yFmt, y2Fmt, colorPalette, type, swapXY, labels, labelFmt, sort, legend, yMin, yMax
73
- - LineChart: data, x, y, y2, series, title, subtitle, xFmt, yFmt, colorPalette, labels, sort, legend, handleMissing, markers, markerShape, lineType, lineWidth
74
- - AreaChart: data, x, y, series, title, subtitle, xFmt, yFmt, colorPalette, type, labels, sort, legend, handleMissing, fillOpacity, line
75
- - PieChart: data, category, value, title, subtitle
76
- - BigValue: data, value, title, fmt, comparison, comparisonFmt, comparisonTitle, downIsGood, sparkline, sparklineType, sparklineColor
77
- - Table: data, rows, title, subtitle, groupBy, groupType, subtotals, totalRow, search, sort, link, rowShading, rowNumbers, compact, headerColor
78
- - Column (sub-component of Table): id, title, fmt, align, wrap, contentType, totalAgg, redNegatives
79
-
80
- ### Inputs
81
- - Dropdown: name, data, value, label, defaultValue, multiple, title
82
- - TextInput: name, title, placeholder
83
-
84
- ### Other components
85
- - Row: no attributes (layout container, distributes children horizontally)
86
-
87
- ## Component attributes
88
- - series: column whose values become separate lines/bars (series=country plots one line per country)
89
- - type: stacked (default), grouped (BarChart only), stacked100
90
- - y2: secondary y-axis, y2SeriesType sets its chart type (line/bar/scatter)
91
- - swapXY: horizontal bars
92
- - handleMissing: gap (default), connect, zero
93
- - colorPalette: comma-separated "#hex1, #hex2", applied to series in order
94
- - seriesOrder: control series order "Val1, Val2", pairs with colorPalette
95
- - labels: show value labels on chart
96
- - markers: show dots on line points; markerShape: circle, emptyCircle, rect, triangle, diamond
97
- - lineType: solid, dashed, dotted
98
- - downIsGood: green for negative (for comparison/delta)
99
- - sparkline: date column for mini trend; sparklineType: line, area, bar
100
- - groupBy: group table rows; groupType: accordion (collapsible) or section (merged)
101
- - totalRow: sum row at bottom; subtotals: sum row per group
102
- - link: make table rows clickable, value is URL column
103
- - contentType:
104
- - delta: arrows+colors. deltaSymbol, downIsGood, chip, neutralMin/Max
105
- - colorscale: background gradient. colorScale, colorMin/Mid/Max
106
- - bar: in-cell bar. barColor, negativeBarColor
107
- - link: clickable. linkLabel, openInNewTab
108
- - image: show image. height, width
109
- - sparkline/sparkarea/sparkbar: mini chart from array. sparkX, sparkY, sparkColor
110
- - totalAgg: sum (default), mean, weightedMean, median, min, max, count, countDistinct
111
-
112
- ## Tying input components to SQL
113
- Inject input values into queries by referring to their `name` attribute as $name.
86
+ Queries can be referenced by other queries in the `from` or `join` to form DAGs of data logic within the page.
87
+
88
+ ## Page frontmatter
89
+ You can add YAML frontmatter at the top of a page. The following attributes are supported:
90
+ - `title`: title displayed at the top of the page
91
+ - `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.
92
+
93
+ ## Viz and display components
94
+ - LineChart: title, data, x, y, y2, splitBy, sort, height, width
95
+ - AreaChart: title, data, x, y, y2, splitBy, arrange (`stack` (default) or `stack100`), sort, height, width
96
+ - 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
97
+ - ScatterPlot: title, data, x, y, splitBy, height, width
98
+ - PieChart: title, data, category, value, height, width
99
+ - ECharts: data, height, width, renderer
100
+ - BigValue: title, data, value
101
+ - Table: title, data, rows, sortable, sort, groupBy, groupType, subtotals, totalRow, link, showLinkCol, rowShading, rowLines, rowNumbers, compact, headerColor, headerFontColor, totalRowColor, totalFontColor, backgroundColor, emptyMessage
102
+ - Column (sub-component of Table): id (column name), title, description, align, wrap, wrapTitle, colGroup, contentType, totalAgg, redNegatives
103
+ - Value: data, column, row
104
+ - Row (layout container, distributes children horizontally): No attributes
105
+
106
+ Notes on common attributes:
107
+ - `data` can also point at a modeled GSQL table.
108
+ - 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
109
+ - `splitBy` creates a series for each distinct value in the column (long format data).
110
+ - `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).
111
+ - `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.
112
+ - `height` and `width` accept any CSS size units eg. `240px` or `50%`.
113
+
114
+ ### `<ECharts>`
115
+ To create visualizations or customizations beyond Graphene's out-of-the-box components, specify an ECharts config via `<ECharts>`.
116
+
117
+ This example creates a stacked bar chart with a purple x-axis.
118
+
119
+ ```md
120
+ <ECharts data="sales_by_status">
121
+ title: {text: "Annual Revenue by Status"},
122
+ xAxis: {axisLine: {lineStyle: {color: 'purple'}}},
123
+ series: [{type: "bar", stack: "bar-stack", encode: {x: "year", y: "revenue", splitBy: "status"}],
124
+ </ECharts>
125
+ ```
126
+
127
+ 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.
128
+
129
+ Graphene will handle axes, layout, and styles for you, so you can omit those configurations unless you explicitly want to override them.
130
+
131
+ Unsupported:
132
+ - `{@colName}` formatter templates (but `{a}`, `{b}`, `{c}` work)
133
+ - Javascript of any kind
134
+
135
+ ### `<Value>`
136
+ `<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 `_`.
137
+
138
+ ```md
139
+ ### Top 3 Most Active Airplane Models
140
+ 1. **<Value data=top_airplane_models column=manufacturer_model row=0 />** ...
141
+ ```
142
+
143
+ ## Input components
144
+ - Dropdown: title, name, data, value (column to populate list with), label, defaultValue, multiple
145
+ - TextInput: title, name, placeholder
146
+ - DateRange: title, name, data, dates, start, end, defaultValue, presetRanges, description
147
+
148
+ Inject input values into queries by referring to their `name` attribute as `$name` in GSQL.
114
149
 
115
150
  ````md
116
151
  <Dropdown name=status .../>
152
+
117
153
  ```sql my_query
118
154
  select ...
119
155
  where status = $status
120
156
  ```
121
157
  ````
122
158
 
123
- ## Formatting
124
- `fmt` attributes accept Excel custom format codes or built-in Graphene formats:
125
- - Numbers: num, num0-num4, num0k, num0m, num0b (etc.), id, fract, mult, mult0-mult2, sci
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.)
159
+ DateRange components emit two referenceable values via `${name}_start` and `${name}_end`.
160
+
161
+ 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
162
 
131
163
  # CLI
132
164
 
133
- `graphene check` is a diagnostics command.
165
+ Invoke the CLI via your project's package manager (e.g. `pnpm graphene check`, `npm exec graphene run`).
134
166
 
135
167
  ```bash
136
168
  graphene check # Check diagnostics across all .gsql files in the project
137
169
  graphene check path/to/file.gsql # Check diagnostics for one specific gsql file
138
170
  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
171
 
143
- ```bash
144
172
  graphene run "from flights select count() as total" # Run inline GSQL and print results
145
173
  graphene run - # Read GSQL from stdin and print results
146
174
 
147
175
  graphene run path/to/page.md # Run the page and save a full-page screenshot
176
+
177
+ # `-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
178
  graphene run path/to/page.md -c "Chart Title" # Run the page and screenshot one chart by title
149
- graphene run path/to/page.md -q query_name # Run a named query/table from the markdown context and print results
150
- ```
179
+ graphene run path/to/page.md -c 'Query (data="query_name" x="category" y="total")' # Run the page and screenshot one chart by queryId
151
180
 
152
- `-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).
181
+ # `-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).
182
+ graphene run path/to/page.md -q query_name # Run a named query/table from the markdown context and print results
153
183
 
154
- Invoke via your project's package manager (e.g. `pnpm graphene check`, `npm exec graphene run`).
184
+ graphene compile "[GSQL]" # Show the compiled, dialect-specific SQL
155
185
 
156
- Other commands:
186
+ # `schema` is for implementation/migration purposes and is NOT for exploring GSQL models
187
+ graphene schema # List datasets/schemas in the connected database
188
+ graphene schema my_dataset # List schemas (or tables) in a dataset
189
+ graphene schema my_dataset.table # Print the GSQL table statement for a database table
157
190
 
158
- ```bash
159
- graphene compile "[GSQL]" # Show the compiled, dialect-specific SQL
191
+ graphene serve # Start the local dev server (foreground)
192
+ graphene serve --bg # Start the local dev server in the background
193
+ graphene stop # Stop the background dev server
160
194
  ```
161
195
 
162
196
  # Best practices
163
- - Start simple - Get basic query working, then add complexity
164
- - Use check often - Catches syntax and analysis errors early
165
- - Iterate dashboard queries in-file - When tuning a code-fenced query in a markdown dashboard, edit the `.md` file and run `graphene run [mdFile] -q [queryName]` instead of inline CLI GSQL to avoid drift between experimentation and what gets committed
166
- - Leverage models - Use modeled joins, dimensions, and measures rather than raw SQL
167
- - Don't format in SQL - Rely on `fmt` instead. Do not multiply percentages by 100.
197
+ - **Leverage models** - Use modeled joins, dimensions, and measures whenever possible
198
+ - Use `check` after editing .gsql files to catch syntax errors
199
+ - Use `run path/to/page.md` after editing a page to catch runtime errors and to review the screenshot
200
+ - Use `run path/to/page.md -c "[Chart Title | Query ID]"` after editing an ECharts component to view the screenshot
201
+ - When iterating on code-fenced GSQL queries, use `run path/to/page.md -q query_name` instead of `run "[GSQL]"`
202
+ - Rely on Graphene's defaults for value formatting and chart styles before trying to override in SQL or ECharts
203
+ - Keep numbers grounded - Use the `<Value/>` component in prose instead of hard-coding numbers
204
+ - When adding viz, think like Edward Tufte. What is _the_ most effective way to illustrate the data?
205
+
206
+ If the user asks:
207
+ - An open-ended question => notebook
208
+ - To create a page for monitoring purposes => dashboard
209
+ - A more straightforward, tactical question => no page, answer in chat
210
+
211
+ ## Notebook guide
212
+ - Use `layout: notebook` in frontmatter
213
+ - Queries should be point-in-time via absolute time filters
214
+ - Page should read like a narrative with prose interspersed with tables or visuals
215
+ - Try to use the most scientifically rigorous means possible to derive insights: think like a statistician or data scientist
216
+
217
+ ## Dashboard guide
218
+ - Use `layout: dashboard` in frontmatter
219
+ - Queries generally use relative time filters eg. last 3 months. If user doesn't specify, ask.
220
+ - Avoid narratives - Don't use headers, prose, other markdown content much if at all
221
+ - Use `<Row>` to create grids to fit the maximum amount of information in the viewport
222
+ - Ask the user if they would like any inputs to dynamically filter things
168
223
 
169
224
  # Reference documentation
170
225
  Consult the reference documentation for more detailed information on using Graphene.
226
+ For semantic modeling with GSQL references, read `references/model-gsql.md`.
171
227
 
172
- - references/area-chart.md
173
- - references/bar-chart.md
174
228
  - references/big-value.md
229
+ - references/date-range.md
175
230
  - references/dropdown.md
231
+ - references/echarts.md
176
232
  - references/gsql.md
177
- - references/line-chart.md
178
- - references/pie-chart.md
233
+ - references/model-gsql.md
179
234
  - references/table.md
180
235
  - references/text-input.md
181
- - references/value-formats.md
@@ -1,55 +1,20 @@
1
- Use big values to display a large value standalone, and optionally include a comparison and a sparkline.
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=orders_with_comparisons
7
+ data=orders
8
8
  value=num_orders
9
- sparkline=month
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. | true | column name, stored expression name, GSQL expression | - |
24
- | title | Title of the card. | false | string | Title of the value column. |
25
- | minWidth | Overrides min-width of component | false | % or px value | `"18%"` |
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.