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: added new time-series graph (#10201)

Abhi kumaref80fb39fdd6
diff --git a/frontend/src/container/DashboardContainer/visualization/charts/TimeSeries/TimeSeries.tsx b/frontend/src/container/DashboardContainer/visualization/charts/TimeSeries/TimeSeries.tsx
new file mode 100644
index 0000000000..5b26e53f75
--- /dev/null
+++ b/frontend/src/container/DashboardContainer/visualization/charts/TimeSeries/TimeSeries.tsx
@@ -0,0 +1,97 @@
+import { useCallback, useRef } from 'react';
+import ChartLayout from 'container/DashboardContainer/visualization/layout/ChartLayout/ChartLayout';
+import Legend from 'lib/uPlotV2/components/Legend/Legend';
+import Tooltip from 'lib/uPlotV2/components/Tooltip/Tooltip';
+import {
+ LegendPosition,
+ TooltipRenderArgs,
+} from 'lib/uPlotV2/components/types';
+import UPlotChart from 'lib/uPlotV2/components/UPlotChart';
+import { PlotContextProvider } from 'lib/uPlotV2/context/PlotContext';
+import TooltipPlugin from 'lib/uPlotV2/plugins/TooltipPlugin/TooltipPlugin';
+import _noop from 'lodash-es/noop';
+import uPlot from 'uplot';
+
+import { ChartProps } from '../types';
+
+export default function TimeSeries({
+ legendConfig = { position: LegendPosition.BOTTOM },
+ config,
+ data,
+ width: containerWidth,
+ height: containerHeight,
+ disableTooltip = false,
+ canPinTooltip = false,
+ timezone,
+ yAxisUnit,
+ decimalPrecision,
+ syncMode,
+ syncKey,
+ onDestroy = _noop,
+ children,
+ layoutChildren,
+ 'data-testid': testId,
+}: ChartProps): JSX.Element {
+ const plotInstanceRef = useRef<uPlot | null>(null);
+
+ const legendComponent = useCallback(
+ (averageLegendWidth: number): React.ReactNode => {
+ return (
+ <Legend
+ config={config}
+ position={legendConfig.position}
+ averageLegendWidth={averageLegendWidth}
+ />
+ );
+ },
+ [config, legendConfig.position],
+ );
+
+ return (
+ <PlotContextProvider>
+ <ChartLayout
+ config={config}
+ containerWidth={containerWidth}
+ containerHeight={containerHeight}
+ legendConfig={legendConfig}
+ legendComponent={legendComponent}
+ layoutChildren={layoutChildren}
+ >
+ {({ chartWidth, chartHeight }): JSX.Element => (
+ <UPlotChart
+ config={config}
+ data={data}
+ width={chartWidth}
+ height={chartHeight}
+ plotRef={(plot): void => {
+ plotInstanceRef.current = plot;
+ }}
+ onDestroy={(plot: uPlot): void => {
+ plotInstanceRef.current = null;
+ onDestroy(plot);
+ }}
+ data-testid={testId}
+ >
+ {children}
+ {!disableTooltip && (
+ <TooltipPlugin
+ config={config}
+ canPinTooltip={canPinTooltip}
+ syncMode={syncMode}
+ syncKey={syncKey}
+ render={(props: TooltipRenderArgs): React.ReactNode => (
+ <Tooltip
+ {...props}
+ timezone={timezone}
+ yAxisUnit={yAxisUnit}
+ decimalPrecision={decimalPrecision}
+ />
+ )}
+ />
+ )}
+ </UPlotChart>
+ )}
+ </ChartLayout>
+ </PlotContextProvider>
+ );
+}
diff --git a/frontend/src/container/DashboardContainer/visualization/charts/types.ts b/frontend/src/container/DashboardContainer/visualization/charts/types.ts
new file mode 100644
index 0000000000..5ef5d1fe43
--- /dev/null
+++ b/frontend/src/container/DashboardContainer/visualization/charts/types.ts
@@ -0,0 +1,29 @@
+import { PrecisionOption } from 'components/Graph/types';
+import { LegendConfig } from 'lib/uPlotV2/components/types';
+import { UPlotConfigBuilder } from 'lib/uPlotV2/config/UPlotConfigBuilder';
+import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+interface BaseChartProps {
+ width: number;
+ height: number;
+ disableTooltip?: boolean;
+ timezone: string;
+ syncMode?: DashboardCursorSync;
+ syncKey?: string;
+ canPinTooltip?: boolean;
+ yAxisUnit?: string;
+ decimalPrecision?: PrecisionOption;
+}
+
+interface TimeSeriesChartProps extends BaseChartProps {
+ config: UPlotConfigBuilder;
+ legendConfig: LegendConfig;
+ data: uPlot.AlignedData;
+ plotRef?: (plot: uPlot | null) => void;
+ onDestroy?: (plot: uPlot) => void;
+ children?: React.ReactNode;
+ layoutChildren?: React.ReactNode;
+ 'data-testid'?: string;
+}
+
+export type ChartProps = TimeSeriesChartProps;