feat(chart): add links to data point tooltips - #1438
Open
lovasoa wants to merge 1 commit into
Open
Conversation
81reap
reviewed
Sep 7, 2026
| 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"}, |
Collaborator
| 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]; |
Collaborator
There was a problem hiding this comment.
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 on lines
+341
to
+343
| custom: points.some((point) => point[5]) | ||
| ? (args) => chartTooltip(args, points) | ||
| : chart_type === "bubble" || chart_type === "scatter" |
Collaborator
| expect(chart.shapes).toHaveLength(2); | ||
| }); | ||
|
|
||
| test("shows a data point link in its tooltip", async ({ page }) => { |
Collaborator
There was a problem hiding this comment.
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
| axisValue.appendChild(valueSpan); | ||
| tooltip.appendChild(axisValue); | ||
| } | ||
| add_link_to_tooltip(tooltip, link); |
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; |
Collaborator
There was a problem hiding this comment.
I think this test is orphaned and doesn't run
https://github.com/search?q=repo%3Asqlpage%2FSQLPage+chart_point_serialization.sql&type=code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
Closes #945.
Adds an optional row-level
linkparameter to thechartcomponent. When a chart data row has a link, the chart tooltip includes an accessibleOpen linkanchor pointing to that URL.Implementation
linkthrough the chart template's point data without changing the existing color/z positions.Tests
npm testcargo testcd tests/end-to-end && npm run test -- --grep "data point link"