Skip to content

Commit 07d26b7

Browse files
committed
New chart type: horizontal bar charts
1 parent 57f10cd commit 07d26b7

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
291291
('labels', 'Whether to show the data labels on the chart or not.', 'BOOLEAN', TRUE, TRUE),
292292
('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.', 'TEXT', TRUE, TRUE),
293293
('stacked', 'Whether to cumulate values from different series.', 'BOOLEAN', TRUE, TRUE),
294-
('logarithmic', 'Display the y-axis in logarithmic scale..', 'BOOLEAN', TRUE, TRUE),
294+
('logarithmic', 'Display the y-axis in logarithmic scale.', 'BOOLEAN', TRUE, TRUE),
295+
('horizontal', 'Displays a bar chart with horizontal bars instead of vertical ones.', 'BOOLEAN', TRUE, TRUE),
295296
-- item level
296297
('x', 'The value of the point on the horizontal axis', 'NUMBER', FALSE, FALSE),
297298
('y', 'The value of the point on the vertical axis', 'NUMBER', FALSE, FALSE),
@@ -305,6 +306,8 @@ INSERT INTO example(component, description, properties) VALUES
305306
('chart', 'A pie chart.', json('[{"component":"chart", "title": "Answers", "type": "pie", "labels": true}, '||
306307
'{"label": "Yes", "value": 65}, '||
307308
'{"label": "No", "value": 35}]')),
309+
('chart', 'A basic bar chart', json('[{"component":"chart", "type": "bar", "title": "Quarterly Results", "horizontal": true}, '||
310+
'{"label": "Tom", "value": -35}, {"label": "Olive", "value": 15}]')),
308311
('chart', 'A bar chart with multiple series.', json('[{"component":"chart", "title": "Expenses", "type": "bar", "stacked": true}, '||
309312
'{"series": "Marketing", "x": 2021, "value": 35}, '||
310313
'{"series": "Marketing", "x": 2022, "value": 15}, '||

sqlpage/sqlpage.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function sqlpage_chart() {
4444
})
4545
if (data.xmin == null) data.xmin = undefined;
4646
if (data.xmax == null) data.xmax = undefined;
47-
if (data.ymin == null) data.ymin = 0;
47+
if (data.ymin == null) data.ymin = undefined;
4848
if (data.ymax == null) data.ymax = undefined;
4949

5050
const colors = [
@@ -126,6 +126,7 @@ function sqlpage_chart() {
126126
tooltip: {
127127
fillSeriesColor: false,
128128
},
129+
bar: { horizontal: !!data.horizontal },
129130
colors,
130131
series,
131132
};

sqlpage/templates/chart.handlebars

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"xmax": {{stringify xmax}},
2424
"ymax": {{stringify ymax}},
2525
"logarithmic": {{stringify logarithmic}},
26+
"horizontal": {{stringify horizontal}},
2627
"stacked": {{stringify stacked}},
2728
"height": {{stringify (default height 250)}},
2829
"colors": {{stringify (to_array color)}},

0 commit comments

Comments
 (0)