signoz/frontend/src/lib/getRandomColor.ts
palash-signoz 9f7c60d2c1
Fe: Feat/trace detail (#764)
* feat: new trace detail page flame graph

* feat: new trace detail page layout

* test: trace detail is wip

* chore: trace details in wip

* feat: trace detail page timeline component

* chore: spantoTree is updated

* chore: gantchart is updated

* chore: onClick is added

* chore: isSpanPresentInSearchString util is added

* chore: trace graph is updated

* chore: added the hack to work

* feat: is span present util is added

* chore: in span ms is added

* chore: tooltip is updated

* WIP: chore: trace details changes are updated

* feat: getTraceItem is added

* feat: trace detail page is updated

* feat: trace detail styling changes

* feat: trace detail page is updated

* feat: implement span hover, select, focus and reset

* feat: reset focus

* feat: spanId as query table and unfurling

* feat: trace details is updated

* chore: remove lodash

* chore: remove lodash

* feat: trace details is updated

* feat: new trace detail page styling changes

* feat: new trace detail page styling changes

* feat: improved styling

* feat: remove horizontal scrolling

* feat: new trace detail page modify caret icon

* chore styles are updated

* Revert "chore: Trace styles"

* chore styles are updated

* feat: timeline normalisation

* chore: remove mock data

* chore: sort tree data util is added and selected span component is updated

* chore: trace changes are updated

* chore: trace changes are updated

* chore: trace changes are updated

* feat: refactored time units for new trace detail page

* chore: remove mockdata

* feat: new trace detail page themeing and interval loop fix

* chore: error tag is updated

* chore: error tag is updated

* chore: error tag is updated

* chore: error tag is updated

* chore: console is removed

* fix: error tag expand button

* chore: expanded panel is updated

* feat: scroll span from gantt chart intoview

* chore: trace detail is removed

Co-authored-by: Pranshu Chittora <pranshu@signoz.io>
2022-03-03 19:04:23 +05:30

37 lines
874 B
TypeScript

import { span } from 'store/actions';
export const colors = [
'#2F80ED',
'#BB6BD9',
'#F2994A',
'#219653',
'#56CCF2',
'#F2C94C',
'#BDBDBD',
];
export const errorColor = '#d32f2f';
export function getRandomNumber(min: number, max: number): number {
return Math.random() * (max - min) + min;
}
const getRandomColor = (): string => {
const index = parseInt(getRandomNumber(0, colors.length - 1).toString(), 10);
return colors[index];
};
export const spanServiceNameToColorMapping = (spans: span[]) => {
const serviceNameSet = new Set();
spans.forEach((spanItem) => {
serviceNameSet.add(spanItem[3]);
});
const serviceToColorMap: { [key: string]: string } = {};
Array.from(serviceNameSet).forEach((serviceName, idx) => {
serviceToColorMap[`${serviceName}`] = colors[idx % colors.length];
});
return serviceToColorMap;
};
export default getRandomColor;