Skip to content

Commit a7516be

Browse files
committed
Keep chart options and basic charts next to their examples
1 parent f650da4 commit a7516be

10 files changed

Lines changed: 277 additions & 99 deletions

File tree

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
---
2+
icon: timeline
3+
category: display-data
4+
summary: Plot query results as line, area, bar, or pie charts.
5+
top:
6+
- class
7+
- name: color
8+
type: COLOR
9+
description: The name of a color in which to display the chart. If there are multiple series in the chart,
10+
this parameter can be repeated multiple times.
11+
- name: height
12+
type: INTEGER
13+
description: 'Height of the chart, in pixels. By default: 250'
14+
- name: horizontal
15+
type: BOOLEAN
16+
description: Displays a bar chart with horizontal bars instead of vertical ones.
17+
- id
18+
- name: labels
19+
type: BOOLEAN
20+
description: Whether to show the data labels on the chart or not.
21+
- name: logarithmic
22+
type: BOOLEAN
23+
description: Display the y-axis in logarithmic scale.
24+
- name: marker
25+
type: REAL
26+
description: Marker size
27+
- name: show_legend
28+
type: BOOLEAN
29+
description: Whether to display the legend listing all chart series. Defaults to true.
30+
- name: stacked
31+
type: BOOLEAN
32+
description: Whether to cumulate values from different series. Supported by the "line", "area" and "bar"
33+
chart types, and ignored by the others. Series are aligned on their x values, and a series that has no
34+
value for a given x counts as zero there.
35+
- name: time
36+
type: BOOLEAN
37+
description: Whether the x-axis represents time. If set to true, the x values will be parsed and formatted
38+
as dates for the user.
39+
- name: title
40+
type: TEXT
41+
description: The name of the chart.
42+
- name: toolbar
43+
type: BOOLEAN
44+
description: Whether to display a toolbar at the top right of the chart, that offers downloading the data
45+
as CSV.
46+
- name: type
47+
type: TEXT
48+
required: true
49+
description: 'The type of chart. One of: "line", "area", "bar", "column", "pie", "scatter", "bubble", "heatmap",
50+
"rangeBar". "column" is a synonym of "bar".'
51+
- name: xmax
52+
type: TEXT
53+
description: The maximum value for the x-axis. When time is true, this can be a date or timestamp.
54+
- name: xmin
55+
type: TEXT
56+
description: The minimal value for the x-axis. When time is true, this can be a date or timestamp.
57+
- name: xticks
58+
type: INTEGER
59+
description: Number of intervals used to generate a numeric x-axis, normally producing one more tick position.
60+
On category and time axes, this is a target for label density, so the visible label count may differ.
61+
- name: xtitle
62+
type: TEXT
63+
description: Title of the x axis, displayed below it.
64+
- name: ymax
65+
type: REAL
66+
description: The maximum value for the y-axis.
67+
- name: ymin
68+
type: REAL
69+
description: The minimal value for the y-axis.
70+
- name: ystep
71+
type: REAL
72+
description: Step between ticks on the y axis.
73+
- name: yticks
74+
type: INTEGER
75+
description: Number of ticks on the y axis.
76+
- name: ytitle
77+
type: TEXT
78+
description: Title of the y axis, displayed to its left.
79+
- name: ztitle
80+
type: TEXT
81+
description: Title of the z axis, displayed in tooltips.
82+
row:
83+
- name: color
84+
type: COLOR
85+
description: 'The name of a color for what this row draws: the bar, slice or point it plots, or the reference
86+
line it draws. Defaults to the color of the series for a data point, and to grey for a reference line.'
87+
- name: label
88+
type: TEXT
89+
description: An alias for parameter "x". On a row that draws a reference line, the text to display next
90+
to the line. Labels are plain text; HTML markup is displayed literally.
91+
- name: link
92+
type: URL
93+
description: A URL to open when the data point is clicked. The tooltip value also links to the point, as
94+
does a text x value when shown as the tooltip title.
95+
- name: series
96+
type: TEXT
97+
description: If multiple series are represented and share the same y-axis, this parameter can be used to
98+
distinguish between them. Series names are plain text; HTML markup is displayed literally.
99+
- name: value
100+
type: REAL
101+
description: An alias for parameter "y"
102+
- name: x
103+
type: REAL
104+
required: true
105+
description: The value of the point on the horizontal axis. Numeric values use continuous, proportionate
106+
positioning; text values are evenly spaced categories. Set the top-level time property for dates and
107+
timestamps.
108+
- name: xline
109+
type: TEXT
110+
description: Draws a reference line across the chart at this position of the x axis instead of plotting
111+
a point, to mark an event such as a deployment. A date or a timestamp when time is set, otherwise one
112+
of the x values.
113+
- name: xline_end
114+
type: TEXT
115+
description: Makes the xline a band instead of a line, reaching to this value.
116+
- name: y
117+
type: REAL
118+
required: true
119+
description: The value of the point on the vertical axis
120+
- name: yline
121+
type: REAL
122+
description: Draws a reference line across the chart at this value of the y axis instead of plotting a
123+
point, to show a limit such as a quota or an alarm threshold. Not drawn if it falls outside of the axis,
124+
so set ymax when the limit is above the data.
125+
- name: yline_end
126+
type: REAL
127+
description: Makes the yline a band instead of a line, reaching to this value.
128+
- name: z
129+
type: REAL
130+
description: A third value carried by the point. Used as the bubble radius in a bubble chart, and shown
131+
in the tooltip under the name given by the top-level "ztitle".
132+
---
133+
134+
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.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
rows:
3+
- component: chart
4+
title: Quarterly Revenue
5+
type: area
6+
color: blue-lt
7+
marker: 5
8+
time: true
9+
- x: '2022-01-01T00:00:00Z'
10+
y: 15
11+
- x: '2022-04-01T00:00:00Z'
12+
y: 46
13+
- x: '2022-07-01T00:00:00Z'
14+
y: 23
15+
- x: '2022-10-01T00:00:00Z'
16+
y: 70
17+
- x: '2023-01-01T00:00:00Z'
18+
y: 35
19+
- x: '2023-04-01T00:00:00Z'
20+
y: 106
21+
- x: '2023-07-01T00:00:00Z'
22+
y: 53
23+
---
24+
25+
An area chart representing a time series, using the top-level property `time`.
26+
Ticks on the x axis are adjusted automatically, and ISO datetimes are parsed and displayed in a readable format.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
rows:
3+
- component: chart
4+
title: Answers
5+
type: pie
6+
labels: true
7+
- label: 'Yes'
8+
value: 65
9+
- label: 'No'
10+
value: 35
11+
---
12+
13+
A pie chart.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
rows:
3+
- component: chart
4+
type: bar
5+
title: Quarterly Results
6+
horizontal: true
7+
labels: true
8+
- label: Tom
9+
value: 35
10+
- label: Olive
11+
value: 15
12+
---
13+
14+
A basic bar chart
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
rows:
3+
- component: chart
4+
type: treemap
5+
title: Quarterly Results By Region (in k$)
6+
labels: true
7+
- series: North America
8+
label: United States
9+
value: 35
10+
- series: North America
11+
label: Canada
12+
value: 15
13+
- series: Europe
14+
label: France
15+
value: 30
16+
- series: Europe
17+
label: Germany
18+
value: 55
19+
- series: Asia
20+
label: China
21+
value: 20
22+
- series: Asia
23+
label: Japan
24+
value: 10
25+
---
26+
27+
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.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
rows:
3+
- component: chart
4+
title: Expenses
5+
type: bar
6+
stacked: true
7+
toolbar: true
8+
show_legend: false
9+
ystep: 10
10+
- series: Marketing
11+
x: 2021
12+
value: 35
13+
- series: Marketing
14+
x: 2022
15+
value: 15
16+
- series: Human resources
17+
x: 2021
18+
value: 30
19+
- series: Human resources
20+
x: 2022
21+
value: 55
22+
---
23+
24+
A bar chart with multiple series.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
rows:
3+
- component: chart
4+
title: Power draw
5+
type: area
6+
stacked: true
7+
time: true
8+
ytitle: watts
9+
color:
10+
- blue
11+
- teal
12+
marker: 4
13+
- series: CPU
14+
x: '2024-03-01T10:00:00Z'
15+
value: 45
16+
- series: CPU
17+
x: '2024-03-01T10:15:00Z'
18+
value: 52
19+
- series: CPU
20+
x: '2024-03-01T10:30:00Z'
21+
value: 48
22+
- series: CPU
23+
x: '2024-03-01T10:45:00Z'
24+
value: 44
25+
- series: GPU
26+
x: '2024-03-01T10:15:00Z'
27+
value: 120
28+
- series: GPU
29+
x: '2024-03-01T10:30:00Z'
30+
value: 140
31+
---
32+
33+
A stacked area chart, showing how each series contributes to a total.
34+
The `stacked` property also works with the `line` and `bar` chart types.
35+
36+
Series are aligned on their `x` values, and a series that has no value for a given `x` counts as zero there:
37+
below, the graphics card draws no power outside of the render.
38+
If a missing value does not mean zero in your data, make all the series share the same `x` values,
39+
for instance by rounding timestamps to a common interval.

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

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -138,102 +138,6 @@ INSERT INTO example(component, description, properties) VALUES
138138
{"title": "Encyclopedia", "link":"https://wikipedia.org", "description": "Wikipedia", "color": "blue", "icon":"world", "footer": "Owned by the Wikimedia Foundation"}
139139
]'));
140140

