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]: only clicked legend graph visible (#4226)

Rajat Dabade55664872bd9d
diff --git a/frontend/src/lib/uPlotLib/getUplotChartOptions.ts b/frontend/src/lib/uPlotLib/getUplotChartOptions.ts
index 3a5ec4b2c6..354deb0b5a 100644
--- a/frontend/src/lib/uPlotLib/getUplotChartOptions.ts
+++ b/frontend/src/lib/uPlotLib/getUplotChartOptions.ts
@@ -55,6 +55,7 @@ export const getUPlotChartOptions = ({
legend: {
show: true,
live: false,
+ isolate: true,
},
focus: {
alpha: 0.3,
@@ -158,16 +159,24 @@ export const getUPlotChartOptions = ({
(self): void => {
const legend = self.root.querySelector('.u-legend');
if (legend) {
- const seriesEls = legend.querySelectorAll('.u-label');
+ const seriesEls = legend.querySelectorAll('.u-series');
const seriesArray = Array.from(seriesEls);
seriesArray.forEach((seriesEl, index) => {
seriesEl.addEventListener('click', () => {
if (graphsVisibilityStates) {
setGraphsVisibilityStates?.((prev) => {
const newGraphVisibilityStates = [...prev];
- newGraphVisibilityStates[index + 1] = !newGraphVisibilityStates[
- index + 1
- ];
+ if (
+ newGraphVisibilityStates[index + 1] &&
+ newGraphVisibilityStates.every((value, i) =>
+ i === index + 1 ? value : !value,
+ )
+ ) {
+ newGraphVisibilityStates.fill(true);
+ } else {
+ newGraphVisibilityStates.fill(false);
+ newGraphVisibilityStates[index + 1] = true;
+ }
return newGraphVisibilityStates;
});
}