Repository navigation
Conversation
A horizontal bar chart cannot put an anchor on a canvas axis label.
When a panel link contains ${__field.labels.<name>}, hide those labels
and overlay one link per category. Dashboard variables and the current
time range are filled in. All stays $__all.
Signed-off-by: colivi <charles.olivi@gmail.com>
|
Hello, I think for links inside panel, it can't be based on |
Hi Guillaume, agreed that sniffing ${__field.labels.*} inside spec.links is the wrong signal: those entries are the panel header menu. The bar chart only needs one link per category, filled with the category label. A placement flag on the link spec would keep header links unchanged and let a panel opt in. I would rather not special-case BarChart if you want the same behavior on other charts. Happy to follow whichever shape you prefer for that flag. |
oxlint rejects a module imported more than once. The value import and the two type imports are now one statement. Signed-off-by: colivi <charles.olivi@gmail.com>
Inline type specifiers fail oxlint. Both types stay on one import type, next to the value import. Signed-off-by: colivi <charles.olivi@gmail.com>
v0.55.0-beta.4 vendors CUE dependencies one module at a time. A parallel plugin build then runs cue mod tidy while cue.mod/pkg already contains github.com/perses/shared/cue/common, and tidy fails with an ambiguous import. v0.55.0 downloads every missing dependency before copying any of them. Signed-off-by: colivi <charles.olivi@gmail.com>
The caret range also matches 0.56.0-beta.1. That release peers @tanstack/react-query 5, so the React 19 job fails while resolving npm install against the locked react-query 4. Signed-off-by: colivi <charles.olivi@gmail.com>
Main bumps the shared libraries and adapts the plugins to TanStack Query 5, so the exact 0.56.0-beta.0 pin is no longer needed. Signed-off-by: colivi <charles.olivi@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
The URL helpers discard destination origins and fragments and overwrite configured or field-specific filters with dashboard values, even when interpolation is disabled.
3 open issues
What changed in this PR
Adds category links to horizontal bar charts by overlaying HTML anchors where canvas axis labels cannot be clickable.
Changes:
- Builds per-series links from field labels and dashboard variables, preserving the All selection and carrying time-range parameters.
- Positions category anchors alongside bars and supports opening links in a new tab.
- Adds unit tests for link interpolation and URL helpers.
| File | Description |
|---|---|
barchart/src/utils.ts |
Adds link interpolation and URL parameter helpers. |
barchart/src/utils.test.ts |
Tests field labels, dashboard variables, All selections, and time parameters. |
barchart/src/BarChartPanel.tsx |
Generates per-series URLs from panel link configuration. |
barchart/src/BarChartBase.tsx |
Replaces horizontal axis labels with positioned category anchors. |
Review effort: Balanced
| } | ||
| const live = current.get(key); | ||
| if (live !== null) { | ||
| base.searchParams.set(key, live); |
| return `${base.pathname}${base.search}`.replace(/%24/g, '$'); | ||
| } | ||
|
|
||
| // withLocationTime keeps the current dashboard range on an in-app link. | ||
| export function withLocationTime(url: string, search: string): string { | ||
| const current = new URLSearchParams(search); | ||
| const base = new URL(url, 'http://perses.local'); | ||
| for (const key of ['start', 'end', 'tz']) { | ||
| const value = current.get(key); | ||
| if (value && !base.searchParams.has(key)) { | ||
| base.searchParams.set(key, value); | ||
| } | ||
| } | ||
| return `${base.pathname}${base.search}`.replace(/%24/g, '$'); |
|
|
||
| export function calculatePercentages(data: BarChartData[]): Array<{ label: string; value: number }> { | ||
| const fieldLabelPattern = /\$\{__field\.labels\.([A-Za-z_][A-Za-z0-9_]*)\}/g; | ||
| const fieldParamPattern = /[?&]([^=&]+)=\$\{__field\.labels\.[^}]+\}/g; |
There was a problem hiding this comment.
The address-bar overwrite is intentional for a dashboard variable: interpolation turns All into .* and a one-element list into (Value), so the live query string is what the next dashboard must receive. I will limit that restore to parameters whose template value is that same variable, and skip it when renderVariables is false, so a literal or a mapping to another variable stays as written.
Relative dashboard links must stay on the current host, which is why the parse base is dropped whereas absolute links will keep their origin, and both helpers will keep the fragment.
A field placeholder will protect the parameter wherever it sits in the value, not only when it is the whole value.
Live query values replace only the dashboard variable of the same name, and only when variable interpolation is on. Absolute links keep their origin, and both helpers keep the fragment. A field placeholder protects its parameter anywhere in the value. Signed-off-by: colivi <charles.olivi@gmail.com>
| } = props; | ||
|
|
||
| const variables = useAllVariableValues(); | ||
| const seriesLink = definition?.spec.links?.find((link) => link.url.includes('__field.labels')); |
There was a problem hiding this comment.
I am concerned about determining the link's behavior based on its URL content. This creates an implicit coupling between the URL and the link type. Wouldn't it be cleaner to explicitly distinguish between panel and the data links at the spec level? This would also allow us to reuse the same mechanism across other panel plugins in the future.


Description
A horizontal bar chart cannot put an anchor on a canvas axis label. When a panel link contains ${__field.labels.}, hide those labels and overlay one link per category. Dashboard variables and the current time range are filled in, all stays $__all.
Screenshots
Checklist
[<catalog_entry>] <commit message>naming convention using one of thefollowing
catalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.UI Changes