Geomap: Fix fixed edge text for network layer (#72863)

Geomap: Fix fixed edge text
This commit is contained in:
Drew Slobodnjak 2023-08-04 08:21:13 -07:00 committed by GitHub
parent c344b0e427
commit 92e7829e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,7 @@ import {
Field, Field,
PluginState, PluginState,
} from '@grafana/data'; } from '@grafana/data';
import { TextDimensionMode } from '@grafana/schema';
import { FrameVectorSource } from 'app/features/geo/utils/frameVectorSource'; import { FrameVectorSource } from 'app/features/geo/utils/frameVectorSource';
import { getGeometryField, getLocationMatchers } from 'app/features/geo/utils/location'; import { getGeometryField, getLocationMatchers } from 'app/features/geo/utils/location';
import { GraphFrame } from 'app/plugins/panel/nodeGraph/types'; import { GraphFrame } from 'app/plugins/panel/nodeGraph/types';
@ -159,11 +160,11 @@ export const networkLayer: MapLayerRegistryItem<NetworkConfig> = {
flowStyle.setGeometry(LS); flowStyle.setGeometry(LS);
const fontFamily = theme.typography.fontFamily; const fontFamily = theme.typography.fontFamily;
if (edgeDims.text) { if (edgeDims.text || edgeStyle.config.text?.mode === TextDimensionMode.Fixed) {
const labelStyle = new Style({ const labelStyle = new Style({
zIndex: 10, zIndex: 10,
text: new Text({ text: new Text({
text: edgeDims.text.get(edgeId), text: edgeDims.text?.get(edgeId) ?? edgeStyle.config.text?.fixed,
font: `normal ${edgeTextConfig?.fontSize}px ${fontFamily}`, font: `normal ${edgeTextConfig?.fontSize}px ${fontFamily}`,
fill: new Fill({ color: color1 ?? defaultStyleConfig.color.fixed }), fill: new Fill({ color: color1 ?? defaultStyleConfig.color.fixed }),
stroke: new Stroke({ stroke: new Stroke({
@ -210,15 +211,15 @@ export const networkLayer: MapLayerRegistryItem<NetworkConfig> = {
return; // ignore empty return; // ignore empty
} }
// Post updates to the legend component // Post updates to the legend component
if (legend) { if (legend) {
legendProps.next({ legendProps.next({
styleConfig: style, styleConfig: style,
size: style.dims?.size, size: style.dims?.size,
layerName: options.name, layerName: options.name,
layer: vectorLayer, layer: vectorLayer,
}); });
} }
const graphFrames = getGraphFrame(data.series); const graphFrames = getGraphFrame(data.series);
for (const frame of data.series) { for (const frame of data.series) {