Skip to content

Commit

Permalink
Merge pull request #107 from SigNoz/issues-106
Browse files Browse the repository at this point in the history
Display upto 20 characters in name of service in ServiceMap
  • Loading branch information
ankitnayan authored May 17, 2021
2 parents bb155d2 + d6884ca commit e6b3a6c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontend/src/modules/Servicemap/ServiceMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
import { Spin } from "antd";
import styled from "styled-components";
import { StoreState } from "../../store/reducers";
import { getZoomPx, getGraphData, getTooltip } from "./utils";

import { getZoomPx, getGraphData, getTooltip, transformLabel } from "./utils";
import SelectService from "./SelectService";
import { ForceGraph2D } from "react-force-graph";

Expand Down Expand Up @@ -97,7 +98,7 @@ const ServiceMap = (props: ServiceMapProps) => {
linkDirectionalParticles="value"
linkDirectionalParticleSpeed={(d) => d.value}
nodeCanvasObject={(node, ctx, globalScale) => {
const label = node.id;
const label = transformLabel(node.id);
const fontSize = node.fontSize;
ctx.font = `${fontSize}px Roboto`;
const width = node.width;
Expand Down
9 changes: 9 additions & 0 deletions frontend/src/modules/Servicemap/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,12 @@ export const getTooltip = (node: {
</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;
};

0 comments on commit e6b3a6c

Please sign in to comment.