mirror of
https://github.com/h-sphere/sql-seal-charts.git
synced 2026-07-22 05:37:34 +00:00
docs: adding few extra pages
This commit is contained in:
parent
39543065fa
commit
732577fae5
4 changed files with 43 additions and 1 deletions
|
|
@ -25,7 +25,15 @@ export default defineConfig({
|
|||
{
|
||||
text: 'Documentation',
|
||||
items: [
|
||||
{ text: 'Quick Start', link: '/quick-start' }
|
||||
{ text: 'Quick Start', link: '/quick-start' },
|
||||
{ text: 'Syntax', link: '/syntax' }
|
||||
]
|
||||
},
|
||||
{
|
||||
text: 'Chart Types',
|
||||
items: [
|
||||
{ text: 'Line Chart', link: '/chart-type/line-chart' },
|
||||
{ text: 'Bar Chart', link: '/chart-type/bar-chart' }
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
# Bar Chart
|
||||
|
||||
Under construction.
|
||||
|
|
|
|||
|
|
@ -1 +1,3 @@
|
|||
# Line Chart
|
||||
|
||||
Under construction.
|
||||
|
|
|
|||
30
docs/syntax.md
Normal file
30
docs/syntax.md
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
# Syntax
|
||||
SQLSeal Charts uses [ECharts](https://echarts.apache.org/en/index.html) under the hood. It automatically exposes data returned by your SQL query as a `data` dataset in ECharts. This means you can generate plenty of charts without worrying too much about how the data is being passed down. For more complex use-cases, you can always refer to the data by column name, it's index or even filter it down to create separate data-sets for different series.
|
||||
To read more about datasets, [check out ECharts documentation](https://apache.github.io/echarts-handbook/en/concepts/dataset/).
|
||||
|
||||
## Variables
|
||||
In addition SQLSeal exposes data returned by SQLSeal Query in the following variables:
|
||||
| Variable Name | Description |
|
||||
| ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `data` | Array of objects containing raw data |
|
||||
| `columns` | array of column names |
|
||||
| Object for each column | You can refer to each of the column data by their name, i.e. for `SELECT category, amount FROM data` you can use `category` and `amount` columns |
|
||||
|
||||
## Functions
|
||||
Extra functions are exposed in SQLSeal Charts configuration object so you can use them:
|
||||
|
||||
| Function | Description |
|
||||
| ------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `column(name: string)` | Returns array of the values for a specified column |
|
||||
| `mean, max, min, uniq, uniqBy` | [Lodash](https://lodash.com/docs/4.17.15) functions to help with data processing |
|
||||
| `array(...arrays)` | creates subarrays from arrays, i.e. `array([1,2], [3,4 ]) == [[1,3], [2,4]]`. Useful when grouping multiple columns together when reshaping the data |
|
||||
| `assembleObjects(...definitions: { key: string, values: array }[])` | Assembles multiple arrays into array of objects using provided key values |
|
||||
| `assemble(definition: Record<string, array>)` | Assembles multiple arrays into array of objects using a key=>value map |
|
||||
|
||||
## JavaScript functionality
|
||||
Configuration has some basic JavaScript capabilities. For security reasons not all JavaScript syntax is available. This will change and more functions will be exposed.
|
||||
For now the following JavaScript syntax is enabled:
|
||||
- Arrow functions, i.e: `() => column('data')`
|
||||
- Template literals, i.e.: \`${column('data')[0]}\`
|
||||
|
||||
More functionality will get exposed soon.
|
||||
Loading…
Reference in a new issue