141-
INSERT INTO component(name, icon, description) VALUES
142-
('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.');
143-
144-
INSERT INTO parameter(component, name, description, type, top_level, optional) SELECT 'chart', * FROM (VALUES
145-
-- top level
146-
('title', 'The name of the chart.', 'TEXT', TRUE, TRUE),
147-
('type', 'The type of chart. One of: "line", "area", "bar", "column", "pie", "scatter", "bubble", "heatmap", "rangeBar". "column" is a synonym of "bar".', 'TEXT', TRUE, FALSE),
148-
('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),
149-
('xmin', 'The minimal value for the x-axis. When time is true, this can be a date or timestamp.', 'TEXT', TRUE, TRUE),
150-
('xmax', 'The maximum value for the x-axis. When time is true, this can be a date or timestamp.', 'TEXT', TRUE, TRUE),
151-
('ymin', 'The minimal value for the y-axis.', 'REAL', TRUE, TRUE),
152-
('ymax', 'The maximum value for the y-axis.', 'REAL', TRUE, TRUE),
153-
('xtitle', 'Title of the x axis, displayed below it.', 'TEXT', TRUE, TRUE),
154-
('ytitle', 'Title of the y axis, displayed to its left.', 'TEXT', TRUE, TRUE),
155-
('ztitle', 'Title of the z axis, displayed in tooltips.', 'TEXT', TRUE, TRUE),
156-
('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),
157-
('yticks', 'Number of ticks on the y axis.', 'INTEGER', TRUE, TRUE),
158-
('ystep', 'Step between ticks on the y axis.', 'REAL', TRUE, TRUE),
159-
('marker', 'Marker size', 'REAL', TRUE, TRUE),
160-
('labels', 'Whether to show the data labels on the chart or not.', 'BOOLEAN', TRUE, TRUE),
161-
('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),
162-
('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),
163-
('toolbar', 'Whether to display a toolbar at the top right of the chart, that offers downloading the data as CSV.', 'BOOLEAN', TRUE, TRUE),
164-
('show_legend', 'Whether to display the legend listing all chart series. Defaults to true.', 'BOOLEAN', TRUE, TRUE),
165-
('logarithmic', 'Display the y-axis in logarithmic scale.', 'BOOLEAN', TRUE, TRUE),
166-
('horizontal', 'Displays a bar chart with horizontal bars instead of vertical ones.', 'BOOLEAN', TRUE, TRUE),
167-
('height', 'Height of the chart, in pixels. By default: 250', 'INTEGER', TRUE, TRUE),
168-
-- item level
169-
('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),
170-
('y', 'The value of the point on the vertical axis', 'REAL', FALSE, FALSE),
171-
('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),
172-
('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),
173-
('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),
174-
('value', 'An alias for parameter "y"', 'REAL', FALSE, TRUE),
175-
('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),
176-
('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),
177-
('yline_end', 'Makes the yline a band instead of a line, reaching to this value.', 'REAL', FALSE, TRUE),
178-
('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),
179-
('xline_end', 'Makes the xline a band instead of a line, reaching to this value.', 'TEXT', FALSE, TRUE),
180-
('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)
181-
) x;
182-
INSERT INTO example(component, description, properties) VALUES
183-
('chart', 'An area chart representing a time series, using the top-level property `time`.
184-
Ticks on the x axis are adjusted automatically, and ISO datetimes are parsed and displayed in a readable format.', json('[
185-
{
186-
"component": "chart",
187-
"title": "Quarterly Revenue",
188-
"type": "area",
189-
"color": "blue-lt",
190-
"marker": 5,
191-
"time": true
192-
},
193-
{"x":"2022-01-01T00:00:00Z","y":15},
194-
{"x":"2022-04-01T00:00:00Z","y":46},
195-
{"x":"2022-07-01T00:00:00Z","y":23},
196-
{"x":"2022-10-01T00:00:00Z","y":70},
197-
{"x":"2023-01-01T00:00:00Z","y":35},
198-
{"x":"2023-04-01T00:00:00Z","y":106},
199-
{"x":"2023-07-01T00:00:00Z","y":53}
200-
]')),
201-
('chart', 'A pie chart.', json('[{"component":"chart", "title": "Answers", "type": "pie", "labels": true},
202-
{"label": "Yes", "value": 65},
203-
{"label": "No", "value": 35}]')),
204-
('chart', 'A basic bar chart', json('[
205-
{"component":"chart", "type": "bar", "title": "Quarterly Results", "horizontal": true, "labels": true},
206-
{"label": "Tom", "value": 35}, {"label": "Olive", "value": 15}]')),
207-
('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.',
208-
json('[
209-
{"component":"chart", "type": "treemap", "title": "Quarterly Results By Region (in k$)", "labels": true },
210-
{"series": "North America", "label": "United States", "value": 35},
211-
{"series": "North America", "label": "Canada", "value": 15},
212-
{"series": "Europe", "label": "France", "value": 30},
213-
{"series": "Europe", "label": "Germany", "value": 55},
214-
{"series": "Asia", "label": "China", "value": 20},
215-
{"series": "Asia", "label": "Japan", "value": 10}
216-
]')),
217-
('chart', 'A bar chart with multiple series.', json('[{"component":"chart", "title": "Expenses", "type": "bar", "stacked": true, "toolbar": true, "show_legend": false, "ystep": 10}, '||
218-
'{"series": "Marketing", "x": 2021, "value": 35}, '||
219-
'{"series": "Marketing", "x": 2022, "value": 15}, '||
220-
'{"series": "Human resources", "x": 2021, "value": 30}, '||
221-
'{"series": "Human resources", "x": 2022, "value": 55}]')),
222-
('chart', 'A stacked area chart, showing how each series contributes to a total.
223-
The `stacked` property also works with the `line` and `bar` chart types.
224-
225-
Series are aligned on their `x` values, and a series that has no value for a given `x` counts as zero there:
226-
below, the graphics card draws no power outside of the render.
227-
If a missing value does not mean zero in your data, make all the series share the same `x` values,
228-
for instance by rounding timestamps to a common interval.',
229-
json('[{"component":"chart", "title": "Power draw", "type": "area", "stacked": true, "time": true, "ytitle": "watts", "color": ["blue", "teal"], "marker": 4}, '||
230-
'{"series": "CPU", "x": "2024-03-01T10:00:00Z", "value": 45}, '||
231-
'{"series": "CPU", "x": "2024-03-01T10:15:00Z", "value": 52}, '||
232-
'{"series": "CPU", "x": "2024-03-01T10:30:00Z", "value": 48}, '||
233-
'{"series": "CPU", "x": "2024-03-01T10:45:00Z", "value": 44}, '||
234-
'{"series": "GPU", "x": "2024-03-01T10:15:00Z", "value": 120}, '||
235-
'{"series": "GPU", "x": "2024-03-01T10:30:00Z", "value": 140}]'));
236-
237141

238142

239143
INSERT INTO component(name, icon, description) VALUES

‎examples/official-site/sqlpage/migrations/82_reference_catalog.sql‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ WITH copy(name, category, summary) AS (VALUES
2929
('big_number', 'display-data', 'Highlight a metric with a trend or progress indicator.'),
3030
('card', 'display-data', 'Arrange records in cards with images, links, or embedded content.'),
3131
('carousel', 'display-data', 'Show a slideshow of images with optional captions and controls.'),
32-
('chart', 'display-data', 'Plot query results as line, area, bar, or pie charts.'),
3332
('datagrid', 'display-data', 'Lay out labeled values in a compact grid.'),
3433
('list', 'display-data', 'Present rows as a vertical list with optional links and icons.'),
3534
('map', 'display-data', 'Plot locations and geographic shapes on an interactive map.'),

0 commit comments

Comments
 (0)