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.

feat(charts): mark partial time buckets with a dotted ring (#13165)

Abhi kumaraef60bad5de3
diff --git a/frontend/src/api/v5/queryRange/convertV5Response.test.ts b/frontend/src/api/v5/queryRange/convertV5Response.test.ts
index 3c7758d5bb..39a56fdb68 100644
--- a/frontend/src/api/v5/queryRange/convertV5Response.test.ts
+++ b/frontend/src/api/v5/queryRange/convertV5Response.test.ts
@@ -61,7 +61,11 @@ describe('convertV5ResponseToLegacy', () => {
],
values: [
{ timestamp: 1000, value: 10 } as unknown as TimeSeriesValue,
- { timestamp: 2000, value: 12 } as unknown as TimeSeriesValue,
+ {
+ timestamp: 2000,
+ value: 12,
+ partial: true,
+ } as unknown as TimeSeriesValue,
],
} as unknown as TimeSeries,
],
@@ -104,7 +108,7 @@ describe('convertV5ResponseToLegacy', () => {
labels: { 'service.name': 'adservice' },
values: [
{ timestamp: 1000, value: '10' },
- { timestamp: 2000, value: '12' },
+ { timestamp: 2000, value: '12', partial: true },
],
metaData: expect.objectContaining({
alias: '__result_0',
diff --git a/frontend/src/api/v5/queryRange/convertV5Response.ts b/frontend/src/api/v5/queryRange/convertV5Response.ts
index 1452c2025f..33a3dd7f8f 100644
--- a/frontend/src/api/v5/queryRange/convertV5Response.ts
+++ b/frontend/src/api/v5/queryRange/convertV5Response.ts
@@ -125,6 +125,7 @@ function convertTimeSeriesData(
values: series.values.map((value: any) => ({
timestamp: value.timestamp,
value: String(value.value),
+ ...(value.partial ? { partial: true } : {}),
})),
metaData: {
alias,
diff --git a/frontend/src/container/WidgetCard/Panels/BarPanel/__tests__/utils.test.ts b/frontend/src/container/WidgetCard/Panels/BarPanel/__tests__/utils.test.ts
index a0bc96f427..b36591f8b6 100644
--- a/frontend/src/container/WidgetCard/Panels/BarPanel/__tests__/utils.test.ts
+++ b/frontend/src/container/WidgetCard/Panels/BarPanel/__tests__/utils.test.ts
@@ -1,3 +1,4 @@
+import type { ExtendedSeries } from 'lib/uPlotV2/config/types';
import { Widgets } from 'types/api/widgets/widget';
import {
MetricRangePayloadProps,
@@ -164,6 +165,27 @@ describe('BarPanel utils', () => {
expect(config.series).toHaveLength(3);
});
+ it('passes partial timestamps to the series', () => {
+ const apiResponse = createApiResponse([
+ {
+ metric: {},
+ queryName: 'Q1',
+ values: [
+ [1000, '1'],
+ [1060, '0.2'],
+ ],
+ partialTimestamps: [1060],
+ } as MetricRangePayloadProps['data']['result'][0],
+ ]);
+
+ const series = prepareBarPanelConfig({
+ ...baseParams,
+ apiResponse,
+ }).getConfig().series?.[1] as ExtendedSeries;
+
+ expect(series.partialTimestamps).toStrictEqual(new Set([1060]));
+ });
+
it('uses getLegend for label when currentQuery is provided', () => {
const apiResponse = createApiResponse([
{
diff --git a/frontend/src/container/WidgetCard/Panels/BarPanel/utils.ts b/frontend/src/container/WidgetCard/Panels/BarPanel/utils.ts
index 71bac454c0..e930b55c12 100644
--- a/frontend/src/container/WidgetCard/Panels/BarPanel/utils.ts
+++ b/frontend/src/container/WidgetCard/Panels/BarPanel/utils.ts
@@ -89,6 +89,9 @@ export function prepareBarPanelConfig({
isDarkMode,
stepInterval: currentStepInterval,
metric: series.metric,
+ partialTimestamps: series.partialTimestamps
+ ? new Set(series.partialTimestamps)
+ : undefined,
});
});
diff --git a/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/__tests__/utils.test.ts b/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/__tests__/utils.test.ts
index 3be7bcfe15..f75bcfd98e 100644
--- a/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/__tests__/utils.test.ts
+++ b/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/__tests__/utils.test.ts
@@ -5,6 +5,7 @@ import {
} from 'types/api/metrics/getQueryRange';
import { Query } from 'types/api/queryBuilder/queryBuilderData';
+import type { ExtendedSeries } from 'lib/uPlotV2/config/types';
import { PanelMode } from 'lib/visualization/panels/types';
import { prepareUPlotConfig } from 'container/WidgetCard/Panels/TimeSeriesPanel/utils';
import { prepareChartData } from 'lib/uPlotV2/utils/dataUtils';
@@ -185,6 +186,28 @@ describe('TimeSeriesPanel utils', () => {
});
});
+ it('passes partial timestamps to the series', () => {
+ const apiResponse = createApiResponse([
+ {
+ metric: {},
+ queryName: 'Q1',
+ values: [
+ [1000, '1'],
+ [1060, '0.2'],
+ ],
+ partialTimestamps: [1060],
+ } as MetricRangePayloadProps['data']['result'][0],
+ ]);
+
+ const series = prepareUPlotConfig({
+ ...baseParams,
+ apiResponse,
+ currentQuery: null as unknown as Query,
+ }).getConfig().series?.[1] as ExtendedSeries;
+
+ expect(series.partialTimestamps).toStrictEqual(new Set([1060]));
+ });
+
it('uses getLegend for label when currentQuery is provided', () => {
const apiResponse = createApiResponse([
{
diff --git a/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/utils.ts b/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/utils.ts
index 432cb46296..4c7d88efc5 100644
--- a/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/utils.ts
+++ b/frontend/src/container/WidgetCard/Panels/TimeSeriesPanel/utils.ts
@@ -101,6 +101,9 @@ export const prepareUPlotConfig = ({
fillMode: widget.fillMode || FillMode.None,
isDarkMode,
metric: series.metric,
+ partialTimestamps: series.partialTimestamps
+ ? new Set(series.partialTimestamps)
+ : undefined,
});
});
diff --git a/frontend/src/lib/newQueryBuilder/__test__/convertNewDataToOld.test.ts b/frontend/src/lib/newQueryBuilder/__test__/convertNewDataToOld.test.ts
new file mode 100644
index 0000000000..947dc1b417
--- /dev/null
+++ b/frontend/src/lib/newQueryBuilder/__test__/convertNewDataToOld.test.ts
@@ -0,0 +1,42 @@
+import { MetricRangePayloadV3 } from 'types/api/metrics/getQueryRange';
+
+import { convertNewDataToOld } from '../convertNewDataToOld';
+
+describe('convertNewDataToOld', () => {
+ it('carries partial values as epoch-second partialTimestamps', () => {
+ const payload = {
+ data: {
+ resultType: 'time_series',
+ result: [
+ {
+ queryName: 'A',
+ series: [
+ {
+ labels: {},
+ labelsArray: [],
+ values: [
+ { timestamp: 1_000_000, value: '1' },
+ { timestamp: 1_060_000, value: '0.2', partial: true },
+ ],
+ },
+ {
+ labels: {},
+ labelsArray: [],
+ values: [{ timestamp: 1_000_000, value: '1' }],
+ },
+ ],
+ },
+ ],
+ },
+ } as unknown as MetricRangePayloadV3;
+
+ const [partial, complete] = convertNewDataToOld(payload).data.result;
+
+ expect(partial.values).toStrictEqual([
+ [1000, '1'],
+ [1060, '0.2'],
+ ]);
+ expect(partial.partialTimestamps).toStrictEqual([1060]);
+ expect(complete).not.toHaveProperty('partialTimestamps');
+ });
+});
diff --git a/frontend/src/lib/newQueryBuilder/convertNewDataToOld.ts b/frontend/src/lib/newQueryBuilder/convertNewDataToOld.ts
index 79fd6722ce..5e1f18635e 100644
--- a/frontend/src/lib/newQueryBuilder/convertNewDataToOld.ts
+++ b/frontend/src/lib/newQueryBuilder/convertNewDataToOld.ts
@@ -25,11 +25,16 @@ export const convertNewDataToOld = (
return [...acc, renderValues];
}, []);
+ const partialTimestamps = series.values
+ .filter((value) => value.partial)
+ .map((value) => value.timestamp / 1000);
+
const result: QueryData = {
metric: series.labels,
values,
queryName: `${item.queryName}`,
metaData: series.metaData,
+ ...(partialTimestamps.length ? { partialTimestamps } : {}),
};
oldResult.push(result);
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx
index a21c3f645a..0a61873ed2 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/__tests__/Tooltip.test.tsx
@@ -122,6 +122,27 @@ describe('Tooltip', () => {
expect(screen.getByText(expectedTitle)).toBeInTheDocument();
});
+ it('marks the header partial when a visible series has a partial bucket at the cursor', () => {
+ const withSeries = (series: unknown[]): uPlot =>
+ Object.assign(createUPlotInstance(0), { series });
+ const partial = { show: true, partialTimestamps: new Set([1]) };
+
+ const { unmount } = renderTooltip({
+ uPlotInstance: withSeries([{}, partial]),
+ });
+ expect(screen.getByTestId('uplot-tooltip-header-partial')).toHaveTextContent(
+ '(partial)',
+ );
+ unmount();
+
+ renderTooltip({
+ uPlotInstance: withSeries([{}, { ...partial, show: false }]),
+ });
+ expect(
+ screen.queryByTestId('uplot-tooltip-header-partial'),
+ ).not.toBeInTheDocument();
+ });
+
it('drops the date from the header title for a point on the current day', () => {
const todayTimestamp = dayjs().tz('UTC').startOf('hour').unix();
const uPlotInstance = createUPlotInstance(0, todayTimestamp);
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.module.scss b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.module.scss
index ee3a545d5a..deb590db81 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.module.scss
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.module.scss
@@ -13,6 +13,17 @@
gap: var(--spacing-2);
}
+.headerEnd {
+ display: flex;
+ align-items: center;
+ gap: var(--spacing-2);
+}
+
+.partialLabel {
+ font-style: italic;
+ opacity: 0.7;
+}
+
.pinnedItem {
padding: var(--spacing-4);
}
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.tsx
index 794fffef85..ec76417758 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipHeader/TooltipHeader.tsx
@@ -5,6 +5,7 @@ import { useTimezone } from 'providers/Timezone';
import type uPlot from 'uplot';
import { formatTimestampOmittingTodaysDate } from 'utils/timeUtils';
+import type { ExtendedSeries } from '../../../../config/types';
import { TooltipContentItem } from '../../../types';
import TooltipItem from '../TooltipItem/TooltipItem';
import TooltipPinnedBadge from '../TooltipPinnedBadge/TooltipPinnedBadge';
@@ -34,7 +35,7 @@ export default function TooltipHeader({
const { timezone: userTimezone } = useTimezone();
const resolvedTimezone = timezone?.value ?? userTimezone.value;
- const headerTitle = useMemo(() => {
+ const header = useMemo(() => {
if (!showTooltipHeader) {
return null;
}
@@ -46,14 +47,21 @@ export default function TooltipHeader({
if (timestamp == null) {
return null;
}
- return formatTimestampOmittingTodaysDate(
- timestamp * 1000,
- resolvedTimezone,
- dateFormat,
- );
+ return {
+ title: formatTimestampOmittingTodaysDate(
+ timestamp * 1000,
+ resolvedTimezone,
+ dateFormat,
+ ),
+ isPartial: (uPlotInstance.series ?? []).some(
+ (series: ExtendedSeries) =>
+ series.show && series.partialTimestamps?.has(timestamp),
+ ),
+ };
}, [
resolvedTimezone,
uPlotInstance.data,
+ uPlotInstance.series,
uPlotInstance.cursor.idx,
showTooltipHeader,
dateFormat,
@@ -64,10 +72,22 @@ export default function TooltipHeader({
className={Styles.headerContainer}
data-testid="uplot-tooltip-header-container"
>
- {showTooltipHeader && headerTitle && (
+ {showTooltipHeader && header && (
<div className={cx(Styles.headerRow, headerRowClassName)}>
- <span>{headerTitle}</span>
- {isPinned && <TooltipPinnedBadge />}
+ <span>{header.title}</span>
+ {(header.isPartial || isPinned) && (
+ <span className={Styles.headerEnd}>
+ {header.isPartial && (
+ <span
+ className={Styles.partialLabel}
+ data-testid="uplot-tooltip-header-partial"
+ >
+ (partial)
+ </span>
+ )}
+ {isPinned && <TooltipPinnedBadge />}
+ </span>
+ )}
</div>
)}
diff --git a/frontend/src/lib/uPlotV2/config/UPlotConfigBuilder.ts b/frontend/src/lib/uPlotV2/config/UPlotConfigBuilder.ts
index 480e503a9f..30d3d18cea 100644
--- a/frontend/src/lib/uPlotV2/config/UPlotConfigBuilder.ts
+++ b/frontend/src/lib/uPlotV2/config/UPlotConfigBuilder.ts
@@ -1,5 +1,6 @@
import { SeriesVisibilityItem } from 'lib/visualization/panels/types';
import { getStoredSeriesVisibility } from 'lib/visualization/panels/utils/legendVisibilityUtils';
+import { partialPointsDrawHook } from 'lib/uPlotV2/hooks/partialPointsDrawHook';
import { ThresholdsDrawHookOptions } from 'lib/uPlotV2/hooks/types';
import { thresholdsDrawHook } from 'lib/uPlotV2/hooks/useThresholdsDrawHook';
import { resolveSeriesVisibility } from 'lib/uPlotV2/utils/seriesVisibility';
@@ -81,6 +82,8 @@ export class UPlotConfigBuilder extends ConfigBuilder<
private thresholds: Record<string, ThresholdsDrawHookOptions> = {};
+ private hasPartialPointsHook = false;
+
private tzDate: ((timestamp: number) => Date) | undefined;
private id: string;
@@ -177,6 +180,10 @@ export class UPlotConfigBuilder extends ConfigBuilder<
*/
addSeries(props: SeriesProps): void {
this.series.push(new UPlotSeriesBuilder(props));
+ if (props.partialTimestamps?.size && !this.hasPartialPointsHook) {
+ this.hasPartialPointsHook = true;
+ this.addHook('draw', partialPointsDrawHook);
+ }
}
getSeriesSpanGapsOptions(): SeriesSpanGapsOption[] {
diff --git a/frontend/src/lib/uPlotV2/config/UPlotSeriesBuilder.ts b/frontend/src/lib/uPlotV2/config/UPlotSeriesBuilder.ts
index b683ea8300..1443e4f28f 100644
--- a/frontend/src/lib/uPlotV2/config/UPlotSeriesBuilder.ts
+++ b/frontend/src/lib/uPlotV2/config/UPlotSeriesBuilder.ts
@@ -4,6 +4,7 @@ import { calculateWidthBasedOnStepInterval } from 'lib/uPlotV2/utils';
import uPlot, { Series } from 'uplot';
import { resolveFillOpacity, toAlphaHex } from '../utils/fillOpacity';
+import { reportBarRect } from '../utils/barRect';
import { generateGradientFill } from '../utils/generateGradientFill';
import { isolatedPointFilter } from '../utils/seriesPointsFilter';
import {
@@ -218,7 +219,14 @@ export class UPlotSeriesBuilder extends ConfigBuilder<
}
getConfig(): ExtendedSeries {
- const { scaleKey, label, spanGaps, show = true, metric } = this.props;
+ const {
+ scaleKey,
+ label,
+ spanGaps,
+ show = true,
+ metric,
+ partialTimestamps,
+ } = this.props;
const resolvedLineColor = this.getLineColor();
@@ -246,6 +254,7 @@ export class UPlotSeriesBuilder extends ConfigBuilder<
...pathConfig,
points: Object.keys(pointsConfig).length > 0 ? pointsConfig : undefined,
metric,
+ ...(partialTimestamps?.size ? { partialTimestamps } : {}),
};
}
}
@@ -358,6 +367,7 @@ function getBarPathBuilder({
builders[barsCfgKey] = barsPathBuilderFactory({
size: [barWidthFactor, effectiveBarMaxWidth],
align: barAlignment,
+ each: reportBarRect,
});
}
@@ -372,6 +382,7 @@ function getBarPathBuilder({
builders[barsCfgKey] = barsPathBuilderFactory({
size: [barWidthFactor, barMaxWidth],
align: barAlignment,
+ each: reportBarRect,
});
}
diff --git a/frontend/src/lib/uPlotV2/config/__tests__/UPlotConfigBuilder.test.ts b/frontend/src/lib/uPlotV2/config/__tests__/UPlotConfigBuilder.test.ts
index 3bc9473bfc..ebaecb1ff0 100644
--- a/frontend/src/lib/uPlotV2/config/__tests__/UPlotConfigBuilder.test.ts
+++ b/frontend/src/lib/uPlotV2/config/__tests__/UPlotConfigBuilder.test.ts
@@ -650,4 +650,20 @@ describe('UPlotConfigBuilder stacking', () => {
expect(builder.getConfig().bands).toStrictEqual([{ series: [1, 3] }]);
});
+
+ it('registers the partial points draw hook once, only for series with partial timestamps', () => {
+ const props: SeriesProps = {
+ scaleKey: 'y',
+ label: 'Requests',
+ colorMapping: {},
+ drawStyle: DrawStyle.Line,
+ };
+ const builder = new UPlotConfigBuilder({ id: 'partial' });
+ builder.addSeries(props);
+ expect(builder.getConfig().hooks?.draw ?? []).toHaveLength(0);
+
+ builder.addSeries({ ...props, partialTimestamps: new Set([40]) });
+ builder.addSeries({ ...props, partialTimestamps: new Set([40]) });
+ expect(builder.getConfig().hooks?.draw).toHaveLength(1);
+ });
});
diff --git a/frontend/src/lib/uPlotV2/config/__tests__/UPlotSeriesBuilder.test.ts b/frontend/src/lib/uPlotV2/config/__tests__/UPlotSeriesBuilder.test.ts
index 8ec1e99705..54577d4da5 100644
--- a/frontend/src/lib/uPlotV2/config/__tests__/UPlotSeriesBuilder.test.ts
+++ b/frontend/src/lib/uPlotV2/config/__tests__/UPlotSeriesBuilder.test.ts
@@ -1,6 +1,7 @@
import { themeColors } from 'constants/theme';
import uPlot from 'uplot';
+import { reportBarRect } from '../../utils/barRect';
import { isolatedPointFilter } from '../../utils/seriesPointsFilter';
import type { SeriesProps } from '../types';
import { DrawStyle, FillMode, LineInterpolation, LineStyle } from '../types';
@@ -398,4 +399,29 @@ describe('UPlotSeriesBuilder', () => {
expect(builder.getConfig().fill).toBeUndefined();
});
+
+ it('exposes partial timestamps only when there are some', () => {
+ const partialTimestamps = new Set([40]);
+
+ expect(
+ new UPlotSeriesBuilder(createBaseProps({ partialTimestamps })).getConfig(),
+ ).toHaveProperty('partialTimestamps', partialTimestamps);
+ expect(
+ new UPlotSeriesBuilder(
+ createBaseProps({ partialTimestamps: new Set() }),
+ ).getConfig(),
+ ).not.toHaveProperty('partialTimestamps');
+ });
+
+ it('reports bar rects from bar path builders', () => {
+ const config = new UPlotSeriesBuilder(
+ createBaseProps({ drawStyle: DrawStyle.Bar, barMaxWidth: 321 }),
+ ).getConfig();
+
+ config.paths?.({} as uPlot, 1, 0, 1);
+
+ expect(uPlot.paths.bars).toHaveBeenCalledWith(
+ expect.objectContaining({ each: reportBarRect }),
+ );
+ });
});
diff --git a/frontend/src/lib/uPlotV2/config/types.ts b/frontend/src/lib/uPlotV2/config/types.ts
index 5937a197d9..cbb8f0ea67 100644
--- a/frontend/src/lib/uPlotV2/config/types.ts
+++ b/frontend/src/lib/uPlotV2/config/types.ts
@@ -201,6 +201,7 @@ export enum FillMode {
export type ExtendedSeries = Series & {
metric?: { [key: string]: string };
+ partialTimestamps?: Set<number>;
};
export interface SeriesProps extends LineConfig, PointsConfig, BarConfig {
@@ -229,6 +230,8 @@ export interface SeriesProps extends LineConfig, PointsConfig, BarConfig {
isDarkMode?: boolean;
stepInterval?: number;
metric?: { [key: string]: string };
+ /** Epoch-second x values whose bucket doesn't cover a full step; marked with a dotted ring. */
+ partialTimestamps?: Set<number>;
}
export interface LegendItem {
diff --git a/frontend/src/lib/uPlotV2/hooks/__tests__/partialPointsDrawHook.test.ts b/frontend/src/lib/uPlotV2/hooks/__tests__/partialPointsDrawHook.test.ts
new file mode 100644
index 0000000000..a2fc863be5
--- /dev/null
+++ b/frontend/src/lib/uPlotV2/hooks/__tests__/partialPointsDrawHook.test.ts
@@ -0,0 +1,77 @@
+import uPlot from 'uplot';
+
+import type { ExtendedSeries } from '../../config/types';
+import { reportBarRect } from '../../utils/barRect';
+import { partialPointsDrawHook } from '../partialPointsDrawHook';
+
+function createPlot(
+ series: Partial<ExtendedSeries>,
+ values: (number | null)[] = [1, 2, 3],
+): { u: uPlot; ctx: Record<string, jest.Mock> } {
+ const ctx = {
+ save: jest.fn(),
+ restore: jest.fn(),
+ beginPath: jest.fn(),
+ rect: jest.fn(),
+ clip: jest.fn(),
+ arc: jest.fn(),
+ fill: jest.fn(),
+ stroke: jest.fn(),
+ setLineDash: jest.fn(),
+ strokeRect: jest.fn(),
+ };
+ const xValues = [10, 20, 30];
+ const u = {
+ ctx,
+ bbox: { left: 0, top: 0, width: 100, height: 100 },
+ data: [xValues, values],
+ series: [{}, { show: true, stroke: 'red', points: { size: 4 }, ...series }],
+ valToIdx: (value: number): number => xValues.indexOf(value),
+ valToPos: (value: number): number => value,
+ } as unknown as uPlot;
+ return { u, ctx };
+}
+
+describe('partialPointsDrawHook', () => {
+ it('draws a dot and a dotted ring on each partial point', () => {
+ const { u, ctx } = createPlot({ partialTimestamps: new Set([30]) });
+
+ partialPointsDrawHook(u);
+
+ expect(ctx.arc).toHaveBeenCalledTimes(2);
+ expect(ctx.arc).toHaveBeenCalledWith(30, 3, 2, 0, 2 * Math.PI);
+ expect(ctx.arc).toHaveBeenCalledWith(30, 3, 5, 0, 2 * Math.PI);
+ expect(ctx.setLineDash).toHaveBeenCalledWith([2, 2]);
+ expect(ctx.restore).toHaveBeenCalled();
+ });
+
+ it('skips hidden series, null values and timestamps not in the data', () => {
+ const hidden = createPlot({ show: false, partialTimestamps: new Set([30]) });
+ const missing = createPlot({ partialTimestamps: new Set([30]) }, [
+ 1,
+ 2,
+ null,
+ ]);
+ const unknown = createPlot({ partialTimestamps: new Set([40]) });
+
+ [hidden, missing, unknown].forEach(({ u, ctx }) => {
+ partialPointsDrawHook(u);
+ expect(ctx.arc).not.toHaveBeenCalled();
+ });
+ });
+
+ it('draws a dotted outline around a partial bar', () => {
+ const { u, ctx } = createPlot({
+ partialTimestamps: new Set([30]),
+ paths: (plot, seriesIdx, idx) => {
+ reportBarRect(plot, seriesIdx, idx, 10, 20, 8, 30);
+ return null;
+ },
+ });
+
+ partialPointsDrawHook(u);
+
+ expect(ctx.strokeRect).toHaveBeenCalledWith(7, 17, 14, 36);
+ expect(ctx.arc).not.toHaveBeenCalled();
+ });
+});
diff --git a/frontend/src/lib/uPlotV2/hooks/partialPointsDrawHook.ts b/frontend/src/lib/uPlotV2/hooks/partialPointsDrawHook.ts
new file mode 100644
index 0000000000..25a56022f6
--- /dev/null
+++ b/frontend/src/lib/uPlotV2/hooks/partialPointsDrawHook.ts
@@ -0,0 +1,89 @@
+import uPlot from 'uplot';
+
+import { ExtendedSeries } from '../config/types';
+import { BarRect, measureBar } from '../utils/barRect';
+
+const DEFAULT_POINT_SIZE = 5;
+const RING_GAP = 3;
+const RING_WIDTH = 1.5;
+const RING_DASH = [2, 2];
+
+function drawRing(
+ u: uPlot,
+ series: ExtendedSeries,
+ idx: number,
+ value: number,
+): void {
+ const { ctx } = u;
+ const { pxRatio } = uPlot;
+ const cx = u.valToPos(u.data[0][idx], 'x', true);
+ const cy = u.valToPos(value, series.scale ?? 'y', true);
+ const radius = ((series.points?.size ?? DEFAULT_POINT_SIZE) / 2) * pxRatio;
+
+ ctx.beginPath();
+ ctx.arc(cx, cy, radius, 0, 2 * Math.PI);
+ ctx.fill();
+
+ ctx.lineWidth = RING_WIDTH * pxRatio;
+ ctx.setLineDash(RING_DASH.map((segment) => segment * pxRatio));
+ ctx.beginPath();
+ ctx.arc(cx, cy, radius + RING_GAP * pxRatio, 0, 2 * Math.PI);
+ ctx.stroke();
+}
+
+function drawBarOutline(u: uPlot, rect: BarRect): void {
+ const gap = RING_GAP * uPlot.pxRatio;
+ u.ctx.lineWidth = RING_WIDTH * uPlot.pxRatio;
+ u.ctx.setLineDash(RING_DASH.map((segment) => segment * uPlot.pxRatio));
+ u.ctx.strokeRect(
+ rect.left - gap,
+ rect.top - gap,
+ rect.width + 2 * gap,
+ rect.height + 2 * gap,
+ );
+}
+
+/**
+ * Marks each series' partial buckets: a dotted outline around bars, a dot and dotted
+ * ring on line and point series.
+ */
+export function partialPointsDrawHook(u: uPlot): void {
+ const { ctx, bbox } = u;
+ const xValues = u.data[0];
+
+ ctx.save();
+ ctx.beginPath();
+ ctx.rect(bbox.left, bbox.top, bbox.width, bbox.height);
+ ctx.clip();
+
+ for (let seriesIdx = 1; seriesIdx < u.series.length; seriesIdx += 1) {
+ const series = u.series[seriesIdx] as ExtendedSeries;
+ if (!series.show || !series.partialTimestamps) {
+ continue;
+ }
+ const color =
+ typeof series.stroke === 'function'
+ ? series.stroke(u, seriesIdx)
+ : (series.stroke ?? '');
+ ctx.fillStyle = color;
+ ctx.strokeStyle = color;
+ ctx.globalAlpha = series.alpha ?? 1;
+
+ series.partialTimestamps.forEach((timestamp) => {
+ const idx = u.valToIdx(timestamp);
+ const value = u.data[seriesIdx][idx];
+ if (xValues[idx] !== timestamp || value == null) {
+ return;
+ }
+ ctx.setLineDash([]);
+ const bar = measureBar(u, seriesIdx, idx);
+ if (bar) {
+ drawBarOutline(u, bar);
+ } else {
+ drawRing(u, series, idx, value);
+ }
+ });
+ }
+
+ ctx.restore();
+}
diff --git a/frontend/src/lib/uPlotV2/utils/__tests__/barRect.test.ts b/frontend/src/lib/uPlotV2/utils/__tests__/barRect.test.ts
new file mode 100644
index 0000000000..b0b4723ced
--- /dev/null
+++ b/frontend/src/lib/uPlotV2/utils/__tests__/barRect.test.ts
@@ -0,0 +1,30 @@
+import type uPlot from 'uplot';
+
+import { measureBar, reportBarRect } from '../barRect';
+
+function plotWithPaths(paths?: uPlot.Series['paths']): uPlot {
+ return { series: [{}, { paths }] } as unknown as uPlot;
+}
+
+describe('measureBar', () => {
+ it('returns the rect the bar paths report for that index', () => {
+ const paths = jest.fn((u: uPlot, seriesIdx: number, idx: number) => {
+ reportBarRect(u, seriesIdx, idx, 10, 20, 8, 30);
+ return null;
+ });
+ const u = plotWithPaths(paths);
+
+ expect(measureBar(u, 1, 4)).toStrictEqual({
+ left: 10,
+ top: 20,
+ width: 8,
+ height: 30,
+ });
+ expect(paths).toHaveBeenCalledWith(u, 1, 4, 4);
+ });
+
+ it('returns null for series whose paths report no bar', () => {
+ expect(measureBar(plotWithPaths(jest.fn(() => null)), 1, 0)).toBeNull();
+ expect(measureBar(plotWithPaths(), 1, 0)).toBeNull();
+ });
+});
diff --git a/frontend/src/lib/uPlotV2/utils/barRect.ts b/frontend/src/lib/uPlotV2/utils/barRect.ts
new file mode 100644
index 0000000000..564a261c48
--- /dev/null
+++ b/frontend/src/lib/uPlotV2/utils/barRect.ts
@@ -0,0 +1,45 @@
+import type uPlot from 'uplot';
+
+export interface BarRect {
+ left: number;
+ top: number;
+ width: number;
+ height: number;
+}
+
+let onBarRect: ((rect: BarRect) => void) | null = null;
+
+/** `each` callback for bar path builders; reports bar rects while {@link measureBar} runs. */
+// eslint-disable-next-line max-params
+export function reportBarRect(
+ _u: uPlot,
+ _seriesIdx: number,
+ _idx: number,
+ left: number,
+ top: number,
+ width: number,
+ height: number,
+): void {
+ onBarRect?.({ left, top, width, height });
+}
+
+/**
+ * Canvas rect of one bar, from re-running the series' paths for that index.
+ * `null` for series not drawn as bars.
+ */
+export function measureBar(
+ u: uPlot,
+ seriesIdx: number,
+ idx: number,
+): BarRect | null {
+ let rect: BarRect | null = null;
+ onBarRect = (measured): void => {
+ rect = measured;
+ };
+ try {
+ u.series[seriesIdx].paths?.(u, seriesIdx, idx, idx);
+ } finally {
+ onBarRect = null;
+ }
+ return rect;
+}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/AreaChartPanel/utils/buildConfig.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/AreaChartPanel/utils/buildConfig.ts
index c211cea7df..6700b3a85b 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/AreaChartPanel/utils/buildConfig.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/AreaChartPanel/utils/buildConfig.ts
@@ -15,6 +15,7 @@ import {
import { resolveSeriesLabelV5 } from 'pages/DashboardPage/DashboardContainer/Panels/utils/resolveSeriesLabel';
import type { PanelSeries } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
import {
+ getPartialTimestamps,
hasSingleVisiblePoint,
toClickPluginPayload,
} from 'pages/DashboardPage/DashboardContainer/queryV5/uplotData';
@@ -155,6 +156,7 @@ function addSeries({
fillOpacity,
isDarkMode,
metric: s.labels,
+ partialTimestamps: getPartialTimestamps(s.values),
});
});
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/__tests__/buildConfig.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/__tests__/buildConfig.test.ts
new file mode 100644
index 0000000000..1bc6a5cc91
--- /dev/null
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/__tests__/buildConfig.test.ts
@@ -0,0 +1,34 @@
+import type { DashboardtypesBarChartPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
+import { UTC_TIMEZONE } from 'components/CustomTimePicker/timezoneUtils';
+import type { ExtendedSeries } from 'lib/uPlotV2/config/types';
+import { PanelMode } from 'lib/visualization/panels/types';
+
+import { buildBarChartConfig } from '../buildConfig';
+
+describe('buildBarChartConfig partial buckets', () => {
+ it('passes partial timestamps (epoch seconds) to the series', () => {
+ const config = buildBarChartConfig({
+ panelId: 'p1',
+ spec: {} as DashboardtypesBarChartPanelSpecDTO,
+ builderQueries: [],
+ series: [
+ {
+ queryName: 'A',
+ legend: 'A',
+ labels: {},
+ values: [
+ { timestamp: 1000, value: 1 },
+ { timestamp: 61000, value: 0.2, partial: true },
+ ],
+ kind: 'series',
+ aggregation: { index: 0, alias: 'A' },
+ },
+ ],
+ isDarkMode: false,
+ timezone: UTC_TIMEZONE,
+ panelMode: PanelMode.DASHBOARD_VIEW,
+ }).getConfig().series?.[1] as ExtendedSeries;
+
+ expect(config.partialTimestamps).toStrictEqual(new Set([61]));
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts
index 264f40427c..94538b4907 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/BarChartPanel/utils/buildConfig.ts
@@ -5,7 +5,10 @@ import {
} from 'pages/DashboardPage/DashboardContainer/Panels/utils/baseConfigBuilder';
import { resolveSeriesLabelV5 } from 'pages/DashboardPage/DashboardContainer/Panels/utils/resolveSeriesLabel';
import type { PanelSeries } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
-import { toClickPluginPayload } from 'pages/DashboardPage/DashboardContainer/queryV5/uplotData';
+import {
+ getPartialTimestamps,
+ toClickPluginPayload,
+} from 'pages/DashboardPage/DashboardContainer/queryV5/uplotData';
import getLabelName from 'lib/getLabelName';
import { DrawStyle } from 'lib/uPlotV2/config/types';
import { UPlotConfigBuilder } from 'lib/uPlotV2/config/UPlotConfigBuilder';
@@ -102,6 +105,7 @@ function addSeries({
isDarkMode,
stepInterval,
metric: s.labels,
+ partialTimestamps: getPartialTimestamps(s.values),
});
});
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/__tests__/buildConfig.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/__tests__/buildConfig.test.ts
index f734ade440..f1432733df 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/__tests__/buildConfig.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/__tests__/buildConfig.test.ts
@@ -1,5 +1,6 @@
import type { DashboardtypesTimeSeriesPanelSpecDTO } from 'api/generated/services/sigNoz.schemas';
import { UTC_TIMEZONE } from 'components/CustomTimePicker/timezoneUtils';
+import type { ExtendedSeries } from 'lib/uPlotV2/config/types';
import { PanelMode } from 'lib/visualization/panels/types';
import type { PanelSeries } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
@@ -74,3 +75,27 @@ describe('buildTimeSeriesConfig spanGaps', () => {
).toStrictEqual([10]);
});
});
+
+describe('buildTimeSeriesConfig partial buckets', () => {
+ it('passes partial timestamps (epoch seconds) to the series', () => {
+ const config = buildTimeSeriesConfig({
+ panelId: 'p1',
+ spec: {} as DashboardtypesTimeSeriesPanelSpecDTO,
+ builderQueries: [],
+ series: [
+ {
+ ...series[0],
+ values: [
+ { timestamp: 1000, value: 1 },
+ { timestamp: 61000, value: 0.2, partial: true },
+ ],
+ },
+ ],
+ isDarkMode: false,
+ timezone: UTC_TIMEZONE,
+ panelMode: PanelMode.DASHBOARD_VIEW,
+ }).getConfig().series?.[1] as ExtendedSeries;
+
+ expect(config.partialTimestamps).toStrictEqual(new Set([61]));
+ });
+});
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts
index 97cba6f40c..329125ccfc 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/Panels/kinds/TimeSeriesPanel/utils/buildConfig.ts
@@ -13,6 +13,7 @@ import { resolveSpanGaps } from 'pages/DashboardPage/DashboardContainer/Panels/u
import { resolveSeriesLabelV5 } from 'pages/DashboardPage/DashboardContainer/Panels/utils/resolveSeriesLabel';
import type { PanelSeries } from 'pages/DashboardPage/DashboardContainer/queryV5/types';
import {
+ getPartialTimestamps,
hasSingleVisiblePoint,
toClickPluginPayload,
} from 'pages/DashboardPage/DashboardContainer/queryV5/uplotData';
@@ -149,6 +150,7 @@ function addSeries({
fillMode,
isDarkMode,
metric: s.labels,
+ partialTimestamps: getPartialTimestamps(s.values),
});
});
}
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/uplotData.test.ts b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/uplotData.test.ts
index eac2281745..b4d8992dcf 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/uplotData.test.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/__tests__/uplotData.test.ts
@@ -1,5 +1,6 @@
import type { PanelSeries } from '../types';
import {
+ getPartialTimestamps,
hasSingleVisiblePoint,
prepareAlignedData,
toClickPluginPayload,
@@ -85,6 +86,22 @@ describe('hasSingleVisiblePoint', () => {
});
});
+describe('getPartialTimestamps', () => {
+ it('returns partial timestamps in epoch seconds', () => {
+ expect(
+ getPartialTimestamps([
+ { timestamp: 1_000_500, value: 1, partial: true },
+ { timestamp: 2_000_000, value: 2 },
+ { timestamp: 3_000_000, value: 3, partial: true },
+ ]),
+ ).toStrictEqual(new Set([1000, 3000]));
+ });
+
+ it('returns undefined when nothing is partial', () => {
+ expect(getPartialTimestamps([{ timestamp: 1000, value: 1 }])).toBeUndefined();
+ });
+});
+
describe('toClickPluginPayload', () => {
it('produces the tuple-shaped legacy result the shared click plugin reads', () => {
const payload = toClickPluginPayload([
diff --git a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/uplotData.ts b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/uplotData.ts
index 7bc5f08b22..544ef93bef 100644
--- a/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/uplotData.ts
+++ b/frontend/src/pages/DashboardPage/DashboardContainer/queryV5/uplotData.ts
@@ -41,6 +41,19 @@ export function prepareAlignedData(series: PanelSeries[]): uPlot.AlignedData {
return [timestamps, ...yValues] as uPlot.AlignedData;
}
+/** Epoch-second x values of the series' partial buckets; `undefined` when none are partial. */
+export function getPartialTimestamps(
+ values: PanelSeriesPoint[],
+): Set<number> | undefined {
+ const timestamps = new Set<number>();
+ values.forEach((point) => {
+ if (point.partial) {
+ timestamps.add(Math.floor(point.timestamp / 1000));
+ }
+ });
+ return timestamps.size ? timestamps : undefined;
+}
+
/**
* True when the series has at most one finite point — can't draw a line, so renderers degrade to
* points (V1 `hasSingleVisiblePoint` parity).
diff --git a/frontend/src/types/api/widgets/getQuery.ts b/frontend/src/types/api/widgets/getQuery.ts
index 2fe74a0626..6190ded92e 100644
--- a/frontend/src/types/api/widgets/getQuery.ts
+++ b/frontend/src/types/api/widgets/getQuery.ts
@@ -21,6 +21,8 @@ export interface QueryData {
queryName: string;
legend?: string;
values: [number, string][];
+ /** Epoch-second x values (as in `values`) of buckets that don't cover a full step. */
+ partialTimestamps?: number[];
quantity?: number[];
unit?: string;
table?: {
@@ -45,7 +47,7 @@ export interface SeriesItem {
[key: string]: string;
};
labelsArray: { [key: string]: string }[];
- values: { timestamp: number; value: string }[];
+ values: { timestamp: number; value: string; partial?: boolean }[];
metaData?: {
alias: string;
index: number;