mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-12 21:39:05 +08:00
adds a utility function to transform label
This commit is contained in:
parent
55a7b5b1b3
commit
8fe2fe5aec
@ -10,7 +10,7 @@ import {
|
|||||||
import { Spin } from "antd";
|
import { Spin } from "antd";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { StoreState } from "../../store/reducers";
|
import { StoreState } from "../../store/reducers";
|
||||||
import { getGraphData, getTooltip } from "./utils";
|
import { getGraphData, getTooltip, transformLabel } from "./utils";
|
||||||
import SelectService from "./SelectService";
|
import SelectService from "./SelectService";
|
||||||
import { ForceGraph2D } from "react-force-graph";
|
import { ForceGraph2D } from "react-force-graph";
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ const ServiceMap = (props: ServiceMapProps) => {
|
|||||||
linkDirectionalParticles="value"
|
linkDirectionalParticles="value"
|
||||||
linkDirectionalParticleSpeed={(d) => d.value}
|
linkDirectionalParticleSpeed={(d) => d.value}
|
||||||
nodeCanvasObject={(node, ctx, globalScale) => {
|
nodeCanvasObject={(node, ctx, globalScale) => {
|
||||||
const label = node.id;
|
const label = transformLabel(node.id);
|
||||||
const fontSize = node.fontSize;
|
const fontSize = node.fontSize;
|
||||||
ctx.font = `${fontSize}px Roboto`;
|
ctx.font = `${fontSize}px Roboto`;
|
||||||
const width = node.width;
|
const width = node.width;
|
||||||
|
@ -96,3 +96,11 @@ export const getTooltip = (node: {
|
|||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const transformLabel = (label: string) => {
|
||||||
|
const MAX_LENGTH = 18;
|
||||||
|
if (label.length > MAX_LENGTH) {
|
||||||
|
return `${label.slice(0, MAX_LENGTH)}..`;
|
||||||
|
}
|
||||||
|
return label;
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user