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: user dashboard preference (#11159)

Abhi kumar8b0ccc8ddc0c
diff --git a/frontend/src/constants/events.ts b/frontend/src/constants/events.ts
index 726fea4f92..baa4c573af 100644
--- a/frontend/src/constants/events.ts
+++ b/frontend/src/constants/events.ts
@@ -6,6 +6,7 @@ export enum Events {
TOOLTIP_PINNED = 'TOOLTIP_PINNED',
TOOLTIP_UNPINNED = 'TOOLTIP_UNPINNED',
TOOLTIP_CONTENT_SCROLLED = 'TOOLTIP_CONTENT_SCROLLED',
+ TOOLTIP_SYNC_MODE_CHANGED = 'TOOLTIP_SYNC_MODE_CHANGED',
}
export enum InfraMonitoringEvents {
diff --git a/frontend/src/constants/localStorage.ts b/frontend/src/constants/localStorage.ts
index d13c0d07cb..7e67ef4129 100644
--- a/frontend/src/constants/localStorage.ts
+++ b/frontend/src/constants/localStorage.ts
@@ -38,4 +38,5 @@ export enum LOCALSTORAGE {
DISSMISSED_COST_METER_INFO = 'DISMISSED_COST_METER_INFO',
DISMISSED_API_KEYS_DEPRECATION_BANNER = 'DISMISSED_API_KEYS_DEPRECATION_BANNER',
LICENSE_KEY_CALLOUT_DISMISSED = 'LICENSE_KEY_CALLOUT_DISMISSED',
+ DASHBOARD_PREFERENCES = 'DASHBOARD_PREFERENCES',
}
diff --git a/frontend/src/container/DashboardContainer/DashboardSettings/General/GeneralSettings.module.scss b/frontend/src/container/DashboardContainer/DashboardSettings/General/GeneralSettings.module.scss
new file mode 100644
index 0000000000..2bed3ac22a
--- /dev/null
+++ b/frontend/src/container/DashboardContainer/DashboardSettings/General/GeneralSettings.module.scss
@@ -0,0 +1,190 @@
+.overviewContent {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.overviewSettings {
+ border-radius: 3px;
+ border: 1px solid var(--l1-border);
+ padding: 16px !important;
+}
+
+.crossPanelSyncGroup {
+ display: flex;
+ flex-direction: column;
+ gap: 16px;
+}
+
+.crossPanelSyncSectionTitle {
+ color: var(--l1-foreground);
+ font-family: Inter;
+ font-size: 14px;
+ font-weight: 500;
+ line-height: 20px;
+}
+
+.crossPanelSyncRow {
+ display: flex;
+ flex-direction: row;
+ justify-content: space-between;
+ align-items: center;
+ gap: 16px;
+
+ & + & {
+ padding-top: 16px;
+ border-top: 1px solid var(--l1-border);
+ }
+}
+
+.crossPanelSyncInfo {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+.crossPanelSyncTitle {
+ color: var(--l2-foreground);
+ font-family: Inter;
+ font-size: 14px;
+ font-weight: 400;
+ line-height: 20px;
+}
+
+.crossPanelSyncDescription {
+ color: var(--l3-foreground);
+ font-family: Inter;
+ font-size: 13px;
+ font-weight: 400;
+ line-height: 20px;
+}
+
+.nameIconInput {
+ display: flex;
+}
+
+.dashboardImageInput {
+ :global(.ant-select-selector) {
+ display: flex;
+ width: 32px;
+ height: 32px;
+ padding: 6px;
+ justify-content: center;
+ align-items: center;
+ border-radius: 2px 0px 0px 2px;
+ border: 1px solid var(--l1-border) !important;
+ background: var(--l3-background) !important;
+
+ :global(.ant-select-selection-item) {
+ display: flex;
+ align-items: center;
+ }
+ }
+
+ &:global(.ant-select-dropdown) {
+ padding: 0px !important;
+ }
+
+ :global(.ant-select-item) {
+ padding: 0px;
+ align-items: center;
+ justify-content: center;
+
+ :global(.ant-select-item-option-content) {
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ }
+ }
+}
+
+.listItemImage {
+ height: 16px;
+ width: 16px;
+}
+
+.dashboardNameInput {
+ border-radius: 0px 2px 2px 0px;
+ border: 1px solid var(--l1-border);
+ background: var(--l3-background);
+}
+
+.dashboardName {
+ color: var(--l2-foreground);
+ font-family: Inter;
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 400;
+ line-height: 20px;
+ margin-bottom: 0.5rem;
+}
+
+.descriptionTextArea {
+ padding: 6px 6px 6px 8px;
+ border-radius: 2px;
+ border: 1px solid var(--l1-border);
+ background: var(--l3-background);
+}
+
+.overviewSettingsFooter {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ width: -webkit-fill-available;
+ padding: 12px 16px 12px 0px;
+ position: fixed;
+ bottom: 0;
+ height: 32px;
+ border-top: 1px solid var(--l1-border);
+ background: var(--l2-background);
+}
+
+.unsaved {
+ display: flex;
+ align-items: center;
+ gap: 8px;
+}
+
+.unsavedDot {
+ width: 6px;
+ height: 6px;
+ border-radius: 50px;
+ background: var(--primary-background);
+ box-shadow: 0px 0px 6px 0px
+ color-mix(in srgb, var(--primary-background) 40%, transparent);
+}
+
+.unsavedChanges {
+ color: var(--bg-robin-400);
+ font-family: Inter;
+ font-size: 14px;
+ font-style: normal;
+ font-weight: 400;
+ line-height: 24px;
+ letter-spacing: -0.07px;
+}
+
+.footerActionBtns {
+ display: flex;
+ gap: 8px;
+}
+
+.discardBtn {
+ margin: '16px 0';
+ color: var(--l1-foreground);
+ font-family: Inter;
+ font-size: 12px;
+ font-style: normal;
+ font-weight: 500;
+ line-height: 24px;
+}
+
+.saveBtn {
+ margin: 0px !important;
+ color: var(--l1-foreground);
+ font-family: Inter;
+ font-size: 12px;
+ font-style: normal;
+ font-weight: 500;
+ line-height: 24px;
+}
diff --git a/frontend/src/container/DashboardContainer/DashboardSettings/General/GeneralSettings.styles.scss b/frontend/src/container/DashboardContainer/DashboardSettings/General/GeneralSettings.styles.scss
deleted file mode 100644
index 79af741038..0000000000
--- a/frontend/src/container/DashboardContainer/DashboardSettings/General/GeneralSettings.styles.scss
+++ /dev/null
@@ -1,143 +0,0 @@
-.overview-content {
- display: flex;
- flex-direction: column;
-
- .overview-settings {
- border-radius: 3px;
- border: 1px solid var(--l1-border);
- padding: 16px !important;
-
- .name-icon-input {
- display: flex;
- .dashboard-image-input {
- .ant-select-selector {
- display: flex;
- width: 32px;
- height: 32px;
- padding: 6px;
- justify-content: center;
- align-items: center;
- border-radius: 2px 0px 0px 2px;
- border: 1px solid var(--l1-border);
- background: var(--l3-background);
-
- .ant-select-selection-item {
- display: flex;
- align-items: center;
-
- .list-item-image {
- height: 16px;
- width: 16px;
- }
- }
- }
- }
-
- .dashboard-name-input {
- border-radius: 0px 2px 2px 0px;
- border: 1px solid var(--l1-border);
- background: var(--l3-background);
- }
- }
-
- .dashboard-name {
- color: var(--l2-foreground);
- font-family: Inter;
- font-size: 14px;
- font-style: normal;
- font-weight: 400;
- line-height: 20px; /* 142.857% */
- }
-
- .description-text-area {
- padding: 6px 6px 6px 8px;
- border-radius: 2px;
- border: 1px solid var(--l1-border);
- background: var(--l3-background);
- }
- }
-
- .overview-settings-footer {
- display: flex;
- justify-content: space-between;
- align-items: center;
- width: -webkit-fill-available;
- padding: 12px 16px 12px 0px;
- position: fixed;
- bottom: 0;
- height: 32px;
- border-top: 1px solid var(--l1-border);
- background: var(--l2-background);
-
- .unsaved {
- display: flex;
- align-items: center;
- gap: 8px;
-
- .unsaved-dot {
- width: 6px;
- height: 6px;
- border-radius: 50px;
- background: var(--primary-background);
- box-shadow: 0px 0px 6px 0px
- color-mix(in srgb, var(--primary-background) 40%, transparent);
- }
- .unsaved-changes {
- color: var(--bg-robin-400);
- font-family: Inter;
- font-size: 14px;
- font-style: normal;
- font-weight: 400;
- line-height: 24px; /* 171.429% */
- letter-spacing: -0.07px;
- }
- }
- .footer-action-btns {
- display: flex;
- gap: 8px;
-
- .discard-btn {
- margin: '16px 0';
- color: var(--l1-foreground);
- font-family: Inter;
- font-size: 12px;
- font-style: normal;
- font-weight: 500;
- line-height: 24px;
- }
-
- .save-btn {
- margin: 0px !important;
- color: var(--l1-foreground);
- font-family: Inter;
- font-size: 12px;
- font-style: normal;
- font-weight: 500;
- line-height: 24px;
- }
- }
- }
-}
-
-.dashboard-image-input {
- &.ant-select-dropdown {
- padding: 0px !important;
- }
-
- .ant-select-item {
- padding: 0px;
- align-items: center;
- justify-content: center;
-
- .ant-select-item-option-content {
- display: flex;
- align-items: center;
- justify-content: center;
-
- .list-item-image {
- height: 16px;
- width: 16px;
- }
- }
- }
-}
diff --git a/frontend/src/container/DashboardContainer/DashboardSettings/General/index.tsx b/frontend/src/container/DashboardContainer/DashboardSettings/General/index.tsx
index 43905daf10..8848476a7f 100644
--- a/frontend/src/container/DashboardContainer/DashboardSettings/General/index.tsx
+++ b/frontend/src/container/DashboardContainer/DashboardSettings/General/index.tsx
@@ -1,16 +1,24 @@
import { useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { Col, Input, Select, Space, Typography } from 'antd';
+import { Col, Input, Radio, Select, Space, Typography } from 'antd';
import AddTags from 'container/DashboardContainer/DashboardSettings/General/AddTags';
+import { useDashboardCursorSyncMode } from 'hooks/dashboard/useDashboardCursorSyncMode';
+import { useSyncTooltipFilterMode } from 'hooks/dashboard/useSyncTooltipFilterMode';
import { useUpdateDashboard } from 'hooks/dashboard/useUpdateDashboard';
+import {
+ DashboardCursorSync,
+ SyncTooltipFilterMode,
+} from 'lib/uPlotV2/plugins/TooltipPlugin/types';
import { isEqual } from 'lodash-es';
import { Check, X } from 'lucide-react';
import { useDashboardStore } from 'providers/Dashboard/store/useDashboardStore';
+import styles from './GeneralSettings.module.scss';
import { Button } from './styles';
import { Base64Icons } from './utils';
-
-import './GeneralSettings.styles.scss';
+import logEvent from 'api/common/logEvent';
+import { Events } from 'constants/events';
+import { getAbsoluteUrl } from 'utils/basePath';
const { Option } = Select;
@@ -19,6 +27,13 @@ function GeneralDashboardSettings(): JSX.Element {
const updateDashboardMutation = useUpdateDashboard();
+ const [cursorSyncMode, setCursorSyncMode] = useDashboardCursorSyncMode(
+ dashboardData?.id,
+ );
+
+ const [syncTooltipFilterMode, setSyncTooltipFilterMode] =
+ useSyncTooltipFilterMode(dashboardData?.id);
+
const selectedData = dashboardData?.data;
const {
@@ -100,8 +115,8 @@ function GeneralDashboardSettings(): JSX.Element {
};
return (
- <div className="overview-content">
- <Col className="overview-settings">
+ <div className={styles.overviewContent}>
+ <Col className={styles.overviewSettings}>
<Space
direction="vertical"
style={{
@@ -112,27 +127,29 @@ function GeneralDashboardSettings(): JSX.Element {
}}
>
<div>
- <Typography style={{ marginBottom: '0.5rem' }} className="dashboard-name">
- Dashboard Name
- </Typography>
- <section className="name-icon-input">
+ <Typography className={styles.dashboardName}>Dashboard Name</Typography>
+ <section className={styles.nameIconInput}>
<Select
defaultActiveFirstOption
data-testid="dashboard-image"
suffixIcon={null}
- rootClassName="dashboard-image-input"
+ rootClassName={styles.dashboardImageInput}
value={updatedImage}
onChange={(value: string): void => setUpdatedImage(value)}
>
{Base64Icons.map((icon) => (
<Option value={icon} key={icon}>
- <img src={icon} alt="dashboard-icon" className="list-item-image" />
+ <img
+ src={icon}
+ alt="dashboard-icon"
+ className={styles.listItemImage}
+ />
</Option>
))}
</Select>
<Input
data-testid="dashboard-name"
- className="dashboard-name-input"
+ className={styles.dashboardNameInput}
value={updatedTitle}
onChange={(e): void => setUpdatedTitle(e.target.value)}
/>
@@ -140,41 +157,92 @@ function GeneralDashboardSettings(): JSX.Element {
</div>
<div>
- <Typography style={{ marginBottom: '0.5rem' }} className="dashboard-name">
- Description
- </Typography>
+ <Typography className={styles.dashboardName}>Description</Typography>
<Input.TextArea
data-testid="dashboard-desc"
rows={6}
value={updatedDescription}
- className="description-text-area"
+ className={styles.descriptionTextArea}
onChange={(e): void => setUpdatedDescription(e.target.value)}
/>
</div>
<div>
- <Typography style={{ marginBottom: '0.5rem' }} className="dashboard-name">
- Tags
- </Typography>
+ <Typography className={styles.dashboardName}>Tags</Typography>
<AddTags tags={updatedTags} setTags={setUpdatedTags} />
</div>
</Space>
</Col>
+ <Col className={`${styles.overviewSettings} ${styles.crossPanelSyncGroup}`}>
+ <Typography.Text className={styles.crossPanelSyncSectionTitle}>
+ Cross-Panel Sync
+ </Typography.Text>
+ <div className={styles.crossPanelSyncRow}>
+ <div className={styles.crossPanelSyncInfo}>
+ <Typography.Text className={styles.crossPanelSyncTitle}>
+ Sync Mode
+ </Typography.Text>
+ <Typography.Text className={styles.crossPanelSyncDescription}>
+ Sync crosshair and tooltip across all the dashboard panels
+ </Typography.Text>
+ </div>
+ <Radio.Group
+ value={cursorSyncMode}
+ onChange={(e): void => {
+ setCursorSyncMode(e.target.value as DashboardCursorSync);
+ }}
+ >
+ <Radio.Button value={DashboardCursorSync.None}>No Sync</Radio.Button>
+ <Radio.Button value={DashboardCursorSync.Crosshair}>
+ Crosshair
+ </Radio.Button>
+ <Radio.Button value={DashboardCursorSync.Tooltip}>Tooltip</Radio.Button>
+ </Radio.Group>
+ </div>
+ {cursorSyncMode === DashboardCursorSync.Tooltip && (
+ <div className={styles.crossPanelSyncRow}>
+ <div className={styles.crossPanelSyncInfo}>
+ <Typography.Text className={styles.crossPanelSyncTitle}>
+ Synced Tooltip Series
+ </Typography.Text>
+ <Typography.Text className={styles.crossPanelSyncDescription}>
+ Show only series that intersect on group-by, or every series with the
+ matching ones highlighted
+ </Typography.Text>
+ </div>
+ <Radio.Group
+ value={syncTooltipFilterMode}
+ onChange={(e): void => {
+ logEvent(Events.TOOLTIP_SYNC_MODE_CHANGED, {
+ path: getAbsoluteUrl(window.location.pathname),
+ mode: e.target.value,
+ });
+ setSyncTooltipFilterMode(e.target.value as SyncTooltipFilterMode);
+ }}
+ >
+ <Radio.Button value={SyncTooltipFilterMode.All}>All</Radio.Button>
+ <Radio.Button value={SyncTooltipFilterMode.Filtered}>
+ Filtered
+ </Radio.Button>
+ </Radio.Group>
+ </div>
+ )}
+ </Col>
{numberOfUnsavedChanges > 0 && (
- <div className="overview-settings-footer">
- <div className="unsaved">
- <div className="unsaved-dot" />
- <Typography.Text className="unsaved-changes">
+ <div className={styles.overviewSettingsFooter}>
+ <div className={styles.unsaved}>
+ <div className={styles.unsavedDot} />
+ <Typography.Text className={styles.unsavedChanges}>
{numberOfUnsavedChanges} unsaved change
{numberOfUnsavedChanges > 1 && 's'}
</Typography.Text>
</div>
- <div className="footer-action-btns">
+ <div className={styles.footerActionBtns}>
<Button
disabled={updateDashboardMutation.isLoading}
icon={<X size={14} />}
onClick={discardHandler}
type="text"
- className="discard-btn"
+ className={styles.discardBtn}
>
Discard
</Button>
@@ -188,7 +256,7 @@ function GeneralDashboardSettings(): JSX.Element {
data-testid="save-dashboard-config"
onClick={onSaveHandler}
type="primary"
- className="save-btn"
+ className={styles.saveBtn}
>
{t('save')}
</Button>
diff --git a/frontend/src/container/DashboardContainer/visualization/charts/ChartWrapper/ChartWrapper.tsx b/frontend/src/container/DashboardContainer/visualization/charts/ChartWrapper/ChartWrapper.tsx
index d255010889..f62710e73d 100644
--- a/frontend/src/container/DashboardContainer/visualization/charts/ChartWrapper/ChartWrapper.tsx
+++ b/frontend/src/container/DashboardContainer/visualization/charts/ChartWrapper/ChartWrapper.tsx
@@ -29,6 +29,7 @@ export default function ChartWrapper({
onClick,
syncMode,
syncKey,
+ syncFilterMode,
onDestroy = noop,
children,
layoutChildren,
@@ -70,8 +71,9 @@ export default function ChartWrapper({
() => ({
yAxisUnit,
groupByPerQuery,
+ filterMode: syncFilterMode,
}),
- [yAxisUnit, groupByPerQuery],
+ [yAxisUnit, groupByPerQuery, syncFilterMode],
);
return (
diff --git a/frontend/src/container/DashboardContainer/visualization/charts/types.ts b/frontend/src/container/DashboardContainer/visualization/charts/types.ts
index 839835c98f..73ceb93934 100644
--- a/frontend/src/container/DashboardContainer/visualization/charts/types.ts
+++ b/frontend/src/container/DashboardContainer/visualization/charts/types.ts
@@ -8,6 +8,7 @@ import {
import { UPlotConfigBuilder } from 'lib/uPlotV2/config/UPlotConfigBuilder';
import {
DashboardCursorSync,
+ SyncTooltipFilterMode,
TooltipClickData,
} from 'lib/uPlotV2/plugins/TooltipPlugin/types';
import { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
@@ -35,6 +36,7 @@ interface UPlotBasedChartProps {
legendConfig: LegendConfig;
syncMode?: DashboardCursorSync;
syncKey?: string;
+ syncFilterMode?: SyncTooltipFilterMode;
plotRef?: (plot: uPlot | null) => void;
onDestroy?: (plot: uPlot) => void;
children?: React.ReactNode;
diff --git a/frontend/src/container/DashboardContainer/visualization/panels/BarPanel/BarPanel.tsx b/frontend/src/container/DashboardContainer/visualization/panels/BarPanel/BarPanel.tsx
index 596954b161..09c4481116 100644
--- a/frontend/src/container/DashboardContainer/visualization/panels/BarPanel/BarPanel.tsx
+++ b/frontend/src/container/DashboardContainer/visualization/panels/BarPanel/BarPanel.tsx
@@ -1,5 +1,7 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { PanelWrapperProps } from 'container/PanelWrapper/panelWrapper.types';
+import { useDashboardCursorSyncMode } from 'hooks/dashboard/useDashboardCursorSyncMode';
+import { useSyncTooltipFilterMode } from 'hooks/dashboard/useSyncTooltipFilterMode';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { useResizeObserver } from 'hooks/useDimensions';
import {
@@ -7,6 +9,7 @@ import {
LegendPosition,
} from 'lib/uPlotV2/components/types';
import ContextMenu from 'periscope/components/ContextMenu';
+import { useDashboardStore } from 'providers/Dashboard/store/useDashboardStore';
import { useTimezone } from 'providers/Timezone';
import uPlot from 'uplot';
import { getTimeRange } from 'utils/getTimeRange';
@@ -38,6 +41,10 @@ function BarPanel(props: PanelWrapperProps): JSX.Element {
const isDarkMode = useIsDarkMode();
const { timezone } = useTimezone();
+ const dashboardId = useDashboardStore((s) => s.dashboardData?.id);
+ const [syncMode] = useDashboardCursorSyncMode(dashboardId, panelMode);
+ const [syncFilterMode] = useSyncTooltipFilterMode(dashboardId);
+
useEffect((): void => {
const { startTime, endTime } = getTimeRange(queryResponse);
@@ -79,6 +86,11 @@ function BarPanel(props: PanelWrapperProps): JSX.Element {
maxTimeScale,
timezone,
panelMode,
+ // `config` gets mutated by TooltipPlugin (config.setCursor for cursor sync).
+ // Rebuild it on syncMode changes so the new chart instance starts from a
+ // clean config — otherwise switching to "No Sync" would inherit stale sync
+ // settings from the previous mode.
+ syncMode,
]);
const chartData = useMemo(() => {
@@ -131,6 +143,7 @@ function BarPanel(props: PanelWrapperProps): JSX.Element {
<div className="panel-container" ref={graphRef}>
{containerDimensions.width > 0 && containerDimensions.height > 0 && (
<BarChart
+ key={`${syncMode}-${syncFilterMode}`}
config={config}
legendConfig={{
position: widget?.legendPosition ?? LegendPosition.BOTTOM,
@@ -147,6 +160,8 @@ function BarPanel(props: PanelWrapperProps): JSX.Element {
yAxisUnit={widget.yAxisUnit}
decimalPrecision={widget.decimalPrecision}
timezone={timezone}
+ syncMode={syncMode}
+ syncFilterMode={syncFilterMode}
renderTooltipFooter={renderTooltipFooter}
>
<ContextMenu
diff --git a/frontend/src/container/DashboardContainer/visualization/panels/TimeSeriesPanel/TimeSeriesPanel.tsx b/frontend/src/container/DashboardContainer/visualization/panels/TimeSeriesPanel/TimeSeriesPanel.tsx
index b3f9de12e6..6d6935de9b 100644
--- a/frontend/src/container/DashboardContainer/visualization/panels/TimeSeriesPanel/TimeSeriesPanel.tsx
+++ b/frontend/src/container/DashboardContainer/visualization/panels/TimeSeriesPanel/TimeSeriesPanel.tsx
@@ -3,6 +3,8 @@ import TimeSeries from 'container/DashboardContainer/visualization/charts/TimeSe
import ChartManager from 'container/DashboardContainer/visualization/components/ChartManager/ChartManager';
import { usePanelContextMenu } from 'container/DashboardContainer/visualization/hooks/usePanelContextMenu';
import { PanelWrapperProps } from 'container/PanelWrapper/panelWrapper.types';
+import { useDashboardCursorSyncMode } from 'hooks/dashboard/useDashboardCursorSyncMode';
+import { useSyncTooltipFilterMode } from 'hooks/dashboard/useSyncTooltipFilterMode';
import { useIsDarkMode } from 'hooks/useDarkMode';
import { useResizeObserver } from 'hooks/useDimensions';
import {
@@ -10,6 +12,7 @@ import {
LegendPosition,
} from 'lib/uPlotV2/components/types';
import { ContextMenu } from 'periscope/components/ContextMenu';
+import { useDashboardStore } from 'providers/Dashboard/store/useDashboardStore';
import { useTimezone } from 'providers/Timezone';
import uPlot from 'uplot';
import { getTimeRange } from 'utils/getTimeRange';
@@ -37,6 +40,10 @@ function TimeSeriesPanel(props: PanelWrapperProps): JSX.Element {
const isDarkMode = useIsDarkMode();
const { timezone } = useTimezone();
+ const dashboardId = useDashboardStore((s) => s.dashboardData?.id);
+ const [syncMode] = useDashboardCursorSyncMode(dashboardId, panelMode);
+ const [syncFilterMode] = useSyncTooltipFilterMode(dashboardId);
+
useEffect((): void => {
const { startTime, endTime } = getTimeRange(queryResponse);
@@ -85,6 +92,11 @@ function TimeSeriesPanel(props: PanelWrapperProps): JSX.Element {
minTimeScale,
maxTimeScale,
timezone,
+ // `config` gets mutated by TooltipPlugin (config.setCursor for cursor sync).
+ // Rebuild it on syncMode changes so the new chart instance starts from a
+ // clean config — otherwise switching to "No Sync" would inherit stale sync
+ // settings from the previous mode.
+ syncMode,
]);
const layoutChildren = useMemo(() => {
@@ -122,6 +134,7 @@ function TimeSeriesPanel(props: PanelWrapperProps): JSX.Element {
<div className="panel-container" ref={graphRef}>
{containerDimensions.width > 0 && containerDimensions.height > 0 && (
<TimeSeries
+ key={`${syncMode}-${syncFilterMode}`}
config={config}
legendConfig={{
position: widget?.legendPosition ?? LegendPosition.BOTTOM,
@@ -134,6 +147,8 @@ function TimeSeriesPanel(props: PanelWrapperProps): JSX.Element {
groupByPerQuery={groupByPerQuery}
width={containerDimensions.width}
height={containerDimensions.height}
+ syncMode={syncMode}
+ syncFilterMode={syncFilterMode}
layoutChildren={layoutChildren}
renderTooltipFooter={renderTooltipFooter}
>
diff --git a/frontend/src/hooks/dashboard/__test__/useDashboardCursorSyncMode.test.ts b/frontend/src/hooks/dashboard/__test__/useDashboardCursorSyncMode.test.ts
new file mode 100644
index 0000000000..acbbc29178
--- /dev/null
+++ b/frontend/src/hooks/dashboard/__test__/useDashboardCursorSyncMode.test.ts
@@ -0,0 +1,150 @@
+import { act, renderHook } from '@testing-library/react';
+import { LOCALSTORAGE } from 'constants/localStorage';
+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
+import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+import { useDashboardCursorSyncMode } from '../useDashboardCursorSyncMode';
+import { useDashboardPreferencesStore } from '../useDashboardPreference';
+
+const STORAGE_KEY = LOCALSTORAGE.DASHBOARD_PREFERENCES;
+
+describe('useDashboardCursorSyncMode', () => {
+ beforeEach(() => {
+ useDashboardPreferencesStore.setState({ preferences: {} });
+ localStorage.removeItem(STORAGE_KEY);
+ });
+
+ describe('in DASHBOARD_VIEW mode', () => {
+ it('uses Crosshair as the default cursor sync mode', () => {
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode('dash-1', PanelMode.DASHBOARD_VIEW),
+ );
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Crosshair);
+ });
+
+ it('reads the stored cursor sync mode for the dashboard', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: { 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip } },
+ });
+
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode('dash-1', PanelMode.DASHBOARD_VIEW),
+ );
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Tooltip);
+ });
+
+ it('writes the value under the cursorSyncMode key in the store', () => {
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode('dash-1', PanelMode.DASHBOARD_VIEW),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.None);
+ });
+
+ expect(result.current[0]).toBe(DashboardCursorSync.None);
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.None },
+ });
+ });
+
+ it('persists the value to localStorage', () => {
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode('dash-1', PanelMode.DASHBOARD_VIEW),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.None);
+ });
+
+ const persisted = JSON.parse(localStorage.getItem(STORAGE_KEY) ?? '{}');
+ expect(persisted.state.preferences).toStrictEqual({
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.None },
+ });
+ });
+
+ it('returns the default when dashboardId is undefined', () => {
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode(undefined, PanelMode.DASHBOARD_VIEW),
+ );
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Crosshair);
+ });
+
+ it('treats the setter as a no-op when dashboardId is undefined', () => {
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode(undefined, PanelMode.DASHBOARD_VIEW),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.Tooltip);
+ });
+
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual(
+ {},
+ );
+ expect(localStorage.getItem(STORAGE_KEY)).toBeNull();
+ expect(result.current[0]).toBe(DashboardCursorSync.Crosshair);
+ });
+ });
+
+ describe('without a panelMode (e.g. dashboard settings call site)', () => {
+ it('reads the stored value just like DASHBOARD_VIEW does', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: { 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip } },
+ });
+
+ const { result } = renderHook(() => useDashboardCursorSyncMode('dash-1'));
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Tooltip);
+ });
+
+ it('writes through the setter to the store', () => {
+ const { result } = renderHook(() => useDashboardCursorSyncMode('dash-1'));
+
+ act(() => {
+ result.current[1](DashboardCursorSync.None);
+ });
+
+ expect(result.current[0]).toBe(DashboardCursorSync.None);
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.None },
+ });
+ });
+ });
+
+ describe.each([[PanelMode.DASHBOARD_EDIT], [PanelMode.STANDALONE_VIEW]])(
+ 'in %s mode (cursor sync disabled)',
+ (panelMode) => {
+ it('returns the Crosshair default and ignores any stored value', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: { 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip } },
+ });
+
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode('dash-1', panelMode),
+ );
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Crosshair);
+ });
+
+ it('treats the setter as a no-op and does not write to the store', () => {
+ const { result } = renderHook(() =>
+ useDashboardCursorSyncMode('dash-1', panelMode),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.None);
+ });
+
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual(
+ {},
+ );
+ expect(localStorage.getItem(STORAGE_KEY)).toBeNull();
+ expect(result.current[0]).toBe(DashboardCursorSync.Crosshair);
+ });
+ },
+ );
+});
diff --git a/frontend/src/hooks/dashboard/__test__/useDashboardPreference.test.ts b/frontend/src/hooks/dashboard/__test__/useDashboardPreference.test.ts
new file mode 100644
index 0000000000..763c2a7317
--- /dev/null
+++ b/frontend/src/hooks/dashboard/__test__/useDashboardPreference.test.ts
@@ -0,0 +1,201 @@
+import { act, renderHook } from '@testing-library/react';
+import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+import {
+ useDashboardPreference,
+ useDashboardPreferencesStore,
+} from '../useDashboardPreference';
+
+const DEFAULT_MODE = DashboardCursorSync.Crosshair;
+
+describe('useDashboardPreference', () => {
+ beforeEach(() => {
+ useDashboardPreferencesStore.setState({ preferences: {} });
+ });
+
+ it('returns the default value when no preference is stored', () => {
+ const { result } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ expect(result.current[0]).toBe(DEFAULT_MODE);
+ });
+
+ it('returns the default value when dashboardId is undefined', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: { 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip } },
+ });
+
+ const { result } = renderHook(() =>
+ useDashboardPreference(undefined, 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ expect(result.current[0]).toBe(DEFAULT_MODE);
+ });
+
+ it('returns the stored value for the given dashboardId', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: {
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip },
+ 'dash-2': { cursorSyncMode: DashboardCursorSync.None },
+ },
+ });
+
+ const { result } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Tooltip);
+ });
+
+ it('persists the new value via the setter', () => {
+ const { result } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.None);
+ });
+
+ expect(result.current[0]).toBe(DashboardCursorSync.None);
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.None },
+ });
+ });
+
+ it('does not write when dashboardId is undefined', () => {
+ const { result } = renderHook(() =>
+ useDashboardPreference(undefined, 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.Tooltip);
+ });
+
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({});
+ expect(result.current[0]).toBe(DEFAULT_MODE);
+ });
+
+ it('keeps multiple hook instances in sync after a write', () => {
+ const { result: writer } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+ const { result: reader } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ act(() => {
+ writer.current[1](DashboardCursorSync.Tooltip);
+ });
+
+ expect(writer.current[0]).toBe(DashboardCursorSync.Tooltip);
+ expect(reader.current[0]).toBe(DashboardCursorSync.Tooltip);
+ });
+
+ it('isolates preferences across different dashboardIds', () => {
+ const { result: dashOne } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+ const { result: dashTwo } = renderHook(() =>
+ useDashboardPreference('dash-2', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ act(() => {
+ dashOne.current[1](DashboardCursorSync.None);
+ });
+
+ expect(dashOne.current[0]).toBe(DashboardCursorSync.None);
+ expect(dashTwo.current[0]).toBe(DEFAULT_MODE);
+ });
+
+ it('does not overwrite preferences for other dashboards when writing', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: { 'dash-2': { cursorSyncMode: DashboardCursorSync.Tooltip } },
+ });
+
+ const { result } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ act(() => {
+ result.current[1](DashboardCursorSync.None);
+ });
+
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.None },
+ 'dash-2': { cursorSyncMode: DashboardCursorSync.Tooltip },
+ });
+ });
+});
+
+describe('useDashboardPreferencesStore.removePreferences', () => {
+ beforeEach(() => {
+ useDashboardPreferencesStore.setState({ preferences: {} });
+ });
+
+ it('removes the preferences for the given dashboardId', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: {
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip },
+ },
+ });
+
+ act(() => {
+ useDashboardPreferencesStore.getState().removePreferences('dash-1');
+ });
+
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({});
+ });
+
+ it('leaves other dashboards untouched', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: {
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip },
+ 'dash-2': { cursorSyncMode: DashboardCursorSync.None },
+ },
+ });
+
+ act(() => {
+ useDashboardPreferencesStore.getState().removePreferences('dash-1');
+ });
+
+ expect(useDashboardPreferencesStore.getState().preferences).toStrictEqual({
+ 'dash-2': { cursorSyncMode: DashboardCursorSync.None },
+ });
+ });
+
+ it('is a no-op when the dashboardId is not present', () => {
+ const initial = {
+ 'dash-2': { cursorSyncMode: DashboardCursorSync.Tooltip },
+ };
+ useDashboardPreferencesStore.setState({ preferences: initial });
+ const before = useDashboardPreferencesStore.getState().preferences;
+
+ act(() => {
+ useDashboardPreferencesStore.getState().removePreferences('dash-1');
+ });
+
+ // Identity-preserving so subscribers reading `preferences` don't re-render.
+ expect(useDashboardPreferencesStore.getState().preferences).toBe(before);
+ });
+
+ it('causes subsequent reads via useDashboardPreference to fall back to the default', () => {
+ useDashboardPreferencesStore.setState({
+ preferences: {
+ 'dash-1': { cursorSyncMode: DashboardCursorSync.Tooltip },
+ },
+ });
+
+ const { result } = renderHook(() =>
+ useDashboardPreference('dash-1', 'cursorSyncMode', DEFAULT_MODE),
+ );
+
+ expect(result.current[0]).toBe(DashboardCursorSync.Tooltip);
+
+ act(() => {
+ useDashboardPreferencesStore.getState().removePreferences('dash-1');
+ });
+
+ expect(result.current[0]).toBe(DEFAULT_MODE);
+ });
+});
diff --git a/frontend/src/hooks/dashboard/useDashboardCursorSyncMode.ts b/frontend/src/hooks/dashboard/useDashboardCursorSyncMode.ts
new file mode 100644
index 0000000000..9cbb664a84
--- /dev/null
+++ b/frontend/src/hooks/dashboard/useDashboardCursorSyncMode.ts
@@ -0,0 +1,28 @@
+import { DashboardCursorSync } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+import { useDashboardPreference } from './useDashboardPreference';
+import { PanelMode } from 'container/DashboardContainer/visualization/panels/types';
+
+const DEFAULT_CURSOR_SYNC_MODE = DashboardCursorSync.Crosshair;
+
+const NOOP = (): void => {};
+
+export function useDashboardCursorSyncMode(
+ dashboardId: string | undefined,
+ panelMode?: PanelMode,
+): [DashboardCursorSync, (value: DashboardCursorSync) => void] {
+ const [value, setValue] = useDashboardPreference(
+ dashboardId,
+ 'cursorSyncMode',
+ DEFAULT_CURSOR_SYNC_MODE,
+ );
+
+ // Chart panels in edit / standalone modes don't participate in cross-panel
+ // sync, so surface the default with a no-op setter for them. Callers without
+ // a panelMode (e.g. dashboard settings) read/write the preference normally.
+ if (panelMode && panelMode !== PanelMode.DASHBOARD_VIEW) {
+ return [DEFAULT_CURSOR_SYNC_MODE, NOOP];
+ }
+
+ return [value, setValue];
+}
diff --git a/frontend/src/hooks/dashboard/useDashboardPreference.ts b/frontend/src/hooks/dashboard/useDashboardPreference.ts
new file mode 100644
index 0000000000..b1bbde9504
--- /dev/null
+++ b/frontend/src/hooks/dashboard/useDashboardPreference.ts
@@ -0,0 +1,88 @@
+import { useCallback } from 'react';
+import { create } from 'zustand';
+import { persist } from 'zustand/middleware';
+import { LOCALSTORAGE } from 'constants/localStorage';
+import {
+ DashboardCursorSync,
+ SyncTooltipFilterMode,
+} from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+// Per-dashboard preferences persisted in localStorage. Add new preference
+// fields here as they are introduced.
+export type DashboardPreferences = {
+ cursorSyncMode?: DashboardCursorSync;
+ syncTooltipFilterMode?: SyncTooltipFilterMode;
+};
+
+interface DashboardPreferencesState {
+ preferences: Record<string, DashboardPreferences>;
+ setPreference: <K extends keyof DashboardPreferences>(
+ dashboardId: string,
+ key: K,
+ value: NonNullable<DashboardPreferences[K]>,
+ ) => void;
+ removePreferences: (dashboardId: string) => void;
+}
+
+export const useDashboardPreferencesStore = create<DashboardPreferencesState>()(
+ persist(
+ (set) => ({
+ preferences: {},
+ setPreference: (dashboardId, key, value): void => {
+ set((state) => ({
+ preferences: {
+ ...state.preferences,
+ [dashboardId]: {
+ ...state.preferences[dashboardId],
+ [key]: value,
+ },
+ },
+ }));
+ },
+ removePreferences: (dashboardId): void => {
+ set((state) => {
+ if (!(dashboardId in state.preferences)) {
+ return state;
+ }
+ const { [dashboardId]: _, ...rest } = state.preferences;
+ return { preferences: rest };
+ });
+ },
+ }),
+ { name: LOCALSTORAGE.DASHBOARD_PREFERENCES },
+ ),
+);
+
+export function useDashboardPreference<K extends keyof DashboardPreferences>(
+ dashboardId: string | undefined,
+ key: K,
+ defaultValue: NonNullable<DashboardPreferences[K]>,
+): [
+ NonNullable<DashboardPreferences[K]>,
+ (value: NonNullable<DashboardPreferences[K]>) => void,
+] {
+ type Value = NonNullable<DashboardPreferences[K]>;
+
+ const value = useDashboardPreferencesStore((state): Value => {
+ if (!dashboardId) {
+ return defaultValue;
+ }
+ return (
+ (state.preferences[dashboardId]?.[key] as Value | undefined) ?? defaultValue
+ );
+ });
+
+ const setPreference = useDashboardPreferencesStore((s) => s.setPreference);
+
+ const updateValue = useCallback(
+ (next: Value): void => {
+ if (!dashboardId) {
+ return;
+ }
+ setPreference(dashboardId, key, next);
+ },
+ [dashboardId, key, setPreference],
+ );
+
+ return [value, updateValue];
+}
diff --git a/frontend/src/hooks/dashboard/useDeleteDashboard.tsx b/frontend/src/hooks/dashboard/useDeleteDashboard.tsx
index 5cac82e228..a0abd55129 100644
--- a/frontend/src/hooks/dashboard/useDeleteDashboard.tsx
+++ b/frontend/src/hooks/dashboard/useDeleteDashboard.tsx
@@ -5,10 +5,15 @@ import { useErrorModal } from 'providers/ErrorModalProvider';
import { SuccessResponseV2 } from 'types/api';
import APIError from 'types/api/error';
+import { useDashboardPreferencesStore } from './useDashboardPreference';
+
export const useDeleteDashboard = (
id: string,
): UseMutationResult<SuccessResponseV2<null>, APIError, void, unknown> => {
const { showErrorModal } = useErrorModal();
+ const removePreferences = useDashboardPreferencesStore(
+ (state) => state.removePreferences,
+ );
return useMutation<SuccessResponseV2<null>, APIError>({
mutationKey: REACT_QUERY_KEY.DELETE_DASHBOARD,
@@ -16,6 +21,9 @@ export const useDeleteDashboard = (
deleteDashboard({
id,
}),
+ onSuccess: () => {
+ removePreferences(id);
+ },
onError: (error: APIError) => {
showErrorModal(error);
},
diff --git a/frontend/src/hooks/dashboard/useSyncTooltipFilterMode.ts b/frontend/src/hooks/dashboard/useSyncTooltipFilterMode.ts
new file mode 100644
index 0000000000..6693b87a58
--- /dev/null
+++ b/frontend/src/hooks/dashboard/useSyncTooltipFilterMode.ts
@@ -0,0 +1,15 @@
+import { SyncTooltipFilterMode } from 'lib/uPlotV2/plugins/TooltipPlugin/types';
+
+import { useDashboardPreference } from './useDashboardPreference';
+
+const DEFAULT_SYNC_TOOLTIP_FILTER_MODE = SyncTooltipFilterMode.Filtered;
+
+export function useSyncTooltipFilterMode(
+ dashboardId: string | undefined,
+): [SyncTooltipFilterMode, (value: SyncTooltipFilterMode) => void] {
+ return useDashboardPreference(
+ dashboardId,
+ 'syncTooltipFilterMode',
+ DEFAULT_SYNC_TOOLTIP_FILTER_MODE,
+ );
+}
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/BarChartTooltip.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/BarChartTooltip.tsx
index f883281051..cd4c853789 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/BarChartTooltip.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/BarChartTooltip.tsx
@@ -17,6 +17,7 @@ export default function BarChartTooltip(props: BarTooltipProps): JSX.Element {
decimalPrecision: props.decimalPrecision,
isStackedBarChart: props.isStackedBarChart,
syncedSeriesIndexes: props.syncedSeriesIndexes,
+ syncFilterMode: props.syncFilterMode,
}),
[
props.uPlotInstance,
@@ -26,6 +27,7 @@ export default function BarChartTooltip(props: BarTooltipProps): JSX.Element {
props.decimalPrecision,
props.isStackedBarChart,
props.syncedSeriesIndexes,
+ props.syncFilterMode,
],
);
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/HistogramTooltip.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/HistogramTooltip.tsx
index 7b0d706df8..8cac18615b 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/HistogramTooltip.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/HistogramTooltip.tsx
@@ -18,6 +18,7 @@ export default function HistogramTooltip(
yAxisUnit: props.yAxisUnit ?? '',
decimalPrecision: props.decimalPrecision,
syncedSeriesIndexes: props.syncedSeriesIndexes,
+ syncFilterMode: props.syncFilterMode,
}),
[
props.uPlotInstance,
@@ -26,6 +27,7 @@ export default function HistogramTooltip(
props.yAxisUnit,
props.decimalPrecision,
props.syncedSeriesIndexes,
+ props.syncFilterMode,
],
);
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/TimeSeriesTooltip.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/TimeSeriesTooltip.tsx
index d5a404da2f..ff5ce289c6 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/TimeSeriesTooltip.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/TimeSeriesTooltip.tsx
@@ -18,6 +18,7 @@ export default function TimeSeriesTooltip(
yAxisUnit: props.yAxisUnit ?? '',
decimalPrecision: props.decimalPrecision,
syncedSeriesIndexes: props.syncedSeriesIndexes,
+ syncFilterMode: props.syncFilterMode,
}),
[
props.uPlotInstance,
@@ -26,6 +27,7 @@ export default function TimeSeriesTooltip(
props.yAxisUnit,
props.decimalPrecision,
props.syncedSeriesIndexes,
+ props.syncFilterMode,
],
);
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx
index 3d136b6f89..8a2fc40def 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/components/TooltipList/TooltipList.tsx
@@ -58,7 +58,7 @@ export default function TooltipList({
style={{ height }}
totalListHeightChanged={setTotalListHeight}
itemContent={(_, item): JSX.Element => (
- <TooltipItem item={item} isItemActive={false} />
+ <TooltipItem item={item} isItemActive={item.isHighlighted === true} />
)}
/>
</div>
diff --git a/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts b/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts
index 0c8f66477d..b270ec7f98 100644
--- a/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts
+++ b/frontend/src/lib/uPlotV2/components/Tooltip/utils.ts
@@ -2,6 +2,7 @@ import { PrecisionOption } from 'components/Graph/types';
import { getToolTipValue } from 'components/Graph/yAxisConfig';
import uPlot, { AlignedData, Series } from 'uplot';
+import { SyncTooltipFilterMode } from '../../plugins/TooltipPlugin/types';
import { TooltipContentItem } from '../types';
export const FALLBACK_SERIES_COLOR = '#000000';
@@ -63,6 +64,7 @@ export function buildTooltipContent({
decimalPrecision,
isStackedBarChart,
syncedSeriesIndexes,
+ syncFilterMode,
}: {
data: AlignedData;
series: Series[];
@@ -73,10 +75,16 @@ export function buildTooltipContent({
decimalPrecision?: PrecisionOption;
isStackedBarChart?: boolean;
syncedSeriesIndexes?: number[] | null;
+ syncFilterMode?: SyncTooltipFilterMode;
}): TooltipContentItem[] {
const items: TooltipContentItem[] = [];
- const allowedIndexes =
+ const matchedIndexes =
syncedSeriesIndexes != null ? new Set(syncedSeriesIndexes) : null;
+ const filterMode = syncFilterMode ?? SyncTooltipFilterMode.Filtered;
+ // In Filtered mode the matched indexes act as a whitelist; in All mode every
+ // series renders and matched indexes only drive row highlighting.
+ const allowedIndexes =
+ filterMode === SyncTooltipFilterMode.All ? null : matchedIndexes;
for (let seriesIndex = 1; seriesIndex < series.length; seriesIndex += 1) {
const seriesItem = series[seriesIndex];
@@ -89,6 +97,7 @@ export function buildTooltipContent({
const dataIndex = dataIndexes[seriesIndex];
const isSync = allowedIndexes != null;
+ const isHighlighted = matchedIndexes?.has(seriesIndex) ?? false;
if (dataIndex === null) {
if (isSync) {
@@ -98,6 +107,7 @@ export function buildTooltipContent({
tooltipValue: 'No Data',
color: resolveSeriesColor(seriesItem.stroke, uPlotInstance, seriesIndex),
isActive: false,
+ isHighlighted,
});
}
continue;
@@ -118,6 +128,7 @@ export function buildTooltipContent({
tooltipValue: getToolTipValue(baseValue, yAxisUnit, decimalPrecision),
color: resolveSeriesColor(seriesItem.stroke, uPlotInstance, seriesIndex),
isActive: seriesIndex === activeSeriesIndex,
+ isHighlighted,
});
} else if (isSync) {
items.push({
@@ -126,6 +137,7 @@ export function buildTooltipContent({
tooltipValue: 'No Data',
color: resolveSeriesColor(seriesItem.stroke, uPlotInstance, seriesIndex),
isActive: false,
+ isHighlighted,
});
}
}
diff --git a/frontend/src/lib/uPlotV2/components/types.ts b/frontend/src/lib/uPlotV2/components/types.ts
index 94857165c9..f02d9cda88 100644
--- a/frontend/src/lib/uPlotV2/components/types.ts
+++ b/frontend/src/lib/uPlotV2/components/types.ts
@@ -4,6 +4,7 @@ import { PrecisionOption } from 'components/Graph/types';
import uPlot from 'uplot';
import { UPlotConfigBuilder } from '../config/UPlotConfigBuilder';
+import { SyncTooltipFilterMode } from '../plugins/TooltipPlugin/types';
/**
* Props for the Plot component
@@ -58,9 +59,15 @@ export interface TooltipRenderArgs {
isPinned: boolean;
dismiss: () => void;
viaSync: boolean;
- /** In Tooltip sync mode, limits which series are rendered in the receiver tooltip.
- * null = no filtering; [] = no matches (tooltip hidden upstream); [...] = allowed indexes */
+ /** In Tooltip sync mode, identifies receiver series that match the source's
+ * focused series on the shared groupBy keys.
+ * Filtered mode: limits which series are rendered (null = no filter,
+ * [] = no matches/tooltip hidden upstream, [...] = allowed indexes).
+ * All mode: same indexes are interpreted as a highlight set; non-matching
+ * series still render. */
syncedSeriesIndexes?: number[] | null;
+ /** Receiver-side filter mode for the synced tooltip. Defaults to Filtered. */
+ syncFilterMode?: SyncTooltipFilterMode;
}
export interface IRenderTooltipFooterArgs {
@@ -114,4 +121,9 @@ export interface TooltipContentItem {
tooltipValue: string;
color: string;
isActive: boolean;
+ /** Synced receiver series whose metric matches the source's focused series
+ * on the shared groupBy keys, in 'all' filter mode. List rendering uses this
+ * to apply the active highlight to matching rows while non-matching rows
+ * stay dimmed. */
+ isHighlighted?: boolean;
}
diff --git a/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/TooltipPlugin.tsx b/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/TooltipPlugin.tsx
index d3c00cb65e..50bd9c8ffe 100644
--- a/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/TooltipPlugin.tsx
+++ b/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/TooltipPlugin.tsx
@@ -18,6 +18,7 @@ import {
import {
DashboardCursorSync,
DEFAULT_PIN_TOOLTIP_KEY,
+ SyncTooltipFilterMode,
TooltipControllerContext,
TooltipControllerState,
TooltipLayoutInfo,
@@ -198,10 +199,14 @@ export default function TooltipPlugin({
if (!controller.hoverActive || !plot) {
return null;
}
- // In Tooltip sync mode, suppress the receiver tooltip entirely when
- // no receiver series match the source panel's focused series.
+ const filterMode =
+ syncMetadata?.filterMode ?? SyncTooltipFilterMode.Filtered;
+ // In Filtered Tooltip sync mode, suppress the receiver tooltip entirely
+ // when no receiver series match the source panel's focused series. In
+ // All mode the tooltip still renders with every series visible.
if (
syncTooltipWithDashboard &&
+ filterMode === SyncTooltipFilterMode.Filtered &&
controller.cursorDrivenBySync &&
Array.isArray(controller.syncedSeriesIndexes) &&
controller.syncedSeriesIndexes.length === 0
@@ -216,6 +221,7 @@ export default function TooltipPlugin({
dismiss: dismissTooltip,
viaSync: controller.cursorDrivenBySync,
syncedSeriesIndexes: controller.syncedSeriesIndexes,
+ syncFilterMode: filterMode,
});
}
diff --git a/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/syncDisplayHook.ts b/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/syncDisplayHook.ts
index be0a4a2e93..a6833b1436 100644
--- a/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/syncDisplayHook.ts
+++ b/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/syncDisplayHook.ts
@@ -2,7 +2,11 @@ import uPlot from 'uplot';
import type { ExtendedSeries } from '../../config/types';
import { syncCursorRegistry } from './syncCursorRegistry';
-import type { TooltipControllerState, TooltipSyncMetadata } from './types';
+import {
+ SyncTooltipFilterMode,
+ type TooltipControllerState,
+ type TooltipSyncMetadata,
+} from './types';
/**
* Flattens per-query groupBys into a deduped set of dimension keys.
@@ -99,11 +103,15 @@ function applySourceSync({
}
/**
- * Returns:
- * null – cursor off-chart (no-op for tooltip)
- * [] – either panel has no groupBy, no overlap with the source, or no
- * receiver series match the source (hide synced tooltip)
- * number[] – 1-based indexes of matching receiver series (show only these)
+ * Computes receiver-side series filtering / highlighting for Tooltip sync.
+ *
+ * Returns the indexes that the tooltip render path should treat per
+ * `syncMetadata.filterMode`:
+ * - Filtered (default): null = no filter, [] = no matches (suppress tooltip),
+ * number[] = allowed indexes (show only these).
+ * - All: null = no highlight (show all), number[] = highlight set (show all,
+ * emphasize matching rows). Never returns [] in this mode so the synced
+ * tooltip is not suppressed when matches are missing.
*/
function applyReceiverSync({
uPlotInstance,
@@ -123,6 +131,10 @@ function applyReceiverSync({
yCrosshairEl.style.display =
sourceMetadata?.yAxisUnit === syncMetadata?.yAxisUnit ? '' : 'none';
+ const filterMode = syncMetadata?.filterMode ?? SyncTooltipFilterMode.Filtered;
+ const noMatchResult: number[] | null =
+ filterMode === SyncTooltipFilterMode.All ? null : [];
+
if (commonKeys.length === 0) {
uPlotInstance.setSeries(null, { focus: false });
return [];
@@ -136,7 +148,7 @@ function applyReceiverSync({
const sourceSeriesMetric = syncCursorRegistry.getActiveSeriesMetric(syncKey);
if (sourceSeriesMetric == null) {
uPlotInstance.setSeries(null, { focus: false });
- return [];
+ return noMatchResult;
}
const matchingIdxs = findMatchingSeriesIndexes(
@@ -147,7 +159,7 @@ function applyReceiverSync({
if (matchingIdxs.length === 0) {
uPlotInstance.setSeries(null, { focus: false });
- return [];
+ return noMatchResult;
}
uPlotInstance.setSeries(matchingIdxs[0], { focus: true });
diff --git a/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/types.ts b/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/types.ts
index 068943882c..550d019a8a 100644
--- a/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/types.ts
+++ b/frontend/src/lib/uPlotV2/plugins/TooltipPlugin/types.ts
@@ -16,9 +16,18 @@ export const TOOLTIP_OFFSET = 10;
export const DEFAULT_PIN_TOOLTIP_KEY = 'p';
export enum DashboardCursorSync {
- Crosshair,
- None,
- Tooltip,
+ Crosshair = 'crosshair',
+ None = 'none',
+ Tooltip = 'tooltip',
+}
+
+/**
+ * Controls whether a synced tooltip filters series by groupBy intersection
+ * or shows every series with the matching ones highlighted.
+ */
+export enum SyncTooltipFilterMode {
+ Filtered = 'filtered',
+ All = 'all',
}
export interface TooltipViewState {
@@ -41,6 +50,7 @@ export interface TooltipLayoutInfo {
export interface TooltipSyncMetadata {
yAxisUnit?: string;
groupByPerQuery?: Record<string, BaseAutocompleteData[]>;
+ filterMode?: SyncTooltipFilterMode;
}
export interface TooltipPluginProps {
diff --git a/frontend/src/lib/uPlotV2/plugins/__tests__/syncDisplayHook.test.ts b/frontend/src/lib/uPlotV2/plugins/__tests__/syncDisplayHook.test.ts
new file mode 100644
index 0000000000..75da528616
--- /dev/null
+++ b/frontend/src/lib/uPlotV2/plugins/__tests__/syncDisplayHook.test.ts
@@ -0,0 +1,152 @@
+import type { BaseAutocompleteData } from 'types/api/queryBuilder/queryAutocompleteResponse';
+import type uPlot from 'uplot';
+
+import type { ExtendedSeries } from '../../config/types';
+import { syncCursorRegistry } from '../TooltipPlugin/syncCursorRegistry';
+import { createSyncDisplayHook } from '../TooltipPlugin/syncDisplayHook';
+import type {
+ TooltipControllerState,
+ TooltipSyncMetadata,
+} from '../TooltipPlugin/types';
+
+const SYNC_KEY = 'test-sync';
+
+function makeController(): TooltipControllerState {
+ return {
+ plot: null,
+ hoverActive: false,
+ isAnySeriesActive: false,
+ pinned: false,
+ clickData: null,
+ style: {},
+ horizontalOffset: 0,
+ verticalOffset: 0,
+ seriesIndexes: [],
+ focusedSeriesIndex: null,
+ syncedSeriesIndexes: null,
+ cursorDrivenBySync: false,
+ plotWithinViewport: true,
+ windowWidth: 1024,
+ windowHeight: 768,
+ pendingPinnedUpdate: false,
+ };
+}
+
+function makeFakePlot(
+ series: ExtendedSeries[],
+ cursorEvent: Record<string, unknown> | null = null,
+): uPlot {
+ const root = document.createElement('div');
+ const yCrosshair = document.createElement('div');
+ yCrosshair.className = 'u-cursor-y';
+ root.appendChild(yCrosshair);
+
+ return {
+ root,
+ series,
+ cursor: { event: cursorEvent, left: 50 },
+ setSeries: jest.fn(),
+ } as unknown as uPlot;
+}
+
+const SERVICE_NAME_KEY: BaseAutocompleteData = {
+ key: 'service.name',
+ type: 'tag',
+};
+
+const groupByService: TooltipSyncMetadata = {
+ groupByPerQuery: { queryName: [SERVICE_NAME_KEY] },
+};
+
+function seedSourcePanel(activeMetric: Record<string, string>): void {
+ syncCursorRegistry.setMetadata(SYNC_KEY, groupByService);
+ syncCursorRegistry.setActiveSeriesMetric(SYNC_KEY, activeMetric);
+}
+
+function makeReceiverSeries(
+ entries: { name: string; show?: boolean }[],
+): ExtendedSeries[] {
+ return [
+ {} as ExtendedSeries,
+ ...entries.map(
+ (e) =>
+ ({
+ show: e.show ?? true,
+ metric: { 'service.name': e.name },
+ }) as unknown as ExtendedSeries,
+ ),
+ ];
+}
+
+describe('createSyncDisplayHook (receiver-side filtering)', () => {
+ beforeEach(() => {
+ syncCursorRegistry.setMetadata(SYNC_KEY, undefined);
+ syncCursorRegistry.setActiveSeriesMetric(SYNC_KEY, null);
+ });
+
+ it('returns indexes of visible matching series only', () => {
+ seedSourcePanel({ 'service.name': 'flagd' });
+
+ const series = makeReceiverSeries([
+ { name: 'flagd', show: true },
+ { name: 'frontend', show: true },
+ { name: 'flagd', show: true },
+ ]);
+ const plot = makeFakePlot(series, null);
+ const controller = makeController();
+
+ createSyncDisplayHook(SYNC_KEY, groupByService, controller)(plot);
+
+ expect(controller.syncedSeriesIndexes).toStrictEqual([1, 3]);
+ });
+
+ it('treats all matching series being hidden as no match → empty array', () => {
+ seedSourcePanel({ 'service.name': 'frontendproxy' });
+
+ const series = makeReceiverSeries([
+ { name: 'flagd', show: true },
+ { name: 'frontendproxy', show: false },
+ ]);
+ const plot = makeFakePlot(series, null);
+ const controller = makeController();
+
+ createSyncDisplayHook(SYNC_KEY, groupByService, controller)(plot);
+
+ expect(controller.syncedSeriesIndexes).toStrictEqual([]);
+ expect(plot.setSeries).toHaveBeenCalledWith(null, { focus: false });
+ });
+
+ it('excludes hidden series and keeps the visible matches', () => {
+ seedSourcePanel({ 'service.name': 'flagd' });
+
+ const series = makeReceiverSeries([
+ { name: 'flagd', show: false },
+ { name: 'frontend', show: true },
+ { name: 'flagd', show: true },
+ ]);
+ const plot = makeFakePlot(series, null);
+ const controller = makeController();
+
+ createSyncDisplayHook(SYNC_KEY, groupByService, controller)(plot);
+
+ expect(controller.syncedSeriesIndexes).toStrictEqual([3]);
+ // Focuses the first visible match, not the hidden one at index 1.
+ expect(plot.setSeries).toHaveBeenCalledWith(3, { focus: true });
+ });
+
+ it('returns null (no filtering) when the hook runs on the source panel', () => {
+ const series = makeReceiverSeries([{ name: 'flagd', show: true }]);
+ // cursor.event != null marks this invocation as the source panel.
+ const plot = makeFakePlot(series, { type: 'mousemove' });
+ const controller = makeController();
+ controller.focusedSeriesIndex = 1;
+ (series[1] as ExtendedSeries).metric = { 'service.name': 'flagd' };
+
+ createSyncDisplayHook(SYNC_KEY, groupByService, controller)(plot);
+
+ expect(controller.syncedSeriesIndexes).toBeNull();
+ expect(syncCursorRegistry.getActiveSeriesMetric(SYNC_KEY)).toStrictEqual({
+ 'service.name': 'flagd',
+ });
+ });
+});