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: small fixes for scale + legend sizing (#10168)

Abhi kumar6c5d36caa91c
diff --git a/frontend/src/container/DashboardContainer/visualization/charts/utils.ts b/frontend/src/container/DashboardContainer/visualization/charts/utils.ts
index 0afe84fe6d..e6a4880b45 100644
--- a/frontend/src/container/DashboardContainer/visualization/charts/utils.ts
+++ b/frontend/src/container/DashboardContainer/visualization/charts/utils.ts
@@ -1,5 +1,5 @@
+import { MAX_LEGEND_WIDTH } from 'lib/uPlotV2/components/Legend/Legend';
import { LegendConfig, LegendPosition } from 'lib/uPlotV2/components/types';
-
export interface ChartDimensions {
width: number;
height: number;
@@ -13,7 +13,6 @@ const DEFAULT_AVG_LABEL_LENGTH = 15;
const LEGEND_GAP = 16;
const LEGEND_PADDING = 12;
const LEGEND_LINE_HEIGHT = 36;
-const MAX_LEGEND_WIDTH = 400;
/**
* Average text width from series labels (for legendsPerSet).
diff --git a/frontend/src/lib/uPlotV2/components/Legend/Legend.styles.scss b/frontend/src/lib/uPlotV2/components/Legend/Legend.styles.scss
index fd42bd5fec..2e8cc5925e 100644
--- a/frontend/src/lib/uPlotV2/components/Legend/Legend.styles.scss
+++ b/frontend/src/lib/uPlotV2/components/Legend/Legend.styles.scss
@@ -59,7 +59,6 @@
gap: 6px;
padding: 4px 8px;
border-radius: 4px;
- max-width: min(400px, 100%);
cursor: pointer;
&.legend-item-off {
diff --git a/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx b/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx
index 713ffa0622..f81fc42ede 100644
--- a/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx
+++ b/frontend/src/lib/uPlotV2/components/Legend/Legend.tsx
@@ -11,6 +11,7 @@ import { useLegendActions } from './useLegendActions';
import './Legend.styles.scss';
+export const MAX_LEGEND_WIDTH = 320;
const LEGENDS_PER_SET_DEFAULT = 5;
export default function Legend({
@@ -66,6 +67,7 @@ export default function Legend({
'legend-item-off': !item.show,
'legend-item-focused': focusedSeriesIndex === item.seriesIndex,
})}
+ style={{ maxWidth: `min(${MAX_LEGEND_WIDTH}px, 100%)` }}
>
<div
className="legend-marker"
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/Tooltip.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/Tooltip.tsx
index 12ffd10b5f..787625cd1c 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/Tooltip.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/Tooltip.tsx
@@ -39,7 +39,7 @@ export default function Tooltip({
data: uPlotInstance.data,
series: uPlotInstance.series,
dataIndexes,
- activeSeriesIdx: seriesIndex,
+ activeSeriesIndex: seriesIndex,
uPlotInstance,
yAxisUnit,
decimalPrecision,
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts b/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts
index ad073f46eb..305b6c0102 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts
@@ -9,10 +9,10 @@ const FALLBACK_SERIES_COLOR = '#000000';
export function resolveSeriesColor(
stroke: Series.Stroke | undefined,
u: uPlot,
- seriesIdx: number,
+ seriesIndex: number,
): string {
if (typeof stroke === 'function') {
- return String(stroke(u, seriesIdx));
+ return String(stroke(u, seriesIndex));
}
if (typeof stroke === 'string') {
return stroke;
@@ -24,7 +24,7 @@ export function buildTooltipContent({
data,
series,
dataIndexes,
- activeSeriesIdx,
+ activeSeriesIndex,
uPlotInstance,
yAxisUnit,
decimalPrecision,
@@ -32,7 +32,7 @@ export function buildTooltipContent({
data: AlignedData;
series: Series[];
dataIndexes: Array<number | null>;
- activeSeriesIdx: number | null;
+ activeSeriesIndex: number | null;
uPlotInstance: uPlot;
yAxisUnit: string;
decimalPrecision?: PrecisionOption;
@@ -40,28 +40,28 @@ export function buildTooltipContent({
const active: TooltipContentItem[] = [];
const rest: TooltipContentItem[] = [];
- for (let idx = 1; idx < series.length; idx += 1) {
- const s = series[idx];
+ for (let index = 1; index < series.length; index += 1) {
+ const s = series[index];
if (!s?.show) {
continue;
}
- const dataIdx = dataIndexes[idx];
+ const dataIndex = dataIndexes[index];
// Skip series with no data at the current cursor position
- if (dataIdx === null) {
+ if (dataIndex === null) {
continue;
}
- const raw = data[idx]?.[dataIdx];
+ const raw = data[index]?.[dataIndex];
const value = Number(raw);
const displayValue = Number.isNaN(value) ? 0 : value;
- const isActive = idx === activeSeriesIdx;
+ const isActive = index === activeSeriesIndex;
const item: TooltipContentItem = {
label: String(s.label ?? ''),
value: displayValue,
tooltipValue: getToolTipValue(displayValue, yAxisUnit, decimalPrecision),
- color: resolveSeriesColor(s.stroke, uPlotInstance, idx),
+ color: resolveSeriesColor(s.stroke, uPlotInstance, index),
isActive,
};
diff --git a/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts b/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts
index dd8db053ac..edf47bddf8 100644
--- a/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts
+++ b/frontend/src/lib/uPlotV2/config/UPlotScaleBuilder.ts
@@ -40,8 +40,8 @@ export class UPlotScaleBuilder extends ConfigBuilder<
range,
thresholds,
logBase = 10,
- padMinBy = 0.1,
- padMaxBy = 0.1,
+ padMinBy = 0,
+ padMaxBy = 0.05,
} = this.props;
// Special handling for time scales (X axis)