Skip to content

feat(chart): add links to data point tooltips - #1438

Open
lovasoa wants to merge 1 commit into
mainfrom
feature/chart-point-links
Open

feat(chart): add links to data point tooltips#1438
lovasoa wants to merge 1 commit into
mainfrom
feature/chart-point-links

Conversation

@lovasoa

@lovasoa lovasoa commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #945.

Adds an optional row-level link parameter to the chart component. When a chart data row has a link, the chart tooltip includes an accessible Open link anchor pointing to that URL.

Implementation

  • Carries link through the chart template's point data without changing the existing color/z positions.
  • Preserves links on aligned series points.
  • Uses a small DOM-based tooltip renderer only for charts that contain links; charts without links keep ApexCharts' existing tooltip behavior.
  • Handles range bars and other point-based charts, including pie-series data stored by ApexCharts as scalar values.
  • Documents the parameter and adds a timeline example.

Tests

  • npm test
  • cargo test
  • cd tests/end-to-end && npm run test -- --grep "data point link"

json('[
{"component":"chart", "title": "Project Timeline", "type": "rangeBar", "time": true, "color": ["teal", "cyan"], "labels": true, "xmin": "2021-12-28", "xmax": "2022-01-04" },
{"series": "Phase 1", "label": "Operations", "value": ["2021-12-29", "2022-01-02"]},
{"series": "Phase 1", "label": "Operations", "value": ["2021-12-29", "2022-01-02"], "link": "/examples/chart.sql?phase=1"},

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when I go to http://127.0.0.1:7071/component.sql?component=chart I see that there is an open link button, but the tooltip dissappears when I try to click it. also the link seems visually disabled

Screenshot_2026-09-07_13-05-43

Comment thread sqlpage/apexcharts.js
const series = w.config.series[seriesIndex];
const name = series?.name || w.config.labels?.[dataPointIndex] || "";
const point = series?.data?.[dataPointIndex] || {};
const link = point.link || raw_points[dataPointIndex]?.[5];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the screenshot also shows that rows without links still show the Open Link hyperlink. I think it's leaking into other rows from here

Comment thread sqlpage/apexcharts.js
Comment on lines +341 to +343
custom: points.some((point) => point[5])
? (args) => chartTooltip(args, points)
: chart_type === "bubble" || chart_type === "scatter"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may be skipping the formatter. when you check on the live website, the dates are formatted

Image

expect(chart.shapes).toHaveLength(2);
});

test("shows a data point link in its tooltip", async ({ page }) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be worth to test multiple different kinds of charts since not all of them use the rows in the same way. claude is pointing out that there may be a code smell with pie charts

Comment thread sqlpage/apexcharts.js
axisValue.appendChild(valueSpan);
tooltip.appendChild(axisValue);
}
add_link_to_tooltip(tooltip, link);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nit] snake case?

Comment on lines 1 to 7
SELECT 'chart' AS component, 'It works !' AS title;
SELECT 'plain' AS x, '1' AS y;
SELECT 'colored' AS x, '2' AS y, 'red' AS color;
SELECT 'sized' AS x, '3' AS y, '30' AS z;
SELECT 'both' AS x, '4' AS y, 'green' AS color, '40' AS z;
SELECT 'linked' AS x, '5' AS y, '/edit.sql?id=5' AS link;
SELECT '70' AS yline, 'limit' AS label, 'orange' AS color;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chart component : link parameter

2 participants