Skip to content

Commit 35e9450

Browse files
committed
add an example for heatmaps
1 parent 1359d8d commit 35e9450

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Add a new [configuration option](./configuration.md): `environment`. This allows you to set the environment in which SQLPage is running. It can be either `development` or `production`. In `production` mode, SQLPage will hide error messages and stack traces from the user, and will cache sql files in memory to avoid reloading them from disk when under heavy load.
1616
- Add support for `selected` in multi-select inputs in the [form](https://sql.ophir.dev/documentation.sql?component=form#component) component. This allows you to pre-select some options in a multi-select input.
1717
- New function: [`sqlpage.protocol`](https://sql.ophir.dev/functions.sql?function=protocol#function) to get the protocol used to access the current page. This is useful to build links that point to your own site, and work both in http and https.
18+
- Add an example to the documentation showing how to create heatmaps with the [chart](https://sql.ophir.dev/documentation.sql?component=chart#component) component.
1819

1920
## 0.17.0
2021

examples/official-site/sqlpage/migrations/01_documentation.sql

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,26 @@ INSERT INTO example(component, description, properties) VALUES
520520
{"series": "United States", "x": 2.3, "y": 21},
521521
{"series": "France", "x": 1.5, "y": 3},
522522
{"series": "South Africa", "x": 0.9, "y": 0.3}
523-
]'));
523+
]')),
524+
('chart', '
525+
## Heatmaps
526+
527+
You can build heatmaps using the `heatmap` top-level property.
528+
529+
The data format follows the [apexcharts heatmap format](https://apexcharts.com/angular-chart-demos/heatmap-charts/basic/),
530+
where each series is represented as a line in the chart:
531+
- The `x` property of each item will be used as the x-axis value.
532+
- The `series` property of each item will be used as the y-axis value.
533+
- The `y` property of each item will be used as the value to display in the heatmap
534+
535+
The `color` property sets the color of each series separately, in order.
536+
',json('[
537+
{"component":"chart", "title": "Survey Results", "type": "heatmap",
538+
"ytitle": "Database managemet system", "xtitle": "Year", "color": ["blue","blue","blue"]},
539+
{ "series": "PostgreSQL", "x": "2000", "y": 48},{ "series": "SQLite", "x": "2000", "y": 14},{ "series": "MySQL", "x": "2000", "y": 78},
540+
{ "series": "PostgreSQL", "x": "2010", "y": 65},{ "series": "SQLite", "x": "2010", "y": 22},{ "series": "MySQL", "x": "2010", "y": 83},
541+
{ "series": "PostgreSQL", "x": "2020", "y": 73},{ "series": "SQLite", "x": "2020", "y": 28},{ "series": "MySQL", "x": "2020", "y": 87}
542+
]'));
524543

525544
INSERT INTO component(name, icon, description) VALUES
526545
('table', 'table', 'A table with optional filtering and sorting. Unlike most others, this component does not have a fixed set of item properties, any property that is used will be rendered directly as a column in the table.');

sqlpage/apexcharts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function sqlpage_chart() {
1717
var category = null;
1818
series.forEach((s, s_i) => {
1919
const point = s.data[0];
20-
let new_point = { x: category, y: NaN };
20+
let new_point = { x: category, y: 0 };
2121
if (point) {
2222
if (category == null) category = point.x;
2323
if (category === point.x) {

0 commit comments

Comments
 (0)