Unverified Commit e6b3a6c9 authored by Ankit Nayan's avatar Ankit Nayan Committed by GitHub
Browse files

Merge pull request #107 from SigNoz/issues-106

Display upto 20 characters in name of service in ServiceMap 
parents bb155d23 d6884cac
Showing with 12 additions and 2 deletions
+12 -2
...@@ -10,7 +10,8 @@ import { ...@@ -10,7 +10,8 @@ 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 { getZoomPx, getGraphData, getTooltip } from "./utils";
import { getZoomPx, 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";
...@@ -97,7 +98,7 @@ const ServiceMap = (props: ServiceMapProps) => { ...@@ -97,7 +98,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;
......
...@@ -107,3 +107,12 @@ export const getTooltip = (node: { ...@@ -107,3 +107,12 @@ export const getTooltip = (node: {
</div> </div>
</div>`; </div>`;
}; };
export const transformLabel = (label: string) => {
const MAX_LENGTH = 13;
const MAX_SHOW = 10;
if (label.length > MAX_LENGTH) {
return `${label.slice(0, MAX_SHOW)}...`;
}
return label;
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment