Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
('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.', '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),
Expand Down Expand Up @@ -702,7 +703,7 @@ INSERT INTO example(component, description, properties) VALUES
{"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, "ystep": 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}, '||
Expand Down
3 changes: 3 additions & 0 deletions sqlpage/apexcharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ sqlpage_chart = (() => {
theme: {
palette: "palette4",
},
legend: {
show: data.show_legend === null || !!data.show_legend,
},
dataLabels: {
enabled: !!data.labels,
dropShadow: {
Expand Down
1 change: 1 addition & 0 deletions sqlpage/templates/chart.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"xmax": {{stringify xmax}},
"ymax": {{stringify ymax}},
"toolbar": {{stringify toolbar}},
"show_legend": {{stringify show_legend}},
"logarithmic": {{stringify logarithmic}},
"horizontal": {{stringify horizontal}},
"stacked": {{stringify stacked}},
Expand Down
11 changes: 11 additions & 0 deletions tests/end-to-end/official-site.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ test("chart", async ({ page }) => {
await expect(page.locator(".apexcharts-canvas").first()).toBeVisible();
});

test("chart supports hiding legend", async ({ page }) => {
await page.goto(`${BASE}/documentation.sql?component=chart#component`);

const expensesChart = page.locator(".card", {
has: page.getByRole("heading", { name: "Expenses" }),
});

await expect(expensesChart.locator(".apexcharts-canvas")).toBeVisible();
await expect(expensesChart.locator(".apexcharts-legend")).toBeHidden();
});

test("map", async ({ page }) => {
await page.goto(`${BASE}/documentation.sql?component=map#component`);
await expect(page.getByText("Loading...")).not.toBeVisible();
Expand Down
Loading