Skip to content

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.

fix(dashboard): heatmap legend search and two-row cap (#13082)

Abhi kumar54aaad2cc3bc
diff --git a/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx b/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx
index c5441a9710..0efccf04e6 100644
--- a/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx
+++ b/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx
@@ -24,6 +24,7 @@ export default function Legend({
focusedSeriesIndex,
onAction,
showCopy = true,
+ itemLabel = 'series',
}: LegendProps): JSX.Element {
const legendContainerRef = useRef<HTMLDivElement | null>(null);
const [filterQuery, setFilterQuery] = useState('');
@@ -92,11 +93,12 @@ export default function Legend({
position={position}
filterQuery={filterQuery}
onFilterQueryChange={setFilterQuery}
+ itemLabel={itemLabel}
/>
)}
{isEmptyState ? (
<div className={styles.emptyState}>
- No series found matching &quot;{effectiveQuery}&quot;
+ No {itemLabel} found matching &quot;{effectiveQuery}&quot;
</div>
) : (
<VirtuosoGrid
diff --git a/frontend/src/lib/uPlotV2/components/Legend/LegendToolbar.tsx b/frontend/src/lib/uPlotV2/components/Legend/LegendToolbar.tsx
index d0f45cf1c5..ef98f5d8e0 100644
--- a/frontend/src/lib/uPlotV2/components/Legend/LegendToolbar.tsx
+++ b/frontend/src/lib/uPlotV2/components/Legend/LegendToolbar.tsx
@@ -14,6 +14,7 @@ export interface LegendToolbarProps {
position: LegendPosition;
filterQuery: string;
onFilterQueryChange: (query: string) => void;
+ itemLabel: string;
}
/** Legend chrome: the series search box and the "Showing N of M" readout. */
@@ -23,6 +24,7 @@ export default function LegendToolbar({
position,
filterQuery,
onFilterQueryChange,
+ itemLabel,
}: LegendToolbarProps): JSX.Element {
const handleFilterChange = useCallback(
(event: ChangeEvent<HTMLInputElement>): void =>
@@ -48,7 +50,7 @@ export default function LegendToolbar({
aria-live="polite"
data-testid="legend-status"
>
- {`Showing ${visibleCount} of ${totalCount} series`}
+ {`Showing ${visibleCount} of ${totalCount} ${itemLabel}`}
</span>
);
diff --git a/frontend/src/lib/uPlotV2/components/types.ts b/frontend/src/lib/uPlotV2/components/types.ts
index ec9a45f3b3..2829c977ad 100644
--- a/frontend/src/lib/uPlotV2/components/types.ts
+++ b/frontend/src/lib/uPlotV2/components/types.ts
@@ -168,6 +168,8 @@ export interface LegendProps {
onAction: OnLegendAction;
/** Show the per-item copy button. Default true. */
showCopy?: boolean;
+ /** Plural noun for the items in the search readouts. Default 'series'. */
+ itemLabel?: string;
}
/** Props for the uPlot legend controller, which derives items + interaction
diff --git a/frontend/src/lib/visualization/charts/ChartWrapper/ChartWrapper.tsx b/frontend/src/lib/visualization/charts/ChartWrapper/ChartWrapper.tsx
index edf897cdbd..3481dc846c 100644
--- a/frontend/src/lib/visualization/charts/ChartWrapper/ChartWrapper.tsx
+++ b/frontend/src/lib/visualization/charts/ChartWrapper/ChartWrapper.tsx
@@ -63,20 +63,20 @@ export default function ChartWrapper({
);
const legendComponent = useCallback(
- ({ averageLegendWidth, showSearch }: LegendLayout): React.ReactNode => {
+ (layout: LegendLayout): React.ReactNode => {
if (!showLegend) {
return null;
}
// A pie's slices and a heatmap's groups are not uPlot series.
if (customLegend) {
- return customLegend(averageLegendWidth);
+ return customLegend(layout);
}
return (
<UPlotLegend
config={config}
position={legendConfig.position}
- averageLegendWidth={averageLegendWidth}
- showSearch={showSearch}
+ averageLegendWidth={layout.averageLegendWidth}
+ showSearch={layout.showSearch}
/>
);
},
diff --git a/frontend/src/lib/visualization/charts/Heatmap/Heatmap.tsx b/frontend/src/lib/visualization/charts/Heatmap/Heatmap.tsx
index 036fdf890a..1d5953cfdd 100644
--- a/frontend/src/lib/visualization/charts/Heatmap/Heatmap.tsx
+++ b/frontend/src/lib/visualization/charts/Heatmap/Heatmap.tsx
@@ -26,6 +26,7 @@ import {
import { ChartClickData } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
import { HeatmapChartProps } from 'lib/visualization/charts/types';
+import type { LegendLayout } from 'lib/visualization/layout/ChartLayout/ChartLayout';
import { useLegendVisibility } from 'lib/visualization/hooks/useLegendVisibility';
import {
buildHeatmapConfig,
@@ -277,11 +278,13 @@ export default function Heatmap(props: HeatmapChartProps): JSX.Element {
}, []);
const groupLegend = useCallback(
- (averageLegendWidth: number): React.ReactNode => (
+ ({ averageLegendWidth, showSearch }: LegendLayout): React.ReactNode => (
<Legend
items={legendItems}
position={legendPosition}
averageLegendWidth={averageLegendWidth}
+ showSearch={showSearch}
+ itemLabel="groups"
focusedSeriesIndex={focusedSeriesIndex}
onAction={onLegendAction}
/>
diff --git a/frontend/src/lib/visualization/charts/types.ts b/frontend/src/lib/visualization/charts/types.ts
index afbd5319f9..003573b49b 100644
--- a/frontend/src/lib/visualization/charts/types.ts
+++ b/frontend/src/lib/visualization/charts/types.ts
@@ -9,6 +9,7 @@ import {
TooltipRenderArgs,
} from 'lib/uPlotV2/components/types';
import { UPlotConfigBuilder } from 'lib/uPlotV2/config/UPlotConfigBuilder';
+import type { LegendLayout } from 'lib/visualization/layout/ChartLayout/ChartLayout';
import type {
HeatmapAxisScale,
HeatmapCell,
@@ -41,7 +42,7 @@ interface BaseChartProps {
tooltipPortalRoot?: HTMLElement | null;
/** Replaces the config-driven legend, for charts whose legend lists something
* other than uPlot series — heatmap groups, where the series are bucket rows. */
- customLegend?: (averageLegendWidth: number) => React.ReactNode;
+ customLegend?: (layout: LegendLayout) => React.ReactNode;
/** Measured against for the chart/legend split. Pair with `customLegend`. */
legendLabels?: string[];
/** Rendered under the plot but above the legend, inside the chart column. */