Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 134 additions & 0 deletions examples/official-site/content/components/chart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
---
icon: timeline
category: display-data
summary: Plot query results as line, area, bar, or pie charts.
top:
- class
- name: color
type: COLOR
description: The name of a color in which to display the chart. If there are multiple series in the chart,
this parameter can be repeated multiple times.
- name: height
type: INTEGER
description: 'Height of the chart, in pixels. By default: 250'
- name: horizontal
type: BOOLEAN
description: Displays a bar chart with horizontal bars instead of vertical ones.
- id
- name: labels
type: BOOLEAN
description: Whether to show the data labels on the chart or not.
- name: logarithmic
type: BOOLEAN
description: Display the y-axis in logarithmic scale.
- name: marker
type: REAL
description: Marker size
- name: show_legend
type: BOOLEAN
description: Whether to display the legend listing all chart series. Defaults to true.
- name: stacked
type: BOOLEAN
description: Whether to cumulate values from different series. Supported by the "line", "area" and "bar"
chart types, and ignored by the others. Series are aligned on their x values, and a series that has no
value for a given x counts as zero there.
- name: time
type: BOOLEAN
description: Whether the x-axis represents time. If set to true, the x values will be parsed and formatted
as dates for the user.
- name: title
type: TEXT
description: The name of the chart.
- name: toolbar
type: BOOLEAN
description: Whether to display a toolbar at the top right of the chart, that offers downloading the data
as CSV.
- name: type
type: TEXT
required: true
description: 'The type of chart. One of: "line", "area", "bar", "column", "pie", "scatter", "bubble", "heatmap",
"rangeBar", or "treemap". "column" is a synonym of "bar".'
- name: xmax
type: TEXT
description: The maximum value for the x-axis. When time is true, this can be a date or timestamp.
- name: xmin
type: TEXT
description: The minimal value for the x-axis. When time is true, this can be a date or timestamp.
- name: xticks
type: INTEGER
description: Number of intervals used to generate a numeric x-axis, normally producing one more tick position.
On category and time axes, this is a target for label density, so the visible label count may differ.
- name: xtitle
type: TEXT
description: Title of the x axis, displayed below it.
- name: ymax
type: REAL
description: The maximum value for the y-axis.
- name: ymin
type: REAL
description: The minimal value for the y-axis.
- name: ystep
type: REAL
description: Step between ticks on the y axis.
- name: yticks
type: INTEGER
description: Number of ticks on the y axis.
- name: ytitle
type: TEXT
description: Title of the y axis, displayed to its left.
- name: ztitle
type: TEXT
description: Title of the z axis, displayed in tooltips.
row:
- name: color
type: COLOR
description: 'The name of a color for what this row draws: the bar, slice or point it plots, or the reference
line it draws. Defaults to the color of the series for a data point, and to grey for a reference line.'
- name: label
type: TEXT
description: An alias for parameter "x". On a row that draws a reference line, the text to display next
to the line. Labels are plain text; HTML markup is displayed literally.
- name: link
type: URL
description: A URL to open when the data point is clicked. The tooltip value also links to the point, as
does a text x value when shown as the tooltip title.
- name: series
type: TEXT
description: If multiple series are represented and share the same y-axis, this parameter can be used to
distinguish between them. Series names are plain text; HTML markup is displayed literally.
- name: value
type: REAL
description: An alias for parameter "y"
- name: x
type: REAL
required: true
description: The value of the point on the horizontal axis. Numeric values use continuous, proportionate
positioning; text values are evenly spaced categories. Set the top-level time property for dates and
timestamps.
- name: xline
type: TEXT
description: Draws a reference line across the chart at this position of the x axis instead of plotting
a point, to mark an event such as a deployment. A date or a timestamp when time is set, otherwise one
of the x values.
- name: xline_end
type: TEXT
description: Makes the xline a band instead of a line, reaching to this value.
- name: y
type: REAL
required: true
description: The value of the point on the vertical axis
- name: yline
type: REAL
description: Draws a reference line across the chart at this value of the y axis instead of plotting a
point, to show a limit such as a quota or an alarm threshold. Not drawn if it falls outside of the axis,
so set ymax when the limit is above the data.
- name: yline_end
type: REAL
description: Makes the yline a band instead of a line, reaching to this value.
- name: z
type: REAL
description: A third value carried by the point. Used as the bubble radius in a bubble chart, and shown
in the tooltip under the name given by the top-level "ztitle".
---

