Canvas: Add datalink support to rectangle and ellipse elements (#83870)

This commit is contained in:
Nathan Marrs 2024-03-05 16:25:12 -07:00 committed by GitHub
parent 38a0eab137
commit 5c27d28ba4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 1 deletions

View File

@ -127,7 +127,7 @@ The inline editing toggle lets you lock or unlock the canvas. When turned off th
### Data links
Canvases support [data links](https://grafana.com/docs/grafana/latest/panels-visualizations/configure-data-links/). You can create a data link for a metric-value element and display it for all elements that use the field name by following these steps:
Canvases support [data links](https://grafana.com/docs/grafana/latest/panels-visualizations/configure-data-links/), but only for metric-value, text, rectangle, and ellipse elements. You can add a data link by following these steps:
1. Set an element to be tied to a field value.
1. Turn off the inline editing toggle.

View File

@ -6,6 +6,7 @@ import { config } from 'app/core/config';
import { DimensionContext } from 'app/features/dimensions/context';
import { ColorDimensionEditor } from 'app/features/dimensions/editors/ColorDimensionEditor';
import { TextDimensionEditor } from 'app/features/dimensions/editors/TextDimensionEditor';
import { getDataLinks } from 'app/plugins/panel/canvas/utils';
import { CanvasElementItem, CanvasElementProps, defaultBgColor, defaultTextColor } from '../element';
import { Align, VAlign, EllipseConfig, EllipseData } from '../types';
@ -98,6 +99,8 @@ export const ellipseItem: CanvasElementItem<EllipseConfig, EllipseData> = {
data.color = ctx.getColor(cfg.color).value();
}
data.links = getDataLinks(ctx, cfg, data.text);
return data;
},

View File

@ -7,6 +7,7 @@ import { config } from 'app/core/config';
import { DimensionContext } from 'app/features/dimensions/context';
import { ColorDimensionEditor } from 'app/features/dimensions/editors/ColorDimensionEditor';
import { TextDimensionEditor } from 'app/features/dimensions/editors/TextDimensionEditor';
import { getDataLinks } from 'app/plugins/panel/canvas/utils';
import { CanvasElementItem, CanvasElementProps, defaultBgColor, defaultTextColor } from '../element';
import { Align, TextConfig, TextData, VAlign } from '../types';
@ -81,6 +82,8 @@ export const rectangleItem: CanvasElementItem<TextConfig, TextData> = {
data.color = ctx.getColor(cfg.color).value();
}
data.links = getDataLinks(ctx, cfg, data.text);
return data;
},