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: apply x axis date/time formatting only to panel types that have date/time in x axis (#6956)

Shaheer Kochaif2be856f63bc
diff --git a/frontend/src/container/AnomalyAlertEvaluationView/AnomalyAlertEvaluationView.tsx b/frontend/src/container/AnomalyAlertEvaluationView/AnomalyAlertEvaluationView.tsx
index 28d5397302..4c3a78f3e7 100644
--- a/frontend/src/container/AnomalyAlertEvaluationView/AnomalyAlertEvaluationView.tsx
+++ b/frontend/src/container/AnomalyAlertEvaluationView/AnomalyAlertEvaluationView.tsx
@@ -259,7 +259,7 @@ function AnomalyAlertEvaluationView({
grid: {
show: true,
},
- axes: getAxes(isDarkMode, yAxisUnit),
+ axes: getAxes({ isDarkMode, yAxisUnit }),
tzDate: (timestamp: number): Date =>
uPlot.tzDate(new Date(timestamp * 1e3), timezone.value),
};
diff --git a/frontend/src/container/BillingContainer/BillingUsageGraph/BillingUsageGraph.tsx b/frontend/src/container/BillingContainer/BillingUsageGraph/BillingUsageGraph.tsx
index 4a4e81c1f2..448eac69f3 100644
--- a/frontend/src/container/BillingContainer/BillingUsageGraph/BillingUsageGraph.tsx
+++ b/frontend/src/container/BillingContainer/BillingUsageGraph/BillingUsageGraph.tsx
@@ -122,7 +122,7 @@ export function BillingUsageGraph(props: BillingUsageGraphProps): JSX.Element {
[graphCompatibleData.data.result],
);
- const axesOptions = getAxes(isDarkMode, '');
+ const axesOptions = getAxes({ isDarkMode, yAxisUnit: '' });
const optionsForChart: uPlot.Options = useMemo(
() => ({
diff --git a/frontend/src/lib/uPlotLib/getUplotChartOptions.ts b/frontend/src/lib/uPlotLib/getUplotChartOptions.ts
index df7d6547e3..61e32e9700 100644
--- a/frontend/src/lib/uPlotLib/getUplotChartOptions.ts
+++ b/frontend/src/lib/uPlotLib/getUplotChartOptions.ts
@@ -387,6 +387,6 @@ export const getUPlotChartOptions = ({
hiddenGraph,
isDarkMode,
}),
- axes: getAxes(isDarkMode, yAxisUnit),
+ axes: getAxes({ isDarkMode, yAxisUnit, panelType }),
};
};
diff --git a/frontend/src/lib/uPlotLib/getUplotHistogramChartOptions.ts b/frontend/src/lib/uPlotLib/getUplotHistogramChartOptions.ts
index 81750ff857..bee488f891 100644
--- a/frontend/src/lib/uPlotLib/getUplotHistogramChartOptions.ts
+++ b/frontend/src/lib/uPlotLib/getUplotHistogramChartOptions.ts
@@ -123,6 +123,7 @@ export const getUplotHistogramChartOptions = ({
setGraphsVisibilityStates,
mergeAllQueries,
onClickHandler = _noop,
+ panelType,
}: GetUplotHistogramChartOptionsProps): uPlot.Options =>
({
id,
@@ -210,5 +211,5 @@ export const getUplotHistogramChartOptions = ({
},
],
},
- axes: getAxes(isDarkMode),
+ axes: getAxes({ isDarkMode, panelType }),
} as uPlot.Options);
diff --git a/frontend/src/lib/uPlotLib/utils/getAxes.ts b/frontend/src/lib/uPlotLib/utils/getAxes.ts
index e066886d7b..663bccad39 100644
--- a/frontend/src/lib/uPlotLib/utils/getAxes.ts
+++ b/frontend/src/lib/uPlotLib/utils/getAxes.ts
@@ -1,12 +1,27 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
import { getToolTipValue } from 'components/Graph/yAxisConfig';
+import { PANEL_TYPES } from 'constants/queryBuilder';
import { uPlotXAxisValuesFormat } from './constants';
import getGridColor from './getGridColor';
+const PANEL_TYPES_WITH_X_AXIS_DATETIME_FORMAT = [
+ PANEL_TYPES.TIME_SERIES,
+ PANEL_TYPES.BAR,
+ PANEL_TYPES.PIE,
+];
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
-const getAxes = (isDarkMode: boolean, yAxisUnit?: string): any => [
+const getAxes = ({
+ isDarkMode,
+ yAxisUnit,
+ panelType,
+}: {
+ isDarkMode: boolean;
+ yAxisUnit?: string;
+ panelType?: PANEL_TYPES;
+}): any => [
{
stroke: isDarkMode ? 'white' : 'black', // Color of the axis line
grid: {
@@ -19,7 +34,11 @@ const getAxes = (isDarkMode: boolean, yAxisUnit?: string): any => [
width: 0.3, // Width of the tick lines,
show: true,
},
- values: uPlotXAxisValuesFormat,
+ ...(PANEL_TYPES_WITH_X_AXIS_DATETIME_FORMAT.includes(panelType)
+ ? {
+ values: uPlotXAxisValuesFormat,
+ }
+ : {}),
gap: 5,
},
{