@graphenedata/cli 0.0.14 → 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.
- package/LICENSE.md +3 -3
- package/README.md +138 -0
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/bin.js +2 -2
- package/dist/cli/bigQuery-I3F46SC6.js +75 -0
- package/dist/cli/bigQuery-I3F46SC6.js.map +7 -0
- package/dist/cli/chunk-OVWODUTJ.js +12849 -0
- package/dist/cli/chunk-OVWODUTJ.js.map +7 -0
- package/dist/cli/chunk-QAXEOZ43.js +53 -0
- package/dist/cli/chunk-QAXEOZ43.js.map +7 -0
- package/dist/cli/cli.js +245 -10290
- package/dist/cli/clickhouse-ZN5AN2UL.js +64 -0
- package/dist/cli/clickhouse-ZN5AN2UL.js.map +7 -0
- package/dist/cli/duckdb-IYBIO5KJ.js +87 -0
- package/dist/cli/duckdb-IYBIO5KJ.js.map +7 -0
- package/dist/cli/serve2-TNN5EROW.js +447 -0
- package/dist/cli/serve2-TNN5EROW.js.map +7 -0
- package/dist/cli/snowflake-MOQB5GA4.js +128 -0
- package/dist/cli/snowflake-MOQB5GA4.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 +235 -0
- package/dist/skills/graphene/references/big-value.md +20 -0
- package/dist/skills/graphene/references/date-range.md +64 -0
- package/dist/skills/graphene/references/dropdown.md +62 -0
- package/dist/skills/graphene/references/echarts.md +162 -0
- package/dist/skills/graphene/references/gsql.md +393 -0
- package/dist/skills/graphene/references/model-gsql.md +72 -0
- package/dist/skills/graphene/references/table.md +143 -0
- package/dist/skills/graphene/references/text-input.md +29 -0
- package/dist/ui/app.css +263 -299
- 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 +763 -0
- package/dist/ui/component-utilities/format.ts +177 -0
- package/dist/ui/component-utilities/inputUtils.ts +48 -9
- package/dist/ui/component-utilities/theme.ts +200 -0
- package/dist/ui/component-utilities/themeStores.ts +26 -21
- 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 +11 -19
- package/dist/ui/components/DateRange.svelte +71 -34
- package/dist/ui/components/Dropdown.svelte +82 -49
- package/dist/ui/components/DropdownOption.svelte +1 -2
- package/dist/ui/components/ECharts.svelte +179 -60
- package/dist/ui/components/InlineDelta.svelte +51 -32
- package/dist/ui/components/LineChart.svelte +54 -125
- package/dist/ui/components/PieChart.svelte +27 -37
- package/dist/ui/components/QueryLoad.svelte +78 -44
- 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 +15 -39
- package/dist/ui/components/TableSubtotalRow.svelte +26 -21
- package/dist/ui/components/TableTotalRow.svelte +27 -37
- package/dist/ui/components/TextInput.svelte +17 -14
- package/dist/ui/components/Value.svelte +25 -0
- package/dist/ui/components/_Table.svelte +80 -76
- package/dist/ui/internal/ChartGallery.svelte +527 -0
- package/dist/ui/internal/ErrorDisplay.svelte +60 -0
- package/dist/ui/internal/LocalApp.svelte +87 -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 +15 -13
- package/dist/ui/internal/pageInputs.svelte.js +292 -0
- package/dist/ui/internal/queryEngine.ts +124 -132
- package/dist/ui/internal/runSocket.ts +59 -0
- package/dist/ui/internal/sidebar.svelte.js +18 -0
- package/dist/ui/internal/telemetry.ts +52 -17
- package/dist/ui/internal/types.d.ts +7 -0
- package/dist/ui/web.js +55 -13
- package/package.json +40 -41
- package/dist/docs/agent-instructions.md +0 -18
- package/dist/docs/base.md +0 -98
- package/dist/docs/cli.md +0 -22
- package/dist/docs/graphene.md +0 -1462
- package/dist/ui/component-utilities/autoFormatting.js +0 -301
- package/dist/ui/component-utilities/builtInFormats.js +0 -482
- 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 -95
- package/dist/ui/component-utilities/convert.js +0 -15
- package/dist/ui/component-utilities/dateParsing.js +0 -57
- package/dist/ui/component-utilities/dropdownContext.ts +0 -1
- package/dist/ui/component-utilities/echarts.js +0 -272
- package/dist/ui/component-utilities/echartsThemes.js +0 -453
- package/dist/ui/component-utilities/formatTitle.js +0 -24
- package/dist/ui/component-utilities/formatting.js +0 -250
- package/dist/ui/component-utilities/getColumnExtents.js +0 -79
- package/dist/ui/component-utilities/getColumnSummary.js +0 -67
- package/dist/ui/component-utilities/getCompletedData.js +0 -114
- 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 -237
- package/dist/ui/component-utilities/getSortedData.js +0 -7
- package/dist/ui/component-utilities/getStackPercentages.js +0 -43
- package/dist/ui/component-utilities/getStackedData.js +0 -17
- 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 -14
- package/dist/ui/component-utilities/tableUtils.ts +0 -120
- package/dist/ui/components/Area.svelte +0 -214
- package/dist/ui/components/Bar.svelte +0 -350
- package/dist/ui/components/Chart.svelte +0 -989
- package/dist/ui/components/ErrorChart.svelte +0 -118
- package/dist/ui/components/Line.svelte +0 -227
- package/dist/ui/internal/NavSidebar.svelte +0 -396
- package/dist/ui/internal/PageError.svelte +0 -23
- package/dist/ui/internal/checkSocket.ts +0 -48
- package/dist/ui/internal/theme.ts +0 -88
- package/dist/ui/public/inter-latin-ext.woff2 +0 -0
- package/dist/ui/public/inter-latin.woff2 +0 -0
package/dist/docs/graphene.md
DELETED
|
@@ -1,1462 +0,0 @@
|
|
|
1
|
-
# Graphene documentation
|
|
2
|
-
|
|
3
|
-
Graphene is a framework for data analysis, semantic modeling, and data visualization in code. Graphene projects are comprised of:
|
|
4
|
-
- .gsql files that define semantics-enriched tables (aka semantic models)
|
|
5
|
-
- .md files that define data apps (aka dashboards)
|
|
6
|
-
|
|
7
|
-
Graphene also has a CLI that lets you check syntax, run queries, serve data apps, and more.
|
|
8
|
-
|
|
9
|
-
**Table of Contents**
|
|
10
|
-
|
|
11
|
-
- [Graphene CLI](#graphene-cli)
|
|
12
|
-
- [Graphene SQL (GSQL)](#graphene-sql-gsql)
|
|
13
|
-
- [`table` statements](#table-statements)
|
|
14
|
-
- [Base columns (required)](#base-columns-required)
|
|
15
|
-
- [Join relationships](#join-relationships)
|
|
16
|
-
- [Multiple join relationships between the same two tables](#multiple-join-relationships-between-the-same-two-tables)
|
|
17
|
-
- [Best practices for modeling join relationships](#best-practices-for-modeling-join-relationships)
|
|
18
|
-
- [Stored expressions](#stored-expressions)
|
|
19
|
-
- [`select` statements](#select-statements)
|
|
20
|
-
- [Using join relationships in queries](#using-join-relationships-in-queries)
|
|
21
|
-
- [Multi-hop joins](#multi-hop-joins)
|
|
22
|
-
- [Using scalar stored expressions (dimensions) in queries](#using-scalar-stored-expressions-dimensions-in-queries)
|
|
23
|
-
- [Using aggregative stored expressions (measures) in queries](#using-aggregative-stored-expressions-measures-in-queries)
|
|
24
|
-
- [Safe aggregation in fan-outs](#safe-aggregation-in-fan-outs)
|
|
25
|
-
- [Available functions](#available-functions)
|
|
26
|
-
- [Aggregate functions](#aggregate-functions)
|
|
27
|
-
- [Date and time functions](#date-and-time-functions)
|
|
28
|
-
- [Conditional Functions](#conditional-functions)
|
|
29
|
-
- [Math Functions](#math-functions)
|
|
30
|
-
- [Type Conversion](#type-conversion)
|
|
31
|
-
- [Subqueries, CTEs, and chaining queries](#subqueries-ctes-and-chaining-queries)
|
|
32
|
-
- [Other miscellaneous details](#other-miscellaneous-details)
|
|
33
|
-
- [`table as` statements](#table-as-statements)
|
|
34
|
-
- [`extend` statements](#extend-statements)
|
|
35
|
-
- [Graphene data apps (dashboards)](#graphene-data-apps-dashboards)
|
|
36
|
-
- [Visualization components](#visualization-components)
|
|
37
|
-
- [Bar chart](#bar-chart)
|
|
38
|
-
- [All bar chart attributes](#all-bar-chart-attributes)
|
|
39
|
-
- [General](#general)
|
|
40
|
-
- [Data](#data)
|
|
41
|
-
- [Formatting & Styling](#formatting--styling)
|
|
42
|
-
- [Value Labels](#value-labels)
|
|
43
|
-
- [Axes](#axes)
|
|
44
|
-
- [Interactivity](#interactivity)
|
|
45
|
-
- [Pie chart](#pie-chart)
|
|
46
|
-
- [All pie chart attributes](#all-pie-chart-attributes)
|
|
47
|
-
- [General](#general-1)
|
|
48
|
-
- [Data](#data-1)
|
|
49
|
-
- [Line chart](#line-chart)
|
|
50
|
-
- [All line chart attributes](#all-line-chart-attributes)
|
|
51
|
-
- [General](#general-2)
|
|
52
|
-
- [Data](#data-2)
|
|
53
|
-
- [Formatting & Styling](#formatting--styling-1)
|
|
54
|
-
- [Axes](#axes-1)
|
|
55
|
-
- [Interactivity](#interactivity-1)
|
|
56
|
-
- [Area chart](#area-chart)
|
|
57
|
-
- [All area chart attributes](#all-area-chart-attributes)
|
|
58
|
-
- [General](#general-3)
|
|
59
|
-
- [Data](#data-3)
|
|
60
|
-
- [Formatting & Styling](#formatting--styling-2)
|
|
61
|
-
- [Value Labels](#value-labels-1)
|
|
62
|
-
- [Axes](#axes-2)
|
|
63
|
-
- [Interactivity](#interactivity-2)
|
|
64
|
-
- [Big value](#big-value)
|
|
65
|
-
- [All big value attributes](#all-big-value-attributes)
|
|
66
|
-
- [Data](#data-4)
|
|
67
|
-
- [Comparison](#comparison)
|
|
68
|
-
- [Sparkline](#sparkline)
|
|
69
|
-
- [Table](#table)
|
|
70
|
-
- [All table attributes](#all-table-attributes)
|
|
71
|
-
- [Table](#table-1)
|
|
72
|
-
- [Groups](#groups)
|
|
73
|
-
- [Column](#column)
|
|
74
|
-
- [Input components](#input-components)
|
|
75
|
-
- [Text input](#text-input)
|
|
76
|
-
- [All text input attributes](#all-text-input-attributes)
|
|
77
|
-
- [Dropdown](#dropdown)
|
|
78
|
-
- [All dropdown attributes](#all-dropdown-attributes)
|
|
79
|
-
- [DropdownOption](#dropdownoption)
|
|
80
|
-
- [Other components](#other-components)
|
|
81
|
-
- [Value formatting](#value-formatting)
|
|
82
|
-
- [Built-in Formats](#built-in-formats)
|
|
83
|
-
- [Auto-Formatting](#auto-formatting)
|
|
84
|
-
- [Dates](#dates)
|
|
85
|
-
- [Currencies](#currencies)
|
|
86
|
-
- [Numbers](#numbers)
|
|
87
|
-
- [Percentages](#percentages)
|
|
88
|
-
|
|
89
|
-
# Graphene CLI
|
|
90
|
-
|
|
91
|
-
These are the available commands:
|
|
92
|
-
- `npm run graphene check` - Checks the syntax (GSQL and Markdown) for the entire Graphene project.
|
|
93
|
-
- `npm run graphene check [mdPath]` - Checks the syntax for a specified Graphene markdown file. Will also do a runtime check if the dev server is running, and if successful, take a full page screenshot to a temp directory for the agent to view.
|
|
94
|
-
- `npm run graphene check [mdPath] -c [chartTitle]` - Same as above, except if the runtime check is successful, only takes a screenshot of the specified chart. `[chartTitle]` must match (case sensitive) the `title` attribute on the chart component.
|
|
95
|
-
- `npm run graphene compile [GSQL | gsqlPath]` - Shows how GSQL is translated into the underlying database SQL.
|
|
96
|
-
- `npm run graphene run [GSQL | gsqlPath]` - Runs a GSQL query. The tables and semantics defined in all .gsql files in the project are available for the query to use.
|
|
97
|
-
|
|
98
|
-
# Graphene SQL (GSQL)
|
|
99
|
-
|
|
100
|
-
GSQL is comprised of four primary statements:
|
|
101
|
-
1. `table` statements that declare existing tables and semantic metadata
|
|
102
|
-
2. `select` statements that query tables
|
|
103
|
-
3. `table as` statements that create new tables using `select`
|
|
104
|
-
4. `extend` statements that attach semantic metadata to tables
|
|
105
|
-
|
|
106
|
-
## `table` statements
|
|
107
|
-
|
|
108
|
-
`table` statements declare tables that already exist in your database. Here's an example of two tables, `orders` and `users`, in GSQL.
|
|
109
|
-
|
|
110
|
-
```sql
|
|
111
|
-
table orders (
|
|
112
|
-
id BIGINT
|
|
113
|
-
user_id BIGINT
|
|
114
|
-
created_at DATETIME
|
|
115
|
-
status STRING -- One of 'Processing', 'Shipped', 'Complete', 'Cancelled', 'Returned'
|
|
116
|
-
amount FLOAT -- Amount paid by customer
|
|
117
|
-
cost FLOAT -- Cost of materials
|
|
118
|
-
|
|
119
|
-
join one users on user_id = users.id
|
|
120
|
-
|
|
121
|
-
revenue_recognized: status in ('Processing', 'Shipped', 'Complete')
|
|
122
|
-
revenue: sum(case when revenue_recognized then amount else 0 end)
|
|
123
|
-
cogs: sum(case when revenue_recognized then cost else 0 end)
|
|
124
|
-
profit: revenue - cogs
|
|
125
|
-
profit_margin: profit / revenue
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
table users (
|
|
129
|
-
id BIGINT
|
|
130
|
-
name VARCHAR
|
|
131
|
-
email VARCHAR
|
|
132
|
-
age INTEGER
|
|
133
|
-
country_code VARCHAR
|
|
134
|
-
|
|
135
|
-
join many orders on id = orders.user_id
|
|
136
|
-
)
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
We can break down a table statement into three parts: [base columns](#base-columns-required), [join relationships](#join-relationships), and [stored expressions](#stored-expressions) (aka dimensions and measures).
|
|
140
|
-
|
|
141
|
-
### Base columns (required)
|
|
142
|
-
|
|
143
|
-
The base column set is simply a reflection of the underlying database table's schema. Similar to `create table` statements in regular SQL DDL, you list each column's name and data type.
|
|
144
|
-
|
|
145
|
-
### Join relationships
|
|
146
|
-
|
|
147
|
-
Join relationships in a `table` statement declare joins that can be used when querying them. This makes query writing easier and more foolproof. See [Using join relationships in queries](#using-join-relationships-in-queries) below for how to use modeled joins in queries.
|
|
148
|
-
|
|
149
|
-
The other main difference about joins in GSQL vs. regular SQL is that you have to explain if there are many rows in the left table for each row in the right table, or vice versa. This additional bit of information allows Graphene to prevent incorrect aggregation as a result of row duplication (aka fan-out) through joins. See [Safe aggregation in fan-outs](#safe-aggregation-in-fan-outs) for more details.
|
|
150
|
-
|
|
151
|
-
This information is provided with the two supported join types, `join one` and `join many`:
|
|
152
|
-
- `join one` is used if there are many rows in the **left** table for each row in the **right** table.
|
|
153
|
-
- `join many` is used if there are many rows in the **right** table for each row in the **left** table.
|
|
154
|
-
|
|
155
|
-
In the example above with `orders` and `users`, the joins confirm that there are many orders per user, and only one user per order.
|
|
156
|
-
|
|
157
|
-
Note that all joins in GSQL are left outer joins. There is no inner, right, or cross join.
|
|
158
|
-
|
|
159
|
-
#### Multiple join relationships between the same two tables
|
|
160
|
-
|
|
161
|
-
Sometimes there are multiple valid ways to join two tables together. You can model this in Graphene by aliasing the various joins with `as`, just as you would in normal SQL. For example:
|
|
162
|
-
|
|
163
|
-
```sql
|
|
164
|
-
table projects (
|
|
165
|
-
...
|
|
166
|
-
owner_id BIGINT
|
|
167
|
-
viewer_id BIGINT
|
|
168
|
-
|
|
169
|
-
join one users as project_owner on owner_id = project_owner.id
|
|
170
|
-
join one users as project_viewer on viewer_id = project_viewer.id
|
|
171
|
-
)
|
|
172
|
-
|
|
173
|
-
table users (
|
|
174
|
-
...
|
|
175
|
-
id BIGINT
|
|
176
|
-
|
|
177
|
-
join many projects as projects_as_owner on id = projects_as_owner.owner_id
|
|
178
|
-
join many projects as projects_as_viewer on id = projects_as_viewer.viewer_id
|
|
179
|
-
)
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
#### Best practices for modeling join relationships
|
|
183
|
-
|
|
184
|
-
- For a given `table` statement, only model joins that are directly on that table. Multi-hop join paths do not need to be written explicitly in order for queries to traverse them.
|
|
185
|
-
- A join between two tables should be modeled in both the respective `table` statements. This may seem redundant but it offers more flexibility for queries to choose which table to set in the `from` (remember that direction matters in queries since all joins are left joins).
|
|
186
|
-
|
|
187
|
-
### Stored expressions
|
|
188
|
-
|
|
189
|
-
**Stored expressions** are GSQL expressions (ie. any arbitrary combination of functions, operators, and column references) that you want to make reusable to queries. Stored expressions are great for canonizing metrics, segments, and other important business definitions.
|
|
190
|
-
|
|
191
|
-
A stored expression must be given a name via `name: expression`. It can then be referenced by name in queries that use the parent table. See [Using stored expressions in queries](#using-stored-expressions-in-queries) below for how to use stored expressions in queries.
|
|
192
|
-
|
|
193
|
-
Like expressions in regular SQL, expressions in GSQL are either scalar or aggregative. In BI parlance, these would be called dimensions and measures, respectively.
|
|
194
|
-
|
|
195
|
-
Expressions can refer to other expressions, as from the example before:
|
|
196
|
-
|
|
197
|
-
```sql
|
|
198
|
-
table orders (
|
|
199
|
-
...
|
|
200
|
-
|
|
201
|
-
/* Scalar expressions */
|
|
202
|
-
revenue_recognized: status in ('Processing', 'Shipped', 'Complete')
|
|
203
|
-
|
|
204
|
-
/* Agg expressions */
|
|
205
|
-
revenue: sum(case when revenue_recognized then amount else 0 end)
|
|
206
|
-
cogs: sum(case when revenue_recognized then cost else 0 end)
|
|
207
|
-
profit: revenue - cogs -- even though there are no agg functions here, this is still aggregative as it references other aggregative expressions
|
|
208
|
-
profit_margin: profit / revenue
|
|
209
|
-
)
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
## `select` statements
|
|
213
|
-
|
|
214
|
-
`select` is how you write queries in Graphene SQL. It behaves similarly to regular SQL except in the following ways:
|
|
215
|
-
- It can invoke join relationships and stored expressions from `table` statements.
|
|
216
|
-
- It prevents users from accidentally aggregating incorrectly through joins.
|
|
217
|
-
|
|
218
|
-
These differences are described in the sections below.
|
|
219
|
-
|
|
220
|
-
### Using join relationships in queries
|
|
221
|
-
|
|
222
|
-
If a `table` has join relationships declared in it, a `select` query on that table can leverage that join without needing to write its own join statement. This is helpful for query writers who have not memorized all the correct join keys.
|
|
223
|
-
|
|
224
|
-
If you recall the model from before:
|
|
225
|
-
|
|
226
|
-
```sql
|
|
227
|
-
table orders (
|
|
228
|
-
...
|
|
229
|
-
user_id BIGINT,
|
|
230
|
-
join one users on user_id = users.id
|
|
231
|
-
)
|
|
232
|
-
|
|
233
|
-
table users (
|
|
234
|
-
id BIGINT,
|
|
235
|
-
name VARCHAR,
|
|
236
|
-
...
|
|
237
|
-
)
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
We can write a query that leverages the modeled join relationship between `orders` and `users`:
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
```sql
|
|
244
|
-
-- Top 10 customers by order count
|
|
245
|
-
select
|
|
246
|
-
users.name, -- Use the dot operator to traverse the modeled join relationship
|
|
247
|
-
count(*)
|
|
248
|
-
from orders -- A join statement here is not needed
|
|
249
|
-
group by 1
|
|
250
|
-
order by 2 desc
|
|
251
|
-
limit 10
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
#### Multi-hop joins
|
|
255
|
-
|
|
256
|
-
Sometimes you need to access columns or stored expressions in a table that is two or more joins away from the `from` table. To do this, simply use more dot operators to trace the desired join path. For example, say there is another table added to our project, `countries`:
|
|
257
|
-
|
|
258
|
-
```sql
|
|
259
|
-
table orders (
|
|
260
|
-
...
|
|
261
|
-
|
|
262
|
-
join one users on user_id = users.id
|
|
263
|
-
)
|
|
264
|
-
|
|
265
|
-
table users (
|
|
266
|
-
...
|
|
267
|
-
|
|
268
|
-
join many orders on id = orders.user_id
|
|
269
|
-
join one country on country_code = countries.code
|
|
270
|
-
)
|
|
271
|
-
|
|
272
|
-
table countries (
|
|
273
|
-
code VARCHAR
|
|
274
|
-
name VARCHAR
|
|
275
|
-
currency VARCHAR
|
|
276
|
-
free_shipping BOOLEAN
|
|
277
|
-
|
|
278
|
-
join many users on code = users.country_code
|
|
279
|
-
)
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
We can write the following query to show the top ten countries by order count:
|
|
283
|
-
|
|
284
|
-
```sql
|
|
285
|
-
-- Top 10 countries by order count
|
|
286
|
-
select
|
|
287
|
-
users.countries.name, -- Orders -> Users -> Countries
|
|
288
|
-
count(*)
|
|
289
|
-
from orders
|
|
290
|
-
group by 1
|
|
291
|
-
order by 2 desc
|
|
292
|
-
limit 10
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### Using scalar stored expressions (dimensions) in queries
|
|
296
|
-
|
|
297
|
-
A stored expression can be invoked in a query by simply referencing it by name.
|
|
298
|
-
|
|
299
|
-
Again, using the orders table from before:
|
|
300
|
-
|
|
301
|
-
```sql
|
|
302
|
-
table orders (
|
|
303
|
-
id BIGINT
|
|
304
|
-
user_id BIGINT
|
|
305
|
-
created_at DATETIME
|
|
306
|
-
status STRING -- One of 'Processing', 'Shipped', 'Complete', 'Cancelled', 'Returned'
|
|
307
|
-
amount FLOAT -- Amount paid by customer
|
|
308
|
-
cost FLOAT -- Cost of materials
|
|
309
|
-
|
|
310
|
-
join one users on user_id = users.id
|
|
311
|
-
|
|
312
|
-
revenue_recognized: status in ('Processing', 'Shipped', 'Complete')
|
|
313
|
-
revenue: sum(case when revenue_recognized then amount else 0 end)
|
|
314
|
-
cogs: sum(case when revenue_recognized then cost else 0 end)
|
|
315
|
-
profit: revenue - cogs
|
|
316
|
-
profit_margin: profit / revenue
|
|
317
|
-
)
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
We can count the number of orders that were revenue-recognized vs. not:
|
|
321
|
-
|
|
322
|
-
```sql
|
|
323
|
-
-- Number of revenue-recognized orders vs. not
|
|
324
|
-
select
|
|
325
|
-
revenue_recognized, -- Stored expression in orders
|
|
326
|
-
count(*)
|
|
327
|
-
from orders
|
|
328
|
-
group by 1
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
This would be equivalent to:
|
|
332
|
-
|
|
333
|
-
```sql
|
|
334
|
-
select
|
|
335
|
-
status in ('Processing', 'Shipped', 'Complete') as revenue_recognized,
|
|
336
|
-
count(*)
|
|
337
|
-
from orders
|
|
338
|
-
group by 1
|
|
339
|
-
```
|
|
340
|
-
|
|
341
|
-
You can see that invoking a stored expression is like using a macro: the definition for the stored expression is effectively expanded in-line by Graphene when it runs the query.
|
|
342
|
-
|
|
343
|
-
### Using aggregative stored expressions (measures) in queries
|
|
344
|
-
|
|
345
|
-
The macro concept is important to understand when invoking stored expressions that are **aggregative** (ie. contain agg functions), which can also be called "measures." Here's an example.
|
|
346
|
-
|
|
347
|
-
```sql
|
|
348
|
-
-- Profit by month
|
|
349
|
-
select
|
|
350
|
-
date_trunc(created_at, month) as month,
|
|
351
|
-
profit
|
|
352
|
-
from orders
|
|
353
|
-
group by 1
|
|
354
|
-
order by 1 asc
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
Note that, while `profit` looks like a column here, it is _not_ a column. That's because this query is equivalent to:
|
|
358
|
-
|
|
359
|
-
```sql
|
|
360
|
-
select
|
|
361
|
-
date_trunc(created_at, month) as month,
|
|
362
|
-
sum(case when revenue_recognized then amount else 0 end) - sum(case when revenue_recognized then cost else 0 end) as profit -- Profit is defined as revenue - cogs, which respectively expands out to these two filtered sums
|
|
363
|
-
from orders
|
|
364
|
-
group by 1
|
|
365
|
-
order by 1 asc
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
[CRITICAL!] This means:
|
|
369
|
-
- You would NEVER wrap a measure in an agg function like `sum(my_measure)`, for the same reason that you cannot do `SUM(SUM(foo))` in regular SQL.
|
|
370
|
-
- You would NEVER group by a measure like `group by my_measure`, for the same reason that you cannot do `GROUP BY SUM(foo)` in regular SQL.
|
|
371
|
-
- You CAN wrap a measure in a scalar function like `floor(my_measure)`, for the same reason that can do `FLOOR(SUM(foo))` in regular SQL.
|
|
372
|
-
- You CAN compose measures together in expressions like `my_measure + my_other_measure`, for the same reason that you can do `SUM(foo) + SUM(bar)` in regular SQL.
|
|
373
|
-
|
|
374
|
-
Another way of thinking about this is that measures are "self-aggregating."
|
|
375
|
-
|
|
376
|
-
### Safe aggregation in fan-outs
|
|
377
|
-
|
|
378
|
-
Aggregations in GSQL are fan-out safe. In the event of a join, Graphene knows which values are duplicated ("fanned out") and will discard the duplicates when calculating aggregates.
|
|
379
|
-
|
|
380
|
-
To do this, Graphene assumes that the column or expression you're aggregating is only dependent on one table. The grain of this table establishes the "correct" grain to compute the aggregate over.
|
|
381
|
-
|
|
382
|
-
>NOTE: Graphene does not support aggregating over expressions that depend on multiple tables (e.g. `sum(table1.col - table2.col)`). To work around this, you can consolidate the expression into a dimension e.g. `my_dim: col - table2.col` and then aggregate over that dimension.
|
|
383
|
-
|
|
384
|
-
Here's an example of a fan-out:
|
|
385
|
-
|
|
386
|
-
```sql
|
|
387
|
-
table orders (
|
|
388
|
-
id BIGINT
|
|
389
|
-
customer_name VARCHAR
|
|
390
|
-
amt_with_shipping FLOAT
|
|
391
|
-
|
|
392
|
-
join many order_items on id = order_items.order_id
|
|
393
|
-
)
|
|
394
|
-
|
|
395
|
-
table order_items (
|
|
396
|
-
id BIGINT
|
|
397
|
-
order_id BIGINT
|
|
398
|
-
product VARCHAR
|
|
399
|
-
price FLOAT
|
|
400
|
-
|
|
401
|
-
join one orders on order_id = orders.id
|
|
402
|
-
)
|
|
403
|
-
```
|
|
404
|
-
|
|
405
|
-
With the following data:
|
|
406
|
-
|
|
407
|
-
**orders**
|
|
408
|
-
|
|
409
|
-
| id | customer_name | amt_with_shipping |
|
|
410
|
-
|----|---------------|-------------------|
|
|
411
|
-
| 1 | Alice | 110.00 |
|
|
412
|
-
| 2 | Bob | 85.00 |
|
|
413
|
-
|
|
414
|
-
**order_items**
|
|
415
|
-
|
|
416
|
-
| id | order_id | product | price |
|
|
417
|
-
|----|----------|---------|-------|
|
|
418
|
-
| 1 | 1 | Widget | 60.00 |
|
|
419
|
-
| 2 | 1 | Gadget | 40.00 |
|
|
420
|
-
| 3 | 2 | Widget | 60.00 |
|
|
421
|
-
| 4 | 2 | Thingamajig | 15.00 |
|
|
422
|
-
|
|
423
|
-
When joining orders to order_items, the result looks like:
|
|
424
|
-
|
|
425
|
-
**orders joined to order_items**
|
|
426
|
-
|
|
427
|
-
| orders.id | customer_name | amt_with_shipping | order_items.id | product | price |
|
|
428
|
-
|-----------|---------------|-------------------|----------------|---------|-------|
|
|
429
|
-
| 1 | Alice | 110.00 | 1 | Widget | 60.00 |
|
|
430
|
-
| 1 | Alice | 110.00 | 2 | Gadget | 40.00 |
|
|
431
|
-
| 2 | Bob | 85.00 | 3 | Widget | 60.00 |
|
|
432
|
-
| 2 | Bob | 85.00 | 4 | Thingamajig | 15.00 |
|
|
433
|
-
|
|
434
|
-
Notice that both orders appear twice because they each contain two items. In regular SQL, if you naively computed `sum(amt_with_shipping)` over this joined result, you'd get 390.00 instead of the correct 195.00. In GSQL, because `amt_with_shipping` belongs to the `orders` table, Graphene knows to compute the sum at the `orders` grain, yielding 195.00.
|
|
435
|
-
|
|
436
|
-
Here's how you can use this to simplify your queries. Say you want to see total order value and total item count by customer. In GSQL, you can write this directly:
|
|
437
|
-
|
|
438
|
-
```sql
|
|
439
|
-
select
|
|
440
|
-
customer_name,
|
|
441
|
-
sum(orders.amt_with_shipping) as total_spent,
|
|
442
|
-
count(order_items.id) as items_purchased
|
|
443
|
-
from orders
|
|
444
|
-
group by customer_name
|
|
445
|
-
```
|
|
446
|
-
|
|
447
|
-
This returns:
|
|
448
|
-
|
|
449
|
-
| customer_name | total_spent | items_purchased |
|
|
450
|
-
|---------------|-------------|-----------------|
|
|
451
|
-
| Alice | 110.00 | 2 |
|
|
452
|
-
| Bob | 85.00 | 2 |
|
|
453
|
-
|
|
454
|
-
In regular SQL, you'd need a subquery or CTE to avoid the fan-out problem:
|
|
455
|
-
|
|
456
|
-
```sql
|
|
457
|
-
WITH order_totals AS (
|
|
458
|
-
SELECT customer_name, SUM(amt_with_shipping) as total_spent
|
|
459
|
-
FROM orders
|
|
460
|
-
GROUP BY customer_name
|
|
461
|
-
),
|
|
462
|
-
item_counts AS (
|
|
463
|
-
SELECT o.customer_name, COUNT(oi.id) as items_purchased
|
|
464
|
-
FROM orders o
|
|
465
|
-
JOIN order_items oi ON o.id = oi.order_id
|
|
466
|
-
GROUP BY o.customer_name
|
|
467
|
-
)
|
|
468
|
-
SELECT
|
|
469
|
-
ot.customer_name,
|
|
470
|
-
ot.total_spent,
|
|
471
|
-
ic.items_purchased
|
|
472
|
-
FROM order_totals ot
|
|
473
|
-
JOIN item_counts ic ON ot.customer_name = ic.customer_name
|
|
474
|
-
```
|
|
475
|
-
|
|
476
|
-
### Available functions
|
|
477
|
-
|
|
478
|
-
Function availability varies depending on the connected database, noted in the tables below. Check your package.json to see what database you are connected to.
|
|
479
|
-
|
|
480
|
-
#### Aggregate functions
|
|
481
|
-
|
|
482
|
-
| Function | Description | Parameters | Return Type | DuckDB | BigQuery | Snowflake |
|
|
483
|
-
| - | - | - | - | - | - | - |
|
|
484
|
-
| count(), count(*) | Counts the number of rows. | - | Number | x | x | x |
|
|
485
|
-
| count(column) | Counts the number of non-null values in a column. | `column` - Any column/expression | Number | x | x | x |
|
|
486
|
-
| count(distinct column) | Counts the number of distinct non-null values in a column. | `column` - Any column/expression | Number | x | x | x |
|
|
487
|
-
| sum(column) | Calculates the sum of numeric values. | `column` - Numeric column/expression | Number | x | x | x |
|
|
488
|
-
| avg(column) | Calculates the average (mean) of numeric values. | `column` - Numeric column/expression | Number | x | x | x |
|
|
489
|
-
| min(column) | Returns the minimum value. | `column` - Any comparable column/expression | Same as input | x | x | x |
|
|
490
|
-
| max(column) | Returns the maximum value. | `column` - Any comparable column/expression | Same as input | x | x | x |
|
|
491
|
-
| string_agg(column) | Concatenates string values. | `column` - String column/expression | String | x | x | x |
|
|
492
|
-
| stddev(column) | Calculates the standard deviation. | `column` - Numeric column/expression | Number | x | x | x |
|
|
493
|
-
| pXX(column) | Returns the XXth percentile (e.g., p50, p975, p9999). | `column` - Numeric column/expression | Number | x | x (≤p99) | x |
|
|
494
|
-
|
|
495
|
-
#### Date and time functions
|
|
496
|
-
|
|
497
|
-
| Function | Description | Parameters | Return Type | DuckDB | BigQuery | Snowflake |
|
|
498
|
-
| - | - | - | - | - | - | - |
|
|
499
|
-
| current_date() | Returns the current date. | - | Date | x | x | x |
|
|
500
|
-
| current_time() | Returns the current time. | - | Timestamp | x | x | x |
|
|
501
|
-
| current_timestamp() | Returns the current timestamp. | - | Timestamp | x | x | x |
|
|
502
|
-
| local_timestamp() | Returns the local timestamp. | - | Timestamp | x | x | x |
|
|
503
|
-
| current_datetime() | Returns the current datetime (BigQuery only). | - | Timestamp | | x | |
|
|
504
|
-
| date_trunc(unit, date) | Truncates date/timestamp to unit (DuckDB). | `unit` - Quoted date part ('year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second') ; `date` - Timestamp | Date or timestamp | x | | |
|
|
505
|
-
| date_trunc(date, unit) | Truncates date/timestamp to unit (BigQuery). | `date` - Date or timestamp ; `unit` - Unquoted date part (year, quarter, month, week, day, hour, minute, second) | Date or timestamp | | x | |
|
|
506
|
-
| extract(unit from timestamp) | Extracts a date part from timestamp. | `unit` - Date part (year, quarter, month, week, day, hour, minute, second, day_of_week, day_of_year) ; `timestamp` - Timestamp/date | Number | x | x | x |
|
|
507
|
-
| timestamp_diff(start, end, unit) | Calculates difference between timestamps (BigQuery). | `start` - Timestamp ; `end` - Timestamp ; `unit` - Keyword (year, quarter, month, week, day, hour, minute, second) | Number | | x | |
|
|
508
|
-
|
|
509
|
-
#### Conditional Functions
|
|
510
|
-
|
|
511
|
-
| Function | Description | Parameters | Return Type | DuckDB | BigQuery | Snowflake |
|
|
512
|
-
| - | - | - | - | - | - | - |
|
|
513
|
-
| if(condition, trueValue, falseValue) | Returns one of two values based on condition. | `condition` - Boolean ; `trueValue` - Any type ; `falseValue` - Same type as trueValue | Same as value args | x | x | |
|
|
514
|
-
| case when ... then ... else ... end | Evaluates conditions and returns values. | Multiple when/then clauses | Varies | x | x | x |
|
|
515
|
-
| coalesce(value1, value2, ...) | Returns first non-null value. | `value1, value2, ...` - Same type | Same as input | x | x | x |
|
|
516
|
-
|
|
517
|
-
#### Math Functions
|
|
518
|
-
|
|
519
|
-
| Function | Description | Parameters | Return Type | DuckDB | BigQuery | Snowflake |
|
|
520
|
-
| - | - | - | - | - | - | - |
|
|
521
|
-
| floor(number) | Rounds down to nearest integer. | `number` - Numeric value | Number | x | x | x |
|
|
522
|
-
| ceil(number) | Rounds up to nearest integer. | `number` - Numeric value | Number | x | x | x |
|
|
523
|
-
| greatest(value1, value2, ...) | Returns the greatest value. | `value1, value2, ...` - Same type | Same as input | x | x | x |
|
|
524
|
-
| least(value1, value2, ...) | Returns the smallest value. | `value1, value2, ...` - Same type | Same as input | x | x | x |
|
|
525
|
-
| safe_divide(numerator, denominator) | Divides, returning null on division by zero (BigQuery). | `numerator` - Number ; `denominator` - Number | Number | | x | |
|
|
526
|
-
|
|
527
|
-
#### Type Conversion
|
|
528
|
-
|
|
529
|
-
| Function | Description | Parameters | Return Type | DuckDB | BigQuery | Snowflake |
|
|
530
|
-
| - | - | - | - | - | - | - |
|
|
531
|
-
| cast(value as type) | Converts value to specified type. | `value` - Any value ; `type` - Target type (int, int64, integer, bigint, smallint, tinyint, byteint, float, float64, double, decimal, numeric, bigdecimal, number, text, string, varchar, variant, bool, boolean, date, datetime, time, timestamp, timestamp_ntz, geography) | Specified type | x | x | x |
|
|
532
|
-
| value::type | Alternative cast syntax. | `value` - Any value ; `type` - Target type | Specified type | x | x | x |
|
|
533
|
-
|
|
534
|
-
### Subqueries, CTEs, and chaining queries
|
|
535
|
-
|
|
536
|
-
Queries can be chained together for more complex, multi-stage query logic. Instead of using subqueries or CTEs (`WITH`), in GSQL this is done by using the `table as` statement, or in Markdown, by simply chaining queries.
|
|
537
|
-
|
|
538
|
-
Using `table as`:
|
|
539
|
-
|
|
540
|
-
```sql
|
|
541
|
-
table sales_per_store as (
|
|
542
|
-
select
|
|
543
|
-
store_id,
|
|
544
|
-
sum(amount) as total_sales
|
|
545
|
-
from orders
|
|
546
|
-
group by store_id
|
|
547
|
-
)
|
|
548
|
-
|
|
549
|
-
-- average store sales
|
|
550
|
-
select avg(total_sales)
|
|
551
|
-
from sales_per_store
|
|
552
|
-
```
|
|
553
|
-
|
|
554
|
-
In a Markdown file:
|
|
555
|
-
|
|
556
|
-
````md
|
|
557
|
-
```sql sales_per_store
|
|
558
|
-
select
|
|
559
|
-
store_id,
|
|
560
|
-
sum(amount) as total_sales
|
|
561
|
-
from orders
|
|
562
|
-
group by store_id
|
|
563
|
-
```
|
|
564
|
-
|
|
565
|
-
```sql average_store_sales
|
|
566
|
-
select avg(total_sales)
|
|
567
|
-
from sales_per_store
|
|
568
|
-
```
|
|
569
|
-
````
|
|
570
|
-
|
|
571
|
-
### Other miscellaneous details
|
|
572
|
-
|
|
573
|
-
- The clauses in a `select` statement (`select`, `from`, `join`, `group by`, etc.) can be written in any order. They cannot be repeated, however.
|
|
574
|
-
- `group by all` is implied if aggregative and scalar expressions are both present in the `select` clause. This means that `group by` can be omitted and the query will still effectively execute the `group by all`.
|
|
575
|
-
- Expressions in `group by` are implicitly selected, so `from orders select avg(amount) group by user_id` will return two columns.
|
|
576
|
-
- `count` is a reserved word. Do not alias your columns as `count`.
|
|
577
|
-
- Window functions and set operations (`union [all]`, `intersect`, `except`) are not supported.
|
|
578
|
-
- Date and timestamp literals can be written with explicit keywords (`date '2024-01-01'` or `timestamp '2024-01-01 12:00:00'`), but these keywords are optional when the expected type is known from context (e.g., when comparing against a date or timestamp column). Interval literals always require the `interval` keyword.
|
|
579
|
-
|
|
580
|
-
## `table as` statements
|
|
581
|
-
|
|
582
|
-
You can turn the output of any `select` statement into a table with `table foo as (select ...)`. Here's an example of an additional table `user_facts` added to the two tables from earlier:
|
|
583
|
-
|
|
584
|
-
```sql
|
|
585
|
-
table orders (
|
|
586
|
-
id BIGINT
|
|
587
|
-
user_id BIGINT
|
|
588
|
-
created_at DATETIME
|
|
589
|
-
status STRING -- One of 'Processing', 'Shipped', 'Complete', 'Cancelled', 'Returned'
|
|
590
|
-
amount FLOAT -- Amount paid by customer
|
|
591
|
-
cost FLOAT -- Cost of materials
|
|
592
|
-
|
|
593
|
-
join one users on user_id = users.id
|
|
594
|
-
|
|
595
|
-
revenue_recognized: status in ('Processing', 'Shipped', 'Complete')
|
|
596
|
-
revenue: sum(case when revenue_recognized then amount else 0 end)
|
|
597
|
-
cogs: sum(case when revenue_recognized then cost else 0 end)
|
|
598
|
-
profit: revenue - cogs
|
|
599
|
-
profit_margin: profit / revenue
|
|
600
|
-
)
|
|
601
|
-
|
|
602
|
-
table users (
|
|
603
|
-
id BIGINT
|
|
604
|
-
name VARCHAR
|
|
605
|
-
email VARCHAR
|
|
606
|
-
age INTEGER
|
|
607
|
-
|
|
608
|
-
join many orders on id = orders.user_id
|
|
609
|
-
join one user_facts on id = user_facts.id
|
|
610
|
-
|
|
611
|
-
ltv: user_facts.ltv
|
|
612
|
-
lifetime_orders: user_facts.lifetime_orders
|
|
613
|
-
)
|
|
614
|
-
|
|
615
|
-
table user_facts as (
|
|
616
|
-
select id, orders.revenue as ltv, count(orders.id) as lifetime_orders,
|
|
617
|
-
from users group by id
|
|
618
|
-
)
|
|
619
|
-
```
|
|
620
|
-
|
|
621
|
-
`table as` statements are conceptually the same as view tables and CTEs in regular SQL. A few things to note:
|
|
622
|
-
- You cannot declare join relationships or stored expressions directly in a `table as` statement. Use an `extend` statement.
|
|
623
|
-
- In the example above, the `ltv` and `lifetime_orders` columns from `user_facts` are "hoisted" back into `users` so that they appear as if they are columns from `users`. This is simply a design choice which allows query writers to never need to know about `user_facts`.
|
|
624
|
-
|
|
625
|
-
## `extend` statements
|
|
626
|
-
|
|
627
|
-
`extend` statements allow you to add join relationships or stored expressions to an existing table. This is especially useful for tables created via `table as` statements, which do not support defining these properties directly.
|
|
628
|
-
|
|
629
|
-
For example, if we have a `table as` statement that creates a daily summary of orders:
|
|
630
|
-
|
|
631
|
-
```sql
|
|
632
|
-
table daily_orders as (
|
|
633
|
-
select
|
|
634
|
-
date_trunc(created_at, day) as day,
|
|
635
|
-
count(*) as num_orders,
|
|
636
|
-
sum(amount) as total_revenue
|
|
637
|
-
from orders
|
|
638
|
-
group by 1
|
|
639
|
-
)
|
|
640
|
-
```
|
|
641
|
-
|
|
642
|
-
We can extend this table to add measures or joins:
|
|
643
|
-
|
|
644
|
-
```sql
|
|
645
|
-
extend daily_orders (
|
|
646
|
-
join one calendar on day = calendar.date
|
|
647
|
-
|
|
648
|
-
avg_order_value: total_revenue / num_orders
|
|
649
|
-
)
|
|
650
|
-
```
|
|
651
|
-
|
|
652
|
-
Note that you cannot add new base columns with `extend`; you can only add joins and stored expressions.
|
|
653
|
-
|
|
654
|
-
# Graphene data apps (dashboards)
|
|
655
|
-
|
|
656
|
-
Graphene data apps are written in Markdown with the addition of special Graphene HTML components. Markdown files can contain named GSQL queries in code fences that components can then refer to. Those queries can use any tables defined in .gsql files.
|
|
657
|
-
|
|
658
|
-
_my_first_dashboard.md_
|
|
659
|
-
````md
|
|
660
|
-
# Order analysis
|
|
661
|
-
|
|
662
|
-
Looking at our order breakdowns.
|
|
663
|
-
|
|
664
|
-
```sql orders_by_month
|
|
665
|
-
select
|
|
666
|
-
date_trunc(created_at, month) as month,
|
|
667
|
-
count(*) as num_orders,
|
|
668
|
-
profit
|
|
669
|
-
from orders
|
|
670
|
-
group by month
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
<Row>
|
|
674
|
-
<LineChart title="Orders by Month" data=orders_by_month x=month y=num_orders />
|
|
675
|
-
<LineChart title="Profit by Month, USD" data=orders x="date_trunc(created_at, month)" y=profit />
|
|
676
|
-
</Row>
|
|
677
|
-
````
|
|
678
|
-
|
|
679
|
-
Syntax notes
|
|
680
|
-
- The `data` attribute can also refer directly to modeled GSQL tables instead of code-fenced queries.
|
|
681
|
-
- Attributes that take column references can also take whole GSQL expressions, as shown in the second line chart from the example above.
|
|
682
|
-
- Like in HTML, the string value assigned to an attribute does not need to be wrapped in double quotes if it only contains alphanumeric characters, `-`, `_`, `:`, or `.`.
|
|
683
|
-
|
|
684
|
-
Best practices
|
|
685
|
-
- If you have multiple time series charts, align their x-axes to have the same range and granularity.
|
|
686
|
-
- Use the same color for a given metric if it is used in multiple charts.
|
|
687
|
-
|
|
688
|
-
## Visualization components
|
|
689
|
-
|
|
690
|
-
### Bar chart
|
|
691
|
-
|
|
692
|
-
Use bar or column charts to compare a metric across categories. Bar charts are best with a small number of categories and series, and should generally start at 0.
|
|
693
|
-
|
|
694
|
-
Here's an example:
|
|
695
|
-
|
|
696
|
-
```markdown
|
|
697
|
-
<BarChart
|
|
698
|
-
title="Sales by Category"
|
|
699
|
-
data=orders_by_category_2021
|
|
700
|
-
x=month
|
|
701
|
-
y=sales
|
|
702
|
-
series=category
|
|
703
|
-
/>
|
|
704
|
-
```
|
|
705
|
-
|
|
706
|
-
#### All bar chart attributes
|
|
707
|
-
|
|
708
|
-
##### General
|
|
709
|
-
|
|
710
|
-
| Attribute | Description | Options | Default |
|
|
711
|
-
|----------|-------------|---------|---------|
|
|
712
|
-
| title | Chart title. Appears at top left of chart. | string | - |
|
|
713
|
-
| subtitle | Chart subtitle. Appears just under title. | string | - |
|
|
714
|
-
| legend | Turns legend on or off. Legend appears at top center of chart. | `true`, `false` | `true` for multiple series |
|
|
715
|
-
| chartAreaHeight | Minimum height of the chart area (excl. header and footer) in pixels. Adjusting the height affects all viewport sizes and may impact the mobile UX. | number | `180` |
|
|
716
|
-
| renderer | Which chart renderer type (canvas or SVG) to use. See ECharts' documentation on renderers. | `canvas`, `svg` | `canvas` |
|
|
717
|
-
| downloadableData | Whether to show the download button to allow users to download the data | `true`, `false` | `true` |
|
|
718
|
-
| downloadableImage | Whether to show the button to allow users to save the chart as an image | `true`, `false` | `true` |
|
|
719
|
-
|
|
720
|
-
##### Data
|
|
721
|
-
|
|
722
|
-
| Attribute | Description | Required | Options | Default |
|
|
723
|
-
|----------|-------------|----------|---------|---------|
|
|
724
|
-
| data | GSQL query or table name | true | query name | - |
|
|
725
|
-
| x | Column or expression to use for the x-axis of the chart | false | column name, stored expression name, GSQL expression | First column |
|
|
726
|
-
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | false | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | Any non-assigned numeric columns |
|
|
727
|
-
| y2 | Column(s) or expression(s) to include on a secondary y-axis. | false | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | - |
|
|
728
|
-
| y2SeriesType | Chart type to apply to the series on the y2 axis | false | `bar`, `line`, `scatter` | `bar` |
|
|
729
|
-
| series | Column or expression to use to define the series (groups) in a multi-series chart. Use when values of a particular column dictate the multiple series to plot, eg. `country` would create a series for every distinct country in the column. | false | column name, stored expression name, GSQL expression | - |
|
|
730
|
-
| sort | Whether to apply default sort to your data. Default sort is x ascending for number and date x-axes, and y descending for category x-axes | false | `true`, `false` | `true` |
|
|
731
|
-
| type | Grouping method to use for multi-series charts | false | `stacked`, `grouped`, `stacked100` | `stacked` |
|
|
732
|
-
| stackName | Name for an individual stack. If separate Bar components are used with different stackNames, the chart will show multiple stacks | false | string | - |
|
|
733
|
-
| 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` |
|
|
734
|
-
| 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 |
|
|
735
|
-
|
|
736
|
-
##### Formatting & Styling
|
|
737
|
-
|
|
738
|
-
| Attribute | Description | Options | Default |
|
|
739
|
-
|----------|-------------|---------|---------|
|
|
740
|
-
| xFmt | Format to use for x column ([see available formats](#value-formatting)) | Excel-style format, built-in format name | - |
|
|
741
|
-
| yFmt | Format to use for y column ([see available formats](#value-formatting)) | Excel-style format, built-in format name | - |
|
|
742
|
-
| y2Fmt | Format to use for y2 column(s) ([see available formats](#value-formatting)) | Excel-style format, built-in format name | - |
|
|
743
|
-
| seriesLabelFmt | Format to use for series label ([see available formats](#value-formatting)) | Excel-style format, built-in format name | - |
|
|
744
|
-
| fillColor | Color to override default series color. Only accepts a single color. | CSS name, hexademical, RGB, HSL | - |
|
|
745
|
-
| fillOpacity | % of the full color that should be rendered, with remainder being transparent | number (0 to 1) | `1` |
|
|
746
|
-
| outlineWidth | Width of line surrounding each bar | number | `0` |
|
|
747
|
-
| outlineColor | Color to use for outline if outlineWidth > 0 | CSS name, hexademical, RGB, HSL | - |
|
|
748
|
-
| colorPalette | List of custom colors to use for the chart | list of color strings (CSS name, hexademical, RGB, HSL) e.g. `"#cf0d06, #eb5752, #e88a87"` | built-in color palette |
|
|
749
|
-
| seriesOrder | Apply a specific order to the series in a multi-series chart. | list of series names in the order they should be used in the chart e.g. `"Canada, US"` | default order implied by the data |
|
|
750
|
-
| leftPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | number | - |
|
|
751
|
-
| rightPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | number | - |
|
|
752
|
-
| xLabelWrap | Whether to wrap x-axis labels when there is not enough space. Default behaviour is to truncate the labels. | `true`, `false` | `false` |
|
|
753
|
-
|
|
754
|
-
##### Value Labels
|
|
755
|
-
|
|
756
|
-
| Attribute | Description | Options | Default |
|
|
757
|
-
|----------|-------------|---------|---------|
|
|
758
|
-
| labels | Show value labels | `true`, `false` | `false` |
|
|
759
|
-
| stackTotalLabel | If using labels, whether to show a total at the top of stacked bar chart | `true`, `false` | `true` |
|
|
760
|
-
| seriesLabels | If using labels, whether to show series labels | `true`, `false` | `true` |
|
|
761
|
-
| labelSize | Font size of value labels | number | `11` |
|
|
762
|
-
| labelPosition | Where label will appear on your series | `outside`, `inside` | Single Series: `outside`, Stacked: `inside`, Grouped: `outside` |
|
|
763
|
-
| labelColor | Font color of value labels | CSS name, hexademical, RGB, HSL | Automatic based on color contrast of background |
|
|
764
|
-
| labelFmt | Format to use for value labels ([see available formats](#value-formatting)) | Excel-style format, built-in format name | same as y column |
|
|
765
|
-
| yLabelFmt | Format to use for value labels for series on the y axis. Overrides any other formats ([see available formats](#value-formatting)) | Excel-style format, built-in format name | - |
|
|
766
|
-
| y2LabelFmt | Format to use for value labels for series on the y2 axis. Overrides any other formats ([see available formats](#value-formatting)) | Excel-style format, built-in format name | - |
|
|
767
|
-
| showAllLabels | Allow all labels to appear on chart, including overlapping labels | `true`, `false` | `false` |
|
|
768
|
-
|
|
769
|
-
##### Axes
|
|
770
|
-
|
|
771
|
-
| Attribute | Description | Options | Default |
|
|
772
|
-
|----------|-------------|---------|---------|
|
|
773
|
-
| swapXY | Swap the x and y axes to create a horizontal chart | `true`, `false` | `false` |
|
|
774
|
-
| yLog | Whether to use a log scale for the y-axis | `true`, `false` | `false` |
|
|
775
|
-
| yLogBase | Base to use when log scale is enabled | number | `10` |
|
|
776
|
-
| xAxisTitle | Name to show under x-axis. If 'true', formatted column name is used. Only works with swapXY=false | string, `true`, `false` | `false` |
|
|
777
|
-
| yAxisTitle | Name to show beside y-axis. If 'true', formatted column name is used. | string, `true`, `false` | `false` |
|
|
778
|
-
| y2AxisTitle | Name to show beside y2 axis. If 'true', formatted column name is used. | string, `true`, `false` | `false` |
|
|
779
|
-
| xGridlines | Turns on/off gridlines extending from x-axis tick marks (vertical lines when swapXY=false) | `true`, `false` | `false` |
|
|
780
|
-
| yGridlines | Turns on/off gridlines extending from y-axis tick marks (horizontal lines when swapXY=false) | `true`, `false` | `true` |
|
|
781
|
-
| y2Gridlines | Turns on/off gridlines extending from y2-axis tick marks (horizontal lines when swapXY=false) | `true`, `false` | `true` |
|
|
782
|
-
| xAxisLabels | Turns on/off value labels on the x-axis | `true`, `false` | `true` |
|
|
783
|
-
| yAxisLabels | Turns on/off value labels on the y-axis | `true`, `false` | `true` |
|
|
784
|
-
| y2AxisLabels | Turns on/off value labels on the y2-axis | `true`, `false` | `true` |
|
|
785
|
-
| xBaseline | Turns on/off thick axis line (line appears at y=0) | `true`, `false` | `true` |
|
|
786
|
-
| yBaseline | Turns on/off thick axis line (line appears directly alongside the y-axis labels) | `true`, `false` | `false` |
|
|
787
|
-
| y2Baseline | Turns on/off thick axis line (line appears directly alongside the y2-axis labels) | `true`, `false` | `false` |
|
|
788
|
-
| xTickMarks | Turns on/off tick marks for each of the x-axis labels | `true`, `false` | `false` |
|
|
789
|
-
| yTickMarks | Turns on/off tick marks for each of the y-axis labels | `true`, `false` | `false` |
|
|
790
|
-
| y2TickMarks | Turns on/off tick marks for each of the y2-axis labels | `true`, `false` | `false` |
|
|
791
|
-
| yMin | Starting value for the y-axis | number | - |
|
|
792
|
-
| yMax | Maximum value for the y-axis | number | - |
|
|
793
|
-
| yScale | Whether to scale the y-axis to fit your data. `yMin` and `yMax` take precedence over `yScale` | `true`, `false` | `false` |
|
|
794
|
-
| y2Min | Starting value for the y2-axis | number | - |
|
|
795
|
-
| y2Max | Maximum value for the y2-axis | number | - |
|
|
796
|
-
| y2Scale | Whether to scale the y-axis to fit your data. `y2Min` and `y2Max` take precedence over `y2Scale` | `true`, `false` | `false` |
|
|
797
|
-
| yAxisColor | Turns on/off color on the y-axis (turned on by default when secondary y-axis is used). Can also be used to set a specific color | `true`, `false`, color string (CSS name, hexademical, RGB, HSL) | `true` when y2 used; `false` otherwise |
|
|
798
|
-
|
|
799
|
-
##### Interactivity
|
|
800
|
-
|
|
801
|
-
| Attribute | Description | Options |
|
|
802
|
-
|----------|-------------|---------|
|
|
803
|
-
| connectGroup | Group name to connect this chart to other charts for synchronized tooltip hovering. Charts with the same `connectGroup` name will become connected | string |
|
|
804
|
-
|
|
805
|
-
### Pie chart
|
|
806
|
-
|
|
807
|
-
Use a pie chart to show part-to-whole relationships across categories. Best for a small number of categories where proportions are easy to compare.
|
|
808
|
-
|
|
809
|
-
Here's an example:
|
|
810
|
-
|
|
811
|
-
```markdown
|
|
812
|
-
<PieChart
|
|
813
|
-
title="Sales share by category"
|
|
814
|
-
data=orders_by_category_2021
|
|
815
|
-
category=category
|
|
816
|
-
value=sales
|
|
817
|
-
/>
|
|
818
|
-
```
|
|
819
|
-
|
|
820
|
-
#### All pie chart attributes
|
|
821
|
-
|
|
822
|
-
##### General
|
|
823
|
-
|
|
824
|
-
| Attribute | Description | Options | Default |
|
|
825
|
-
|----------|-------------|---------|---------|
|
|
826
|
-
| title | Chart title. Appears at top left of chart. | string | - |
|
|
827
|
-
| subtitle | Chart subtitle. Appears just under title. | string | - |
|
|
828
|
-
|
|
829
|
-
##### Data
|
|
830
|
-
|
|
831
|
-
| Attribute | Description | Required | Options | Default |
|
|
832
|
-
|------|-------------|----------|---------|---------|
|
|
833
|
-
| data | GSQL query or table name | true | query name | - |
|
|
834
|
-
| category | Column or expression to use for slice names | true | column name, stored expression name, GSQL expression | - |
|
|
835
|
-
| value | Column or expression to use for slice values | true | column name, stored expression name, GSQL expression | - |
|
|
836
|
-
|
|
837
|
-
### Line chart
|
|
838
|
-
|
|
839
|
-
Use line charts to display how one or more metrics vary over time. Line charts are suitable for plotting a large number of data points on the same chart.
|
|
840
|
-
|
|
841
|
-
Here's an example:
|
|
842
|
-
|
|
843
|
-
```markdown
|
|
844
|
-
<LineChart
|
|
845
|
-
title="Monthly Sales"
|
|
846
|
-
subtitle="Includes all categories"
|
|
847
|
-
data=orders_by_month
|
|
848
|
-
x=month
|
|
849
|
-
y=sales_usd0k
|
|
850
|
-
yAxisTitle="Sales per Month"
|
|
851
|
-
/>
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
#### All line chart attributes
|
|
855
|
-
|
|
856
|
-
##### General
|
|
857
|
-
|
|
858
|
-
| Attribute | Description | Required | Options | Default |
|
|
859
|
-
|------|-------------|----------|---------|---------|
|
|
860
|
-
| title | Chart title. Appears at top left of chart. | false | string | - |
|
|
861
|
-
| subtitle | Chart subtitle. Appears just under title. | false | string | - |
|
|
862
|
-
| legend | Turn legend on or off. Legend appears at top center of chart. | false | `true`, `false` | `true` for multiple series |
|
|
863
|
-
| chartAreaHeight | Minimum height of the chart area (excl. header and footer) in pixels. Adjusting the height affects all viewport sizes and may impact the mobile UX. | false | number | `180` |
|
|
864
|
-
| renderer | Which chart renderer type (canvas or SVG) to use. See ECharts' [documentation on renderers](https://echarts.apache.org/handbook/en/best-practices/canvas-vs-svg/). | false | `canvas`, `svg` | `canvas` |
|
|
865
|
-
| downloadableData | Whether to show the download button to allow users to download the data | false | `true`, `false` | `true` |
|
|
866
|
-
| downloadableImage | Whether to show the button to allow users to save the chart as an image | false | `true`, `false` | `true` |
|
|
867
|
-
|
|
868
|
-
##### Data
|
|
869
|
-
|
|
870
|
-
| Attribute | Description | Required | Options | Default |
|
|
871
|
-
|------|-------------|----------|---------|---------|
|
|
872
|
-
| data | GSQL query or table name | true | query name | - |
|
|
873
|
-
| x | Column or expression to use for the x-axis of the chart | true | column name, stored expression name, GSQL expression | - |
|
|
874
|
-
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | true | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | - |
|
|
875
|
-
| y2 | Column(s) or expression(s) to include on a secondary y-axis. | false | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | - |
|
|
876
|
-
| y2SeriesType | Chart type to apply to the series on the y2 axis | false | `line`, `bar`, `scatter` | `line` |
|
|
877
|
-
| series | Column or expression to use to define the series (groups) in a multi-series chart. Use when values of a particular column dictate the multiple series to plot, eg. `country` would create a series for every distinct country in the column. | false | column name, stored expression name, GSQL expression | - |
|
|
878
|
-
| sort | Whether to apply default sort to your data. Default is x ascending for number and date x-axes, and y descending for category x-axes | false | `true`, `false` | `true` |
|
|
879
|
-
| handleMissing | Treatment of missing values in the dataset | false | `gap`, `connect`, `zero` | `gap` |
|
|
880
|
-
| 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` |
|
|
881
|
-
| 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 | - |
|
|
882
|
-
|
|
883
|
-
##### Formatting & Styling
|
|
884
|
-
|
|
885
|
-
| Attribute | Description | Required | Options | Default |
|
|
886
|
-
|------|-------------|----------|---------|---------|
|
|
887
|
-
| xFmt | Format to use for x column ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
888
|
-
| yFmt | Format to use for y column(s) ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
889
|
-
| y2Fmt | Format to use for y2 column(s) ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
890
|
-
| seriesLabelFmt | Format to use for series label ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
891
|
-
| step | Specifies whether the chart is displayed as a step line | false | `true`, `false` | `false` |
|
|
892
|
-
| stepPosition | Configures the position of turn points for a step line chart | false | `start`, `middle`, `end` | `end` |
|
|
893
|
-
| lineColor | Color to override default series color. Only accepts a single color | false | CSS name, hexademical, RGB, HSL | - |
|
|
894
|
-
| lineOpacity | % of the full color that should be rendered, with remainder being transparent | false | number (0 to 1) | `1` |
|
|
895
|
-
| lineType | Options to show breaks in a line (dashed or dotted) | false | `solid`, `dashed`, `dotted` | `solid` |
|
|
896
|
-
| lineWidth | Thickness of line (in pixels) | false | number | `2` |
|
|
897
|
-
| markers | Turn on/off markers (shapes rendered onto the points of a line) | false | `true`, `false` | `false` |
|
|
898
|
-
| markerShape | Shape to use if markers=true | false | `circle`, `emptyCircle`, `rect`, `triangle`, `diamond` | `circle` |
|
|
899
|
-
| markerSize | Size of each shape (in pixels) | false | number | `8` |
|
|
900
|
-
| colorPalette | List of custom colors to use for the chart | false | list of color strings (CSS name, hexademical, RGB, HSL) e.g. `"#cf0d06, #eb5752, #e88a87"` | - |
|
|
901
|
-
| seriesOrder | Apply a specific order to the series in a multi-series chart. | false | list of series names in the order they should be used in the chart e.g. `"Canada, US"` | default order implied by the data |
|
|
902
|
-
| labels | Show value labels | false | `true`, `false` | `false` |
|
|
903
|
-
| labelSize | Font size of value labels | false | number | `11` |
|
|
904
|
-
| labelPosition | Where label will appear on your series | false | `above`, `middle`, `below` | `above` |
|
|
905
|
-
| labelColor | Font color of value labels | false | CSS name, hexademical, RGB, HSL | - |
|
|
906
|
-
| labelFmt | Format to use for value labels ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
907
|
-
| yLabelFmt | Format to use for value labels for series on the y axis. Overrides any other formats ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
908
|
-
| y2LabelFmt | Format to use for value labels for series on the y2 axis. Overrides any other formats ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
909
|
-
| showAllLabels | Allow all labels to appear on chart, including overlapping labels | false | `true`, `false` | `false` |
|
|
910
|
-
| leftPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | false | number | - |
|
|
911
|
-
| rightPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | false | number | - |
|
|
912
|
-
| xLabelWrap | Whether to wrap x-axis labels when there is not enough space. Default behaviour is to truncate the labels. | false | `true`, `false` | `false` |
|
|
913
|
-
|
|
914
|
-
##### Axes
|
|
915
|
-
|
|
916
|
-
| Attribute | Description | Required | Options | Default |
|
|
917
|
-
|------|-------------|----------|---------|---------|
|
|
918
|
-
| yLog | Whether to use a log scale for the y-axis | false | `true`, `false` | `false` |
|
|
919
|
-
| yLogBase | Base to use when log scale is enabled | false | number | `10` |
|
|
920
|
-
| xAxisTitle | Name to show under x-axis. If 'true', formatted column name is used. Only works with swapXY=false | false | `true`, `string`, `false` | `false` |
|
|
921
|
-
| yAxisTitle | Name to show beside y-axis. If 'true', formatted column name is used. | false | `true`, `string`, `false` | `false` |
|
|
922
|
-
| y2AxisTitle | Name to show beside y2 axis. If 'true', formatted column name is used. | false | `true`, `string`, `false` | `false` |
|
|
923
|
-
| xGridlines | Turns on/off gridlines extending from x-axis tick marks (vertical lines when swapXY=false) | false | `true`, `false` | `false` |
|
|
924
|
-
| yGridlines | Turns on/off gridlines extending from y-axis tick marks (horizontal lines when swapXY=false) | false | `true`, `false` | `true` |
|
|
925
|
-
| y2Gridlines | Turns on/off gridlines extending from y2-axis tick marks (horizontal lines when swapXY=false) | false | `true`, `false` | `true` |
|
|
926
|
-
| xAxisLabels | Turns on/off value labels on the x-axis | false | `true`, `false` | `true` |
|
|
927
|
-
| yAxisLabels | Turns on/off value labels on the y-axis | false | `true`, `false` | `true` |
|
|
928
|
-
| y2AxisLabels | Turns on/off value labels on the y2-axis | false | `true`, `false` | `true` |
|
|
929
|
-
| xBaseline | Turns on/off thick axis line (line appears at y=0) | false | `true`, `false` | `true` |
|
|
930
|
-
| yBaseline | Turns on/off thick axis line (line appears directly alongside the y-axis labels) | false | `true`, `false` | `false` |
|
|
931
|
-
| y2Baseline | Turns on/off thick axis line (line appears directly alongside the y2-axis labels) | false | `true`, `false` | `false` |
|
|
932
|
-
| xTickMarks | Turns on/off tick marks for each of the x-axis labels | false | `true`, `false` | `false` |
|
|
933
|
-
| yTickMarks | Turns on/off tick marks for each of the y-axis labels | false | `true`, `false` | `false` |
|
|
934
|
-
| y2TickMarks | Turns on/off tick marks for each of the y2-axis labels | false | `true`, `false` | `false` |
|
|
935
|
-
| yMin | Starting value for the y-axis | false | number | - |
|
|
936
|
-
| yMax | Maximum value for the y-axis | false | number | - |
|
|
937
|
-
| yScale | Whether to scale the y-axis to fit your data. `yMin` and `yMax` take precedence over `yScale` | false | `true`, `false` | `false` |
|
|
938
|
-
| y2Min | Starting value for the y2-axis | false | number | - |
|
|
939
|
-
| y2Max | Maximum value for the y2-axis | false | number | - |
|
|
940
|
-
| y2Scale | Whether to scale the y-axis to fit your data. `y2Min` and `y2Max` take precedence over `y2Scale` | false | `true`, `false` | `false` |
|
|
941
|
-
|
|
942
|
-
##### Interactivity
|
|
943
|
-
|
|
944
|
-
| Attribute | Description | Required | Options | Default |
|
|
945
|
-
|------|-------------|----------|---------|---------|
|
|
946
|
-
| connectGroup | Group name to connect this chart to other charts for synchronized tooltip hovering. Charts with the same `connectGroup` name will become connected | false | - | - |
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
### Area chart
|
|
950
|
-
|
|
951
|
-
Use area charts to track how a metric with multiple series changes over time, or a continuous range. Area charts emphasize changes in the sum of series over the individual series.
|
|
952
|
-
|
|
953
|
-
Here's an example:
|
|
954
|
-
|
|
955
|
-
```markdown
|
|
956
|
-
<AreaChart
|
|
957
|
-
data=orders_by_month
|
|
958
|
-
x=month
|
|
959
|
-
y=sales
|
|
960
|
-
/>
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
#### All area chart attributes
|
|
964
|
-
|
|
965
|
-
##### General
|
|
966
|
-
|
|
967
|
-
| Attribute | Description | Required | Options | Default |
|
|
968
|
-
|------|-------------|----------|---------|---------|
|
|
969
|
-
| title | Chart title. Appears at top left of chart. | false | string | - |
|
|
970
|
-
| subtitle | Chart subtitle. Appears just under title. | false | string | - |
|
|
971
|
-
| legend | Turn legend on or off. Legend appears at top center of chart. | false | `true`, `false` | `true` for multiple series |
|
|
972
|
-
| chartAreaHeight | Minimum height of the chart area (excl. header and footer) in pixels. Adjusting the height affects all viewport sizes and may impact the mobile UX. | false | number | `180` |
|
|
973
|
-
| renderer | Which chart renderer type (canvas or SVG) to use. See ECharts' [documentation on renderers](https://echarts.apache.org/handbook/en/best-practices/canvas-vs-svg/). | false | `canvas`, `svg` | `canvas` |
|
|
974
|
-
| downloadableData | Whether to show the download button to allow users to download the data | false | `true`, `false` | `true` |
|
|
975
|
-
| downloadableImage | Whether to show the button to allow users to save the chart as an image | false | `true`, `false` | `true` |
|
|
976
|
-
|
|
977
|
-
##### Data
|
|
978
|
-
|
|
979
|
-
| Attribute | Description | Required | Options | Default |
|
|
980
|
-
|------|-------------|----------|---------|---------|
|
|
981
|
-
| data | GSQL query or table name | true | query name | - |
|
|
982
|
-
| x | Column or expression to use for the x-axis of the chart | true | column name, stored expression name, GSQL expression | First column |
|
|
983
|
-
| y | Column(s) or expression(s) to use for the y-axis of the chart. Each will create its own series. Consider a split axis with `y2` if there is a difference of scale or unit of measure between the series. | true | column name, stored expression name, GSQL expression, list of any combination of these e.g. `"col1, my_expr"` | Any non-assigned numeric columns |
|
|
984
|
-
| series | Column or expression to use to define the series (groups) in a multi-series chart. Use when values of a particular column dictate the multiple series to plot, eg. `country` would create a series for every distinct country in the column. | false | column name, stored expression name, GSQL expression | - |
|
|
985
|
-
| sort | Whether to apply default sort to your data. Default sort is x ascending for number and date x-axes, and y descending for category x-axes | false | `true`, `false` | `true` |
|
|
986
|
-
| type | Grouping method to use for multi-series charts | false | `stacked`, `stacked100` | `stacked` |
|
|
987
|
-
| handleMissing | Treatment of missing values in the dataset | false | `gap`, `connect`, `zero` | `gap` for single series, `zero` for multi-series |
|
|
988
|
-
| 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` |
|
|
989
|
-
| 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" |
|
|
990
|
-
|
|
991
|
-
##### Formatting & Styling
|
|
992
|
-
|
|
993
|
-
| Attribute | Description | Required | Options | Default |
|
|
994
|
-
|------|-------------|----------|---------|---------|
|
|
995
|
-
| xFmt | Format to use for x column ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
996
|
-
| yFmt | Format to use for y column ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
997
|
-
| seriesLabelFmt | Format to use for series label ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | - |
|
|
998
|
-
| step | Specifies whether the chart is displayed as a step line | false | `true`, `false` | `false` |
|
|
999
|
-
| stepPosition | Configures the position of turn points for a step line chart | false | `start`, `middle`, `end` | `end` |
|
|
1000
|
-
| fillColor | Color to override default series color. Only accepts a single color. | false | CSS name, hexademical, RGB, HSL | - |
|
|
1001
|
-
| lineColor | Color to override default line color. Only accepts a single color. | false | CSS name, hexademical, RGB, HSL | - |
|
|
1002
|
-
| fillOpacity | % of the full color that should be rendered, with remainder being transparent | false | number (0 to 1) | `0.7` |
|
|
1003
|
-
| line | Show line on top of the area | false | `true`, `false` | `true` |
|
|
1004
|
-
| colorPalette | List of custom colors to use for the chart | false | list of color strings (CSS name, hexademical, RGB, HSL) e.g. `"#cf0d06, #eb5752, #e88a87"` | built-in color palette |
|
|
1005
|
-
| seriesOrder | Apply a specific order to the series in a multi-series chart. | false | list of series names in the order they should be used in the chart e.g. `"Canada, US"` | default order implied by the data |
|
|
1006
|
-
| leftPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | false | number | - |
|
|
1007
|
-
| rightPadding | Number representing the padding (whitespace) on the left side of the chart. Useful to avoid labels getting cut off | false | number | - |
|
|
1008
|
-
| xLabelWrap | Whether to wrap x-axis labels when there is not enough space. Default behaviour is to truncate the labels. | false | `true`, `false` | `false` |
|
|
1009
|
-
|
|
1010
|
-
##### Value Labels
|
|
1011
|
-
|
|
1012
|
-
| Attribute | Description | Required | Options | Default |
|
|
1013
|
-
|------|-------------|----------|---------|---------|
|
|
1014
|
-
| labels | Show value labels | false | `true`, `false` | `false` |
|
|
1015
|
-
| labelSize | Font size of value labels | false | number | `11` |
|
|
1016
|
-
| labelPosition | Where label will appear on your series | false | `above`, `middle`, `below` | `above` |
|
|
1017
|
-
| labelColor | Font color of value labels | false | CSS name, hexademical, RGB, HSL | Automatic based on color contrast of background |
|
|
1018
|
-
| labelFmt | Format to use for value labels ([see available formats](#value-formatting)) | false | Excel-style format, built-in format name | same as y column |
|
|
1019
|
-
| showAllLabels | Allow all labels to appear on chart, including overlapping labels | false | `true`, `false` | `false` |
|
|
1020
|
-
|
|
1021
|
-
##### Axes
|
|
1022
|
-
|
|
1023
|
-
| Attribute | Description | Required | Options | Default |
|
|
1024
|
-
|------|-------------|----------|---------|---------|
|
|
1025
|
-
| yLog | Whether to use a log scale for the y-axis | false | `true`, `false` | `false` |
|
|
1026
|
-
| yLogBase | Base to use when log scale is enabled | false | number | `10` |
|
|
1027
|
-
| xAxisTitle | Name to show under x-axis. If 'true', formatted column name is used. Only works with swapXY=false | false | `true`, `string`, `false` | `false` |
|
|
1028
|
-
| yAxisTitle | Name to show beside y-axis. If 'true', formatted column name is used. | false | `true`, `string`, `false` | `false` |
|
|
1029
|
-
| xGridlines | Turns on/off gridlines extending from x-axis tick marks (vertical lines when swapXY=false) | false | `true`, `false` | `false` |
|
|
1030
|
-
| yGridlines | Turns on/off gridlines extending from y-axis tick marks (horizontal lines when swapXY=false) | false | `true`, `false` | `true` |
|
|
1031
|
-
| xAxisLabels | Turns on/off value labels on the x-axis | false | `true`, `false` | `true` |
|
|
1032
|
-
| yAxisLabels | Turns on/off value labels on the y-axis | false | `true`, `false` | `true` |
|
|
1033
|
-
| xBaseline | Turns on/off thick axis line (line appears at y=0) | false | `true`, `false` | `true` |
|
|
1034
|
-
| yBaseline | Turns on/off thick axis line (line appears directly alongside the y-axis labels) | false | `true`, `false` | `false` |
|
|
1035
|
-
| xTickMarks | Turns on/off tick marks for each of the x-axis labels | false | `true`, `false` | `false` |
|
|
1036
|
-
| yTickMarks | Turns on/off tick marks for each of the y-axis labels | false | `true`, `false` | `false` |
|
|
1037
|
-
| yMin | Starting value for the y-axis | false | number | - |
|
|
1038
|
-
| yMax | Maximum value for the y-axis | false | number | - |
|
|
1039
|
-
| yScale | Whether to scale the y-axis to fit your data. `yMin` and `yMax` take precedence over `yScale` | false | `true`, `false` | `false` |
|
|
1040
|
-
|
|
1041
|
-
##### Interactivity
|
|
1042
|
-
|
|
1043
|
-
| Attribute | Description | Required | Options | Default |
|
|
1044
|
-
|------|-------------|----------|---------|---------|
|
|
1045
|
-
| connectGroup | Group name to connect this chart to other charts for synchronized tooltip hovering. Charts with the same `connectGroup` name will become connected | false | - | - |
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
### Big value
|
|
1049
|
-
|
|
1050
|
-
Use big values to display a large value standalone, and optionally include a comparison and a sparkline.
|
|
1051
|
-
|
|
1052
|
-
Here's an example:
|
|
1053
|
-
|
|
1054
|
-
```markdown
|
|
1055
|
-
<BigValue
|
|
1056
|
-
data=orders_with_comparisons
|
|
1057
|
-
value=num_orders
|
|
1058
|
-
sparkline=month
|
|
1059
|
-
comparison=order_growth
|
|
1060
|
-
comparisonFmt=pct1
|
|
1061
|
-
comparisonTitle="vs. Last Month"
|
|
1062
|
-
/>
|
|
1063
|
-
```
|
|
1064
|
-
|
|
1065
|
-
#### All big value attributes
|
|
1066
|
-
|
|
1067
|
-
##### Data
|
|
1068
|
-
|
|
1069
|
-
| Attribute | Description | Required | Options | Default |
|
|
1070
|
-
|------|-------------|----------|---------|---------|
|
|
1071
|
-
| data | GSQL query or table name | true | query name | - |
|
|
1072
|
-
| value | Column or expression to pull the main value from. | true | column name, stored expression name, GSQL expression | - |
|
|
1073
|
-
| title | Title of the card. | false | string | Title of the value column. |
|
|
1074
|
-
| minWidth | Overrides min-width of component | false | % or px value | `"18%"` |
|
|
1075
|
-
| maxWidth | Adds a max-width to the component | false | % or px value | - |
|
|
1076
|
-
| fmt | Sets format for the value ([see available formats](#value-formatting)) | false | Excel-style format, built-in format | - |
|
|
1077
|
-
| 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` |
|
|
1078
|
-
| 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"` |
|
|
1079
|
-
| 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 | - | - |
|
|
1080
|
-
|
|
1081
|
-
##### Comparison
|
|
1082
|
-
|
|
1083
|
-
| Attribute | Description | Required | Options | Default |
|
|
1084
|
-
|------|-------------|----------|---------|---------|
|
|
1085
|
-
| comparison | Column or expression to pull the comparison value from. | false | column name, stored expression name, GSQL expression | - |
|
|
1086
|
-
| comparisonTitle | Text to the right of the comparison. | false | string | Title of the comparison column. |
|
|
1087
|
-
| comparisonDelta | Whether to display delta symbol and color | false | `true`, `false` | `true` |
|
|
1088
|
-
| downIsGood | If present, negative comparison values appear in green, and positive values appear in red. | false | `true`, `false` | `false` |
|
|
1089
|
-
| neutralMin | Sets the bottom of the range for 'neutral' values - neutral values appear in grey rather than red or green | false | number | `0` |
|
|
1090
|
-
| neutralMax | Sets the top of the range for 'neutral' values - neutral values appear in grey rather than red or green | false | number | `0` |
|
|
1091
|
-
| comparisonFmt | Sets format for the comparison ([see available formats](#value-formatting)) | false | Excel-style format, built-in format | - |
|
|
1092
|
-
|
|
1093
|
-
##### Sparkline
|
|
1094
|
-
|
|
1095
|
-
| Attribute | Description | Required | Options | Default |
|
|
1096
|
-
|------|-------------|----------|---------|---------|
|
|
1097
|
-
| sparkline | Column or expression to pull the date from to create the sparkline. | false | column name, stored expression name, GSQL expression | - |
|
|
1098
|
-
| sparklineType | Chart type for sparkline | false | `line`, `area`, `bar` | `line` |
|
|
1099
|
-
| sparklineValueFmt | Formatting for tooltip values | false | format code | same as fmt if supplied |
|
|
1100
|
-
| sparklineDateFmt | Formatting for tooltip dates | false | format code | `YYYY-MM-DD` |
|
|
1101
|
-
| sparklineColor | Color of visualization | false | CSS name, hexademical, RGB, HSL | - |
|
|
1102
|
-
| sparklineYScale | Whether to truncate the y-axis of the chart to enhance visibility | false | `true`, `false` | `false` |
|
|
1103
|
-
| 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 | - |
|
|
1104
|
-
| description | Adds an info icon with description tooltip on hover | false | string | - |
|
|
1105
|
-
|
|
1106
|
-
### Table
|
|
1107
|
-
|
|
1108
|
-
Use a Table component to display a richly formatted table of data from a query. Tables are powerful default choice for data display that allow high information density, and are easy to read.
|
|
1109
|
-
|
|
1110
|
-
Here's an example:
|
|
1111
|
-
|
|
1112
|
-
```markdown
|
|
1113
|
-
<Table data=orders_summary />
|
|
1114
|
-
```
|
|
1115
|
-
|
|
1116
|
-
#### All table attributes
|
|
1117
|
-
|
|
1118
|
-
##### Table
|
|
1119
|
-
|
|
1120
|
-
| Attribute | Description | Required | Options | Default |
|
|
1121
|
-
|------|-------------|----------|---------|---------|
|
|
1122
|
-
| data | GSQL query or table name | true | query name | - |
|
|
1123
|
-
| rows | Number of rows to show in the table before paginating results. Use `"rows=all"` to show all rows in the table. | false | number, `all` | `10` |
|
|
1124
|
-
| title | Title for the table | false | string | - |
|
|
1125
|
-
| subtitle | Subtitle - appears under the title | false | string | - |
|
|
1126
|
-
| headerColor | Background color of the header row | false | Hex color code, css color name | - |
|
|
1127
|
-
| headerFontColor | Font color of the header row | false | Hex color code, css color name | - |
|
|
1128
|
-
| totalRow | Show a total row at the bottom of the table, defaults to sum of all numeric columns | false | `true`, `false` | `false` |
|
|
1129
|
-
| totalRowColor | Background color of the total row | false | Hex color code, css color name | - |
|
|
1130
|
-
| totalFontColor | Font color of the total row | false | Hex color code, css color name | - |
|
|
1131
|
-
| rowNumbers | Turns on or off row index numbers | false | `true`, `false` | `false` |
|
|
1132
|
-
| rowLines | Turns on or off borders at the bottom of each row | false | `true`, `false` | `true` |
|
|
1133
|
-
| rowShading | Shades every second row in light grey | false | `true`, `false` | `false` |
|
|
1134
|
-
| backgroundColor | Background color of the table | false | Hex color code, css color name | - |
|
|
1135
|
-
| sortable | Enable sort for each column - click the column title to sort | false | `true`, `false` | `true` |
|
|
1136
|
-
| sort | Column to sort by on initial page load. Sort direction is asc if unspecified. Can only sort by one column using this prop. If you need multi-column sort, use the order by clause in your sql in combination with this prop. | false | 'column name + asc/desc' | - |
|
|
1137
|
-
| search | Add a search bar to the top of your table | false | `true`, `false` | `false` |
|
|
1138
|
-
| downloadable | Enable download data button below the table on hover | false | `true`, `false` | `true` |
|
|
1139
|
-
| formatColumnTitles | Enable auto-formatting of column titles. Turn off to show raw SQL column names | false | `true`, `false` | `true` |
|
|
1140
|
-
| wrapTitles | Wrap column titles | false | `true`, `false` | `false` |
|
|
1141
|
-
| compact | Enable a more compact table view that allows more content vertically and horizontally | false | `true`, `false` | `false` |
|
|
1142
|
-
| link | Makes each row of your table a clickable link. Accepts a column or expression containing the link to use for each row in your table | false | column name, stored expression name, GSQL expression | - |
|
|
1143
|
-
| showLinkCol | Whether to show the column supplied to the `link` attribute | false | `true`, `false` | `false` |
|
|
1144
|
-
| generateMarkdown | Helper for writing Table syntax with many columns. When set to true, markdown for the Table including each `Column` contained within the query will be generated and displayed below the table. | false | `true`, `false` | `false` |
|
|
1145
|
-
| 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` |
|
|
1146
|
-
| 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" |
|
|
1147
|
-
|
|
1148
|
-
##### Groups
|
|
1149
|
-
|
|
1150
|
-
| Attribute | Description | Required | Options | Default |
|
|
1151
|
-
|------|-------------|----------|---------|---------|
|
|
1152
|
-
| groupBy | Column or expression to use to create groups. Note that groups are currently limited to a single group column. | false | column name, stored expression name, GSQL expression | - |
|
|
1153
|
-
| groupType | How the groups are shown in the table. Can be accordion (expand/collapse) or section (group column values are merged across rows) | false | `accordion`, `section` | `accordion` |
|
|
1154
|
-
| subtotals | Whether to show aggregated totals for the groups | false | `true`, `false` | `false` |
|
|
1155
|
-
| subtotalFmt | Specify an override format to use in the subtotal row ([see available formats](#value-formatting)). Custom strings or values are unformatted by default. | false | Excel-style format, built-in format | - |
|
|
1156
|
-
| groupsOpen | [groupType=accordion] Whether to show the accordions as open on page load | false | `true`, `false` | `true` |
|
|
1157
|
-
| accordionRowColor | [groupType=accordion] Background color for the accordion row | false | Hex color code, css color name | - |
|
|
1158
|
-
| subtotalRowColor | [groupType=section] Background color for the subtotal row | false | Hex color code, css color name | - |
|
|
1159
|
-
| subtotalFontColor | [groupType=section] Font color for the subtotal row | false | Hex color code, css color name | - |
|
|
1160
|
-
| groupNamePosition | [groupType=section] Where the group label will appear in its cell | false | `top`, `middle`, `bottom` | `middle` |
|
|
1161
|
-
|
|
1162
|
-
##### Column
|
|
1163
|
-
|
|
1164
|
-
Use the Column sub-component to choose specific columns to display in your table, and to apply options to specific columns. If you don't supply any columns to the table, it will display all columns from your query result.
|
|
1165
|
-
|
|
1166
|
-
Here's an example:
|
|
1167
|
-
|
|
1168
|
-
```markdown
|
|
1169
|
-
<Table data=country_summary>
|
|
1170
|
-
<Column id=country />
|
|
1171
|
-
<Column id=category />
|
|
1172
|
-
<Column id=value_usd fmt=eur />
|
|
1173
|
-
<Column id=yoy title="Y/Y Growth" fmt=pct3 />
|
|
1174
|
-
</Table>
|
|
1175
|
-
```
|
|
1176
|
-
|
|
1177
|
-
| Attribute | Description | Required | Options | Default |
|
|
1178
|
-
|------|-------------|----------|---------|---------|
|
|
1179
|
-
| id | Column id (from SQL query) | true | column name | - |
|
|
1180
|
-
| title | Override title of column | false | string | column name (formatted) |
|
|
1181
|
-
| description | Adds an info icon with description tooltip on hover | false | string | - |
|
|
1182
|
-
| align | Align column text | false | `left`, `center`, `right` | `left` |
|
|
1183
|
-
| fmt | Format the values in the column ([see available formats](#value-formatting)) | false | Excel-style format, built-in format | - |
|
|
1184
|
-
| fmtColumn | Column to use to format values in this column. This is used to achieve different value formats by row. The fmtColumn should contain strings of format codes - either Graphene built-in formats or Excel codes. | false | column name | - |
|
|
1185
|
-
| totalAgg | Specify an aggregation function to use for the total row. Accepts predefined functions, custom strings or values | false | `sum`, `mean`, `weightedMean`, `median`, `min`, `max`, `count`, `countDistinct`, custom string or value | `sum` |
|
|
1186
|
-
| totalFmt | Specify an override format to use in the total row ([see available formats](#value-formatting)). Custom strings or values are unformatted by default. | false | Excel-style format, built-in format | - |
|
|
1187
|
-
| weightCol | Column or expression to use as the weight values for weighted mean aggregation. If not specified, a weight of 1 for each value will be used and the result will be the same as the `mean` aggregation. | false | column name, stored expression name, GSQL expression | - |
|
|
1188
|
-
| wrap | Wrap column text | false | `true`, `false` | `false` |
|
|
1189
|
-
| wrapTitle | Wrap column title | false | `true`, `false` | `false` |
|
|
1190
|
-
| contentType | Lets you specify how to treat the content within a column. See below for contentType-specific options. | false | `link`, `image`, `delta`, `colorscale`, `html` | - |
|
|
1191
|
-
| colGroup | Group name to display above a group of columns. Columns with the same group name will get a shared header above them | false | string | - |
|
|
1192
|
-
| redNegatives | Conditionally sets the font color to red based on whether the selected value is less than 0 | false | `true`, `false` | `false` |
|
|
1193
|
-
|
|
1194
|
-
Column attributes for specific contentTypes:
|
|
1195
|
-
|
|
1196
|
-
Images (`contentType=image`)
|
|
1197
|
-
|
|
1198
|
-
| Attribute | Description | Required | Options | Default |
|
|
1199
|
-
|------|-------------|----------|---------|---------|
|
|
1200
|
-
| height | Height of image in pixels | false | number | original height of image |
|
|
1201
|
-
| width | Width of image in pixels | false | number | original width of image |
|
|
1202
|
-
| alt | Alt text for image | false | column name | Name of the image file (excluding the file extension) |
|
|
1203
|
-
|
|
1204
|
-
Links (`contentType=link`)
|
|
1205
|
-
|
|
1206
|
-
| Attribute | Description | Required | Options | Default |
|
|
1207
|
-
|------|-------------|----------|---------|---------|
|
|
1208
|
-
| linkLabel | Text to display for link | false | column name, string | raw url |
|
|
1209
|
-
| openInNewTab | Whether to open link in new tab | false | `true`, `false` | `false` |
|
|
1210
|
-
|
|
1211
|
-
Deltas (`contentType=delta`)
|
|
1212
|
-
|
|
1213
|
-
| Attribute | Description | Required | Options | Default |
|
|
1214
|
-
|------|-------------|----------|---------|---------|
|
|
1215
|
-
| deltaSymbol | Whether to show the up/down delta arrow symbol | false | `true`, `false` | `true` |
|
|
1216
|
-
| downIsGood | If present, negative comparison values appear in green, and positive values appear in red. | false | `true`, `false` | `false` |
|
|
1217
|
-
| showValue | Whether to show the delta value. Set this to false to show only the delta arrow indicator. | false | `true`, `false` | `true` |
|
|
1218
|
-
| neutralMin | Start of the range for 'neutral' values, which appear in grey font with a dash instead of an up/down arrow. By default, neutral is not applied to any values. | false | number | `0` |
|
|
1219
|
-
| neutralMax | End of the range for 'neutral' values, which appear in grey font with a dash instead of an up/down arrow. By default, neutral is not applied to any values. | false | number | `0` |
|
|
1220
|
-
| chip | Whether to display the delta as a 'chip', with a background color and border. | false | `true`, `false` | `false` |
|
|
1221
|
-
|
|
1222
|
-
Sparklines (`contentType=sparkline` | `contentType=sparkarea` | `contentType=sparkbar`)
|
|
1223
|
-
|
|
1224
|
-
| Attribute | Description | Required | Options | Default |
|
|
1225
|
-
|------|-------------|----------|---------|---------|
|
|
1226
|
-
| sparkX | Column within an array cell to use as the x-axis for the spark viz. Arrays can be created inside a query using the `"array_agg()"` function from DuckDB | false | column from array cell | - |
|
|
1227
|
-
| sparkY | Column within an array cell to use as the y-axis for the spark viz. Arrays can be created inside a query using the `"array_agg()"` function from DuckDB | false | column from array cell | - |
|
|
1228
|
-
| sparkYScale | Whether to truncate the y-axis | false | `true`, `false` | `false` |
|
|
1229
|
-
| sparkHeight | Height of the spark viz. Making the viz taller will increase the height of the full table row | false | number | `18` |
|
|
1230
|
-
| sparkWidth | Width of the spark viz | false | number | `90` |
|
|
1231
|
-
| sparkColor | Color of the spark viz | false | Hex color code, css color name | - |
|
|
1232
|
-
|
|
1233
|
-
Bar chart column (`contentType=bar`)
|
|
1234
|
-
|
|
1235
|
-
| Attribute | Description | Required | Options | Default |
|
|
1236
|
-
|------|-------------|----------|---------|---------|
|
|
1237
|
-
| barColor | Color of the bars. Affects positive bars only. See `negativeBarColor` to change color of negative bars | false | Hex color code, css color name | - |
|
|
1238
|
-
| negativeBarColor | Color of negative bars | false | Hex color code, css color name | - |
|
|
1239
|
-
| hideLabels | Whether to hide the data labels on the bars | false | `true`, `false` | `false` |
|
|
1240
|
-
| backgroundColor | Background color for bar chart | false | Hex color code, css color name | `transparent` |
|
|
1241
|
-
|
|
1242
|
-
Conditional formatting (`contentType=colorscale`)
|
|
1243
|
-
|
|
1244
|
-
| Attribute | Description | Required | Options | Default |
|
|
1245
|
-
|------|-------------|----------|---------|---------|
|
|
1246
|
-
| colorScale | Color to use for the scale | false | - | `green` |
|
|
1247
|
-
| colorMin | Set a minimum for the scale. Any values below that minimum will appear in the lowest color on the scale | false | number | min of column |
|
|
1248
|
-
| colorMid | Set a midpoint for the scale | false | number | mid of column |
|
|
1249
|
-
| colorMax | Set a maximum for the scale. Any values above that maximum will appear in the highest color on the scale | false | number | max of column |
|
|
1250
|
-
| colorBreakpoints | List of numbers to use as breakpoints for each color in your color scale. Should line up with the colors you provide in `colorScale` | false | list of numbers | - |
|
|
1251
|
-
| scaleColumn | Column or expression to use to define the color scale range. Values in this column will have their cell color determined by the value in the scaleColumn | false | column name, stored expression name, GSQL expression | - |
|
|
1252
|
-
|
|
1253
|
-
## Input components
|
|
1254
|
-
|
|
1255
|
-
### Text input
|
|
1256
|
-
|
|
1257
|
-
Creates a text input that can be used to filter or search.
|
|
1258
|
-
|
|
1259
|
-
Here's an example:
|
|
1260
|
-
|
|
1261
|
-
```markdown
|
|
1262
|
-
<TextInput
|
|
1263
|
-
name=name_of_input
|
|
1264
|
-
title=Search
|
|
1265
|
-
/>
|
|
1266
|
-
```
|
|
1267
|
-
|
|
1268
|
-
The user-inputted text would then be referenced in GSQL via `$name_of_input`. For example:
|
|
1269
|
-
|
|
1270
|
-
```sql
|
|
1271
|
-
select *
|
|
1272
|
-
from users
|
|
1273
|
-
where email ilike concat('%', $name_of_input, '%')
|
|
1274
|
-
```
|
|
1275
|
-
|
|
1276
|
-
#### All text input attributes
|
|
1277
|
-
|
|
1278
|
-
| Attribute | Description | Required | Options | Default |
|
|
1279
|
-
|------|-------------|----------|---------|---------|
|
|
1280
|
-
| name | Name of the text input, used to reference the selected value elsewhere as `"$name"` | true | string | - |
|
|
1281
|
-
| title | Title displayed above the text input | false | string | - |
|
|
1282
|
-
| placeholder | Alternative placeholder text displayed in the text input | false | string | `"Type to search"` |
|
|
1283
|
-
| hideDuringPrint | Hide the component when the report is printed | false | `true`, `false` | `true` |
|
|
1284
|
-
| description | Adds an info icon with description tooltip on hover | false | string | - |
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
### Dropdown
|
|
1288
|
-
|
|
1289
|
-
Creates a dropdown menu with a list of options that can be selected. The selected option can be used to filter queries or in markdown.
|
|
1290
|
-
|
|
1291
|
-
Here's an example:
|
|
1292
|
-
|
|
1293
|
-
````markdown
|
|
1294
|
-
```sql statuses
|
|
1295
|
-
select distinct status from orders
|
|
1296
|
-
```
|
|
1297
|
-
|
|
1298
|
-
<Dropdown
|
|
1299
|
-
title="Select Order Status"
|
|
1300
|
-
name="status_dropdown"
|
|
1301
|
-
data="statuses"
|
|
1302
|
-
value="status"
|
|
1303
|
-
defaultValue="Complete"
|
|
1304
|
-
/>
|
|
1305
|
-
````
|
|
1306
|
-
|
|
1307
|
-
The user-selected value would then be referenced in GSQL as `$status_dropdown`. For example:
|
|
1308
|
-
|
|
1309
|
-
```sql
|
|
1310
|
-
select *
|
|
1311
|
-
from orders
|
|
1312
|
-
where status = $status_dropdown
|
|
1313
|
-
```
|
|
1314
|
-
|
|
1315
|
-
#### All dropdown attributes
|
|
1316
|
-
|
|
1317
|
-
| Attribute | Description | Required | Options | Default |
|
|
1318
|
-
|------|-------------|----------|---------|---------|
|
|
1319
|
-
| name | Name of the dropdown, used to reference the selected value elsewhere as `"$name"` | true | - | - |
|
|
1320
|
-
| data | GSQL query or table name | false | query name | - |
|
|
1321
|
-
| value | Column name from the query containing values to pick from | false | column name | - |
|
|
1322
|
-
| multiple | Enables multi-select which returns a list | false | `true`, `false` | `false` |
|
|
1323
|
-
| 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"` | - |
|
|
1324
|
-
| selectAllByDefault | Selects and returns all values, multiple attribute required | false | `true`, `false` | `false` |
|
|
1325
|
-
| noDefault | Stops any default from being selected. Overrides any set `defaultValue`. | false | boolean | `false` |
|
|
1326
|
-
| disableSelectAll | Removes the `"Select all"` button. Recommended for large datasets. | false | boolean | `false` |
|
|
1327
|
-
| 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 |
|
|
1328
|
-
| title | Title to display above the dropdown | false | string | - |
|
|
1329
|
-
| order | Column to sort options by, with optional ordering keyword | false | column name [ `asc`, `desc` ] | Ascending based on dropdown value (or label, if specified) |
|
|
1330
|
-
| where | SQL where fragment to filter options by (e.g., where sales > 40000) | false | SQL where clause | - |
|
|
1331
|
-
| hideDuringPrint | Hide the component when the report is printed | false | `true`, `false` | `true` |
|
|
1332
|
-
| description | Adds an info icon with description tooltip on hover | false | string | - |
|
|
1333
|
-
|
|
1334
|
-
##### DropdownOption
|
|
1335
|
-
|
|
1336
|
-
The `DropdownOption` sub-component can be used to manually add options to a dropdown. This is useful to add a default option, or to add options that are not in a query.
|
|
1337
|
-
|
|
1338
|
-
Here's an example:
|
|
1339
|
-
|
|
1340
|
-
```markdown
|
|
1341
|
-
<Dropdown name=hardcoded>
|
|
1342
|
-
<DropdownOption valueLabel="Option One" value=1 />
|
|
1343
|
-
<DropdownOption valueLabel="Option Two" value=2 />
|
|
1344
|
-
<DropdownOption valueLabel="Option Three" value=3 />
|
|
1345
|
-
</Dropdown>
|
|
1346
|
-
```
|
|
1347
|
-
|
|
1348
|
-
| Attribute | Description | Required | Options | Default |
|
|
1349
|
-
|------|-------------|----------|---------|---------|
|
|
1350
|
-
| value | Value to use when the option is selected | true | - | - |
|
|
1351
|
-
| valueLabel | Label to display for the option in the dropdown | false | - | Uses the value |
|
|
1352
|
-
|
|
1353
|
-
## Other components
|
|
1354
|
-
|
|
1355
|
-
`<Row></Row>` - Evenly distributes components inside along the same row.
|
|
1356
|
-
|
|
1357
|
-
## Value formatting
|
|
1358
|
-
|
|
1359
|
-
The easiest way to format numbers and dates in Graphene is through component attributes. You can pass in either of the following:
|
|
1360
|
-
|
|
1361
|
-
* [Excel-style format codes](https://support.microsoft.com/en-us/office/number-format-codes-in-excel-for-mac-5026bbd6-04bc-48cd-bf33-80f18b4eae68) (e.g., `fmt="$#,##0.0"`)
|
|
1362
|
-
* [Graphene's built-in formats](#built-in-formats) (e.g., `fmt=usd2k`)
|
|
1363
|
-
|
|
1364
|
-
For example, you can use the `fmt` attribute to format values inside a BigValue component:
|
|
1365
|
-
|
|
1366
|
-
```markdown
|
|
1367
|
-
<BigValue
|
|
1368
|
-
data=sales_data
|
|
1369
|
-
value=sales
|
|
1370
|
-
fmt="$#,##0"
|
|
1371
|
-
/>
|
|
1372
|
-
```
|
|
1373
|
-
|
|
1374
|
-
Within charts, you can format individual columns using `xFmt` and `yFmt`:
|
|
1375
|
-
|
|
1376
|
-
```markdown
|
|
1377
|
-
<LineChart
|
|
1378
|
-
data=sales_data
|
|
1379
|
-
x=date
|
|
1380
|
-
y=sales
|
|
1381
|
-
xFmt="m/d"
|
|
1382
|
-
yFmt=eur
|
|
1383
|
-
/>
|
|
1384
|
-
```
|
|
1385
|
-
|
|
1386
|
-
In the example above, `xFmt` is passing in an Excel-style code to format the dates and `yFmt` is referencing a built-in format (see the full list of supported formats below).
|
|
1387
|
-
|
|
1388
|
-
**Date formatting**
|
|
1389
|
-
|
|
1390
|
-
Formatting does not apply to the date axis of a chart. For example, if you set `xFmt` to `"m/d/yy"`, you will only see that formatting reflected in your chart tooltips and annotations. This is to ensure that the chart axis labels have the correct spacing.
|
|
1391
|
-
|
|
1392
|
-
### Built-in Formats
|
|
1393
|
-
|
|
1394
|
-
Graphene supports a variety of date/time, number, percentage, and currency formats.
|
|
1395
|
-
|
|
1396
|
-
#### Auto-Formatting
|
|
1397
|
-
|
|
1398
|
-
Wherever you see `auto` listed beside a format, that means Graphene will automatically format your value based on the context it is in.
|
|
1399
|
-
|
|
1400
|
-
For example, Graphene automatically formats large numbers into shortened versions based on the size of the median number in a column (e.g., 4,000,000 → 4M).
|
|
1401
|
-
|
|
1402
|
-
You can choose to handle these numbers differently by choosing a specific format code. For example, if Graphene is formatting a column as millions, but you want to see all numbers in thousands, you could use the `num0k` format, which will show all numbers in the column in thousands with 0 decimal places.
|
|
1403
|
-
|
|
1404
|
-
#### Dates
|
|
1405
|
-
|
|
1406
|
-
Graphene supports the following date formats:
|
|
1407
|
-
|
|
1408
|
-
* `ddd` - Short day name (e.g., Mon, Tue)
|
|
1409
|
-
* `dddd` - Full day name (e.g., Monday, Tuesday)
|
|
1410
|
-
* `mmm` - Short month name (e.g., Jan, Feb)
|
|
1411
|
-
* `mmmm` - Full month name (e.g., January, February)
|
|
1412
|
-
* `yyyy` - Four-digit year
|
|
1413
|
-
* `shortdate` - Short date format (e.g., Jan 9/22)
|
|
1414
|
-
* `longdate` - Long date format (e.g., January 9, 2022)
|
|
1415
|
-
* `fulldate` - Full date format (e.g., Monday January 9, 2022)
|
|
1416
|
-
* `mdy` - Month/day/year (e.g., 1/9/22)
|
|
1417
|
-
* `dmy` - Day/month/year (e.g., 9/1/22)
|
|
1418
|
-
* `hms` - Time format (e.g., 11:45:03 AM)
|
|
1419
|
-
|
|
1420
|
-
#### Currencies
|
|
1421
|
-
|
|
1422
|
-
Supported currencies include USD, AUD, BRL, CAD, CNY, EUR, GBP, JPY, INR, KRW, NGN, RUB, and SEK.
|
|
1423
|
-
|
|
1424
|
-
In order to use currency tags, use the currency code, optionally appended with:
|
|
1425
|
-
|
|
1426
|
-
* a number indicating the number of decimal places to show (0-2)
|
|
1427
|
-
* a letter indicating the order of magnitude to show ("","k", "m", "b")
|
|
1428
|
-
|
|
1429
|
-
For example, the available tags for USD are:
|
|
1430
|
-
|
|
1431
|
-
* `usd` (auto) - Automatically formats based on value size
|
|
1432
|
-
* `usd0`, `usd1`, `usd2` - USD with 0, 1, or 2 decimal places
|
|
1433
|
-
* `usd0k`, `usd1k`, `usd2k` - USD in thousands (e.g., $64k)
|
|
1434
|
-
* `usd0m`, `usd1m`, `usd2m` - USD in millions (e.g., $42M)
|
|
1435
|
-
* `usd0b`, `usd1b`, `usd2b` - USD in billions (e.g., $1B)
|
|
1436
|
-
|
|
1437
|
-
Similar patterns apply to other supported currencies.
|
|
1438
|
-
|
|
1439
|
-
#### Numbers
|
|
1440
|
-
|
|
1441
|
-
The default number format (when no `fmt` is specified) automatically handles decimal places and summary units (in the same way that `usd` does for currency).
|
|
1442
|
-
|
|
1443
|
-
Available number formats:
|
|
1444
|
-
|
|
1445
|
-
* `num0`, `num1`, `num2`, `num3`, `num4` - Numbers with 0-4 decimal places
|
|
1446
|
-
* `num0k`, `num1k`, `num2k` - Numbers in thousands (e.g., 64k)
|
|
1447
|
-
* `num0m`, `num1m`, `num2m` - Numbers in millions (e.g., 42M)
|
|
1448
|
-
* `num0b`, `num1b`, `num2b` - Numbers in billions (e.g., 1B)
|
|
1449
|
-
* `id` - Integer format for IDs
|
|
1450
|
-
* `fract` - Fraction format
|
|
1451
|
-
* `mult`, `mult0`, `mult1`, `mult2` - Multiplier format (e.g., 5.32x)
|
|
1452
|
-
* `sci` - Scientific notation
|
|
1453
|
-
|
|
1454
|
-
#### Percentages
|
|
1455
|
-
|
|
1456
|
-
Available percentage formats:
|
|
1457
|
-
|
|
1458
|
-
* `pct` (auto) - Automatically formats percentages based on value
|
|
1459
|
-
* `pct0` - Percentage with 0 decimal places (e.g., 73%)
|
|
1460
|
-
* `pct1` - Percentage with 1 decimal place (e.g., 73.1%)
|
|
1461
|
-
* `pct2` - Percentage with 2 decimal places (e.g., 73.10%)
|
|
1462
|
-
* `pct3` - Percentage with 3 decimal places (e.g., 73.100%)
|