A component that plots data. Line, area, bar, and pie charts are all supported. Each item in the component is a data point in the graph.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
rows:
- component: chart
title: Quarterly Revenue
type: area
color: blue-lt
marker: 5
time: true
- x: '2022-01-01T00:00:00Z'
y: 15
- x: '2022-04-01T00:00:00Z'
y: 46
- x: '2022-07-01T00:00:00Z'
y: 23
- x: '2022-10-01T00:00:00Z'
y: 70
- x: '2023-01-01T00:00:00Z'
y: 35
- x: '2023-04-01T00:00:00Z'
y: 106
- x: '2023-07-01T00:00:00Z'
y: 53
---

An area chart representing a time series, using the top-level property `time`.
Ticks on the x axis are adjusted automatically, and ISO datetimes are parsed and displayed in a readable format.
13 changes: 13 additions & 0 deletions examples/official-site/content/components/chart/examples/02-pie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
rows:
- component: chart
title: Answers
type: pie
labels: true
- label: 'Yes'
value: 65
- label: 'No'
value: 35
---

A pie chart.
14 changes: 14 additions & 0 deletions examples/official-site/content/components/chart/examples/03-bar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
rows:
- component: chart
type: bar
title: Quarterly Results
horizontal: true
labels: true
- label: Tom
value: 35
- label: Olive
value: 15
---

A basic bar chart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
rows:
- component: chart
type: treemap
title: Quarterly Results By Region (in k$)
labels: true
- series: North America
label: United States
value: 35
- series: North America
label: Canada
value: 15
- series: Europe
label: France
value: 30
- series: Europe
label: Germany
value: 55
- series: Asia
label: China
value: 20
- series: Asia
label: Japan
value: 10
---

A TreeMap Chart allows you to display hierarchical data in a nested layout. This is useful for visualizing the proportion of each part to the whole.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
rows:
- component: chart
title: Expenses
type: bar
stacked: true
toolbar: true
show_legend: false
ystep: 10
- series: Marketing
x: 2021
value: 35
- series: Marketing
x: 2022
value: 15
- series: Human resources
x: 2021
value: 30
- series: Human resources
x: 2022
value: 55
---

A bar chart with multiple series.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
rows:
- component: chart
title: Power draw
type: area
stacked: true
time: true
ytitle: watts
color:
- blue
- teal
marker: 4
- series: CPU
x: '2024-03-01T10:00:00Z'
value: 45
- series: CPU
x: '2024-03-01T10:15:00Z'
value: 52
- series: CPU
x: '2024-03-01T10:30:00Z'
value: 48
- series: CPU
x: '2024-03-01T10:45:00Z'
value: 44
- series: GPU
x: '2024-03-01T10:15:00Z'
value: 120
- series: GPU
x: '2024-03-01T10:30:00Z'
value: 140
---

A stacked area chart, showing how each series contributes to a total.
The `stacked` property also works with the `line` and `bar` chart types.

Series are aligned on their `x` values, and a series that has no value for a given `x` counts as zero there:
below, the graphics card draws no power outside of the render.
If a missing value does not mean zero in your data, make all the series share the same `x` values,
for instance by rounding timestamps to a common interval.
96 changes: 0 additions & 96 deletions examples/official-site/sqlpage/migrations/01_documentation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -138,102 +138,6 @@ INSERT INTO example(component, description, properties) VALUES
{"title": "Encyclopedia", "link":"https://wikipedia.org", "description": "Wikipedia", "color": "blue", "icon":"world", "footer": "Owned by the Wikimedia Foundation"}
]'));

INSERT INTO component(name, icon, description) VALUES
('chart', 'timeline', 'A component that plots data. Line, area, bar, and pie charts are all supported. Each item in the component is a data point in the graph.');

INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'chart', * FROM (VALUES
-- top level
('title', 'The name of the chart.', 'TEXT', TRUE, TRUE),
('type', 'The type of chart. One of: "line", "area", "bar", "column", "pie", "scatter", "bubble", "heatmap", "rangeBar", or "treemap". "column" is a synonym of "bar".', 'TEXT', TRUE, FALSE),
('time', 'Whether the x-axis represents time. If set to true, the x values will be parsed and formatted as dates for the user.', 'BOOLEAN', TRUE, TRUE),
('xmin', 'The minimal value for the x-axis. When time is true, this can be a date or timestamp.', 'TEXT', TRUE, TRUE),
('xmax', 'The maximum value for the x-axis. When time is true, this can be a date or timestamp.', 'TEXT', TRUE, TRUE),
('ymin', 'The minimal value for the y-axis.', 'REAL', TRUE, TRUE),
('ymax', 'The maximum value for the y-axis.', 'REAL', TRUE, TRUE),
('xtitle', 'Title of the x axis, displayed below it.', 'TEXT', TRUE, TRUE),
('ytitle', 'Title of the y axis, displayed to its left.', 'TEXT', TRUE, TRUE),
('ztitle', 'Title of the z axis, displayed in tooltips.', 'TEXT', TRUE, TRUE),
('xticks', 'Number of intervals used to generate a numeric x-axis, normally producing one more tick position. On category and time axes, this is a target for label density, so the visible label count may differ.', 'INTEGER', TRUE, TRUE),
('yticks', 'Number of ticks on the y axis.', 'INTEGER', TRUE, TRUE),
('ystep', 'Step between ticks on the y axis.', 'REAL', TRUE, TRUE),
('marker', 'Marker size', 'REAL', TRUE, TRUE),
('labels', 'Whether to show the data labels on the chart or not.', 'BOOLEAN', TRUE, TRUE),
('color', 'The name of a color in which to display the chart. If there are multiple series in the chart, this parameter can be repeated multiple times.', 'COLOR', TRUE, TRUE),
('stacked', 'Whether to cumulate values from different series. Supported by the "line", "area" and "bar" chart types, and ignored by the others. Series are aligned on their x values, and a series that has no value for a given x counts as zero there.', 'BOOLEAN', TRUE, TRUE),
('toolbar', 'Whether to display a toolbar at the top right of the chart, that offers downloading the data as CSV.', 'BOOLEAN', TRUE, TRUE),
('show_legend', 'Whether to display the legend listing all chart series. Defaults to true.', 'BOOLEAN', TRUE, TRUE),
('logarithmic', 'Display the y-axis in logarithmic scale.', 'BOOLEAN', TRUE, TRUE),
('horizontal', 'Displays a bar chart with horizontal bars instead of vertical ones.', 'BOOLEAN', TRUE, TRUE),
('height', 'Height of the chart, in pixels. By default: 250', 'INTEGER', TRUE, TRUE),
-- item level
('x', 'The value of the point on the horizontal axis. Numeric values use continuous, proportionate positioning; text values are evenly spaced categories. Set the top-level time property for dates and timestamps.', 'REAL', FALSE, FALSE),
('y', 'The value of the point on the vertical axis', 'REAL', FALSE, FALSE),
('z', 'A third value carried by the point. Used as the bubble radius in a bubble chart, and shown in the tooltip under the name given by the top-level "ztitle".', 'REAL', FALSE, TRUE),
('link', 'A URL to open when the data point is clicked. The tooltip value also links to the point, as does a text x value when shown as the tooltip title.', 'URL', FALSE, TRUE),
('label', 'An alias for parameter "x". On a row that draws a reference line, the text to display next to the line. Labels are plain text; HTML markup is displayed literally.', 'TEXT', FALSE, TRUE),
('value', 'An alias for parameter "y"', 'REAL', FALSE, TRUE),
('series', 'If multiple series are represented and share the same y-axis, this parameter can be used to distinguish between them. Series names are plain text; HTML markup is displayed literally.', 'TEXT', FALSE, TRUE),
('yline', 'Draws a reference line across the chart at this value of the y axis instead of plotting a point, to show a limit such as a quota or an alarm threshold. Not drawn if it falls outside of the axis, so set ymax when the limit is above the data.', 'REAL', FALSE, TRUE),
('yline_end', 'Makes the yline a band instead of a line, reaching to this value.', 'REAL', FALSE, TRUE),
('xline', 'Draws a reference line across the chart at this position of the x axis instead of plotting a point, to mark an event such as a deployment. A date or a timestamp when time is set, otherwise one of the x values.', 'TEXT', FALSE, TRUE),
('xline_end', 'Makes the xline a band instead of a line, reaching to this value.', 'TEXT', FALSE, TRUE),
('color', 'The name of a color for what this row draws: the bar, slice or point it plots, or the reference line it draws. Defaults to the color of the series for a data point, and to grey for a reference line.', 'COLOR', FALSE, TRUE)
) x;
INSERT INTO example(component, description, properties) VALUES
('chart', 'An area chart representing a time series, using the top-level property `time`.
Ticks on the x axis are adjusted automatically, and ISO datetimes are parsed and displayed in a readable format.', json('[
{
"component": "chart",
"title": "Quarterly Revenue",
"type": "area",
"color": "blue-lt",
"marker": 5,
"time": true
},
{"x":"2022-01-01T00:00:00Z","y":15},
{"x":"2022-04-01T00:00:00Z","y":46},
{"x":"2022-07-01T00:00:00Z","y":23},
{"x":"2022-10-01T00:00:00Z","y":70},
{"x":"2023-01-01T00:00:00Z","y":35},
{"x":"2023-04-01T00:00:00Z","y":106},
{"x":"2023-07-01T00:00:00Z","y":53}
]')),
('chart', 'A pie chart.', json('[{"component":"chart", "title": "Answers", "type": "pie", "labels": true},
{"label": "Yes", "value": 65},
{"label": "No", "value": 35}]')),
('chart', 'A basic bar chart', json('[
{"component":"chart", "type": "bar", "title": "Quarterly Results", "horizontal": true, "labels": true},
{"label": "Tom", "value": 35}, {"label": "Olive", "value": 15}]')),
('chart', 'A TreeMap Chart allows you to display hierarchical data in a nested layout. This is useful for visualizing the proportion of each part to the whole.',
json('[
{"component":"chart", "type": "treemap", "title": "Quarterly Results By Region (in k$)", "labels": true },
{"series": "North America", "label": "United States", "value": 35},
{"series": "North America", "label": "Canada", "value": 15},
{"series": "Europe", "label": "France", "value": 30},
{"series": "Europe", "label": "Germany", "value": 55},
{"series": "Asia", "label": "China", "value": 20},
{"series": "Asia", "label": "Japan", "value": 10}
]')),
('chart', 'A bar chart with multiple series.', json('[{"component":"chart", "title": "Expenses", "type": "bar", "stacked": true, "toolbar": true, "show_legend": false, "ystep": 10}, '||
'{"series": "Marketing", "x": 2021, "value": 35}, '||
'{"series": "Marketing", "x": 2022, "value": 15}, '||
'{"series": "Human resources", "x": 2021, "value": 30}, '||
'{"series": "Human resources", "x": 2022, "value": 55}]')),
('chart', 'A stacked area chart, showing how each series contributes to a total.
The `stacked` property also works with the `line` and `bar` chart types.

Series are aligned on their `x` values, and a series that has no value for a given `x` counts as zero there:
below, the graphics card draws no power outside of the render.
If a missing value does not mean zero in your data, make all the series share the same `x` values,
for instance by rounding timestamps to a common interval.',
json('[{"component":"chart", "title": "Power draw", "type": "area", "stacked": true, "time": true, "ytitle": "watts", "color": ["blue", "teal"], "marker": 4}, '||
'{"series": "CPU", "x": "2024-03-01T10:00:00Z", "value": 45}, '||
'{"series": "CPU", "x": "2024-03-01T10:15:00Z", "value": 52}, '||
'{"series": "CPU", "x": "2024-03-01T10:30:00Z", "value": 48}, '||
'{"series": "CPU", "x": "2024-03-01T10:45:00Z", "value": 44}, '||
'{"series": "GPU", "x": "2024-03-01T10:15:00Z", "value": 120}, '||
'{"series": "GPU", "x": "2024-03-01T10:30:00Z", "value": 140}]'));



INSERT INTO component(name, icon, description) VALUES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ WITH copy(name, category, summary) AS (VALUES
('big_number', 'display-data', 'Highlight a metric with a trend or progress indicator.'),
('card', 'display-data', 'Arrange records in cards with images, links, or embedded content.'),
('carousel', 'display-data', 'Show a slideshow of images with optional captions and controls.'),
('chart', 'display-data', 'Plot query results as line, area, bar, or pie charts.'),
('datagrid', 'display-data', 'Lay out labeled values in a compact grid.'),
('list', 'display-data', 'Present rows as a vertical list with optional links and icons.'),
('map', 'display-data', 'Plot locations and geographic shapes on an interactive map.'),
Expand Down
Loading
Loading