SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.
TypeScript apmapplication-monitoringdistributed-tracinggogood-first-issuejaegerloglogsmetricsmonitoringnextjsobservabilityopen-sourceopentelemetryprometheusreactreactjsself-hostedtracingtypescript
chore: added changes for sorting tooltip content (#11320)
Abhi kumar7d2f8b291e3f
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/utils.test.ts b/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/utils.test.tsindex 866ae5b909..031691de92 100644--- a/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/utils.test.ts+++ b/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/utils.test.ts@@ -189,7 +189,7 @@ describe('Tooltip utils', () => {];}- it('builds tooltip content in series-index order with isActive flag set correctly', () => {+ it('builds tooltip content sorted by value descending with isActive flag set correctly', () => {const data: AlignedData = [[0], [10], [20], [30]];const series = createSeriesConfig();const dataIndexes = [null, 0, 0, 0];@@ -206,21 +206,21 @@ describe('Tooltip utils', () => {});expect(result).toHaveLength(2);- // Series are returned in series-index order (A=index 1 before B=index 2)+ // Sorted by value descending: B (20) before A (10)expect(result[0]).toMatchObject<Partial<TooltipContentItem>>({- label: 'A',- value: 10,- tooltipValue: 'formatted-10',- color: '#ff0000',- isActive: false,- });- expect(result[1]).toMatchObject<Partial<TooltipContentItem>>({label: 'B',value: 20,tooltipValue: 'formatted-20',color: 'color-2',isActive: true,});+ expect(result[1]).toMatchObject<Partial<TooltipContentItem>>({+ label: 'A',+ value: 10,+ tooltipValue: 'formatted-10',+ color: '#ff0000',+ isActive: false,+ });});it('skips series with null data index or non-finite values', () => {@@ -274,7 +274,7 @@ describe('Tooltip utils', () => {expect(result[1].value).toBe(30);});- it('returns items in series-index order', () => {+ it('returns items sorted by value descending', () => {// Series values in non-sorted order: 3, 1, 4, 2const data: AlignedData = [[0], [3], [1], [4], [2]];const series: Series[] = [@@ -297,7 +297,7 @@ describe('Tooltip utils', () => {decimalPrecision,});- expect(result.map((item) => item.value)).toStrictEqual([3, 1, 4, 2]);+ expect(result.map((item) => item.value)).toStrictEqual([4, 3, 2, 1]);});});});diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts b/frontend/src/lib/uPlotV2/components/Tooltip/utils.tsindex b270ec7f98..4846bf5f29 100644--- a/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts+++ b/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts@@ -142,5 +142,7 @@ export function buildTooltipContent({}}+ items.sort((a, b) => b.value - a.value);+return items;}