Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lens][Visualize] Adds option to disable cursor sync on dashboards #143355

Merged
merged 6 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/user/dashboard/dashboard.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ Apply a set of design options to the entire dashboard.

* *Sync color pallettes across panels* — Applies the same color palette to all panels on the dashboard.

* *Sync cursor across panels* — When you hover your cursor over a *Lens*, *TSVB*, aggregation-based, or *Timelion* XY chart and a heatmap chart, the cursor on all other related dashboard charts automatically appear.

* *Sync tooltips across panels* — When you hover your cursor over a *Lens*, *TSVB*, aggregation-based, or *Timelion* XY chart, the tooltips on all other related dashboard charts automatically appear.

[float]
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pageLoadAssetSize:
expressions: 140958
expressionShape: 34008
expressionTagcloud: 27505
expressionXY: 38000
expressionXY: 38500
features: 21723
fieldFormats: 65209
files: 22673
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ export const heatmapFunction = (): HeatmapExpressionFunctionDefinition => ({
handlers.getExecutionContext?.()?.description,
},
syncTooltips: handlers?.isSyncTooltipsEnabled?.() ?? false,
syncCursor: handlers?.isSyncCursorEnabled?.() ?? true,
},
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export interface HeatmapExpressionProps {
data: Datatable;
args: HeatmapArguments;
syncTooltips: boolean;
syncCursor: boolean;
}

export interface HeatmapRender {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ export type HeatmapRenderProps = HeatmapExpressionProps & {
uiState: PersistedState;
interactive: boolean;
syncTooltips: boolean;
syncCursor: boolean;
renderComplete: IInterpreterRenderHandlers['done'];
};
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ describe('HeatmapComponent', function () {
formatFactory: formatService.deserialize,
interactive: true,
syncTooltips: false,
syncCursor: true,
renderComplete: jest.fn(),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export const HeatmapComponent: FC<HeatmapRenderProps> = memo(
uiState,
interactive,
syncTooltips,
syncCursor,
renderComplete,
}) => {
const chartRef = useRef<Chart>(null);
Expand Down Expand Up @@ -576,7 +577,7 @@ export const HeatmapComponent: FC<HeatmapRenderProps> = memo(
noResults={
<EmptyPlaceholder icon={IconChartHeatmap} renderComplete={onRenderChange} />
}
onPointerUpdate={handleCursorUpdate}
onPointerUpdate={syncCursor ? handleCursorUpdate : undefined}
externalPointerEvents={{
tooltip: { visible: syncTooltips },
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const heatmapRenderer: (
interactive={isInteractive()}
chartsActiveCursorService={plugins.charts.activeCursor}
syncTooltips={config.syncTooltips}
syncCursor={config.syncCursor}
/>
</div>
</KibanaThemeProvider>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('layeredXyVis', () => {
args: { ...rest, layers: [sampleExtendedLayer] },
syncColors: false,
syncTooltips: false,
syncCursor: true,
canNavigateToLens: false,
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export const layeredXyVisFn: LayeredXyVisFn['fn'] = async (data, args, handlers)
canNavigateToLens: Boolean(handlers.variables.canNavigateToLens),
syncColors: handlers?.isSyncColorsEnabled?.() ?? false,
syncTooltips: handlers?.isSyncTooltipsEnabled?.() ?? false,
syncCursor: handlers?.isSyncCursorEnabled?.() ?? true,
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe('xyVis', () => {
canNavigateToLens: false,
syncColors: false,
syncTooltips: false,
syncCursor: true,
},
});
});
Expand Down Expand Up @@ -350,6 +351,7 @@ describe('xyVis', () => {
canNavigateToLens: false,
syncColors: false,
syncTooltips: false,
syncCursor: true,
},
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {
canNavigateToLens: Boolean(handlers.variables.canNavigateToLens),
syncColors: handlers?.isSyncColorsEnabled?.() ?? false,
syncTooltips: handlers?.isSyncTooltipsEnabled?.() ?? false,
syncCursor: handlers?.isSyncCursorEnabled?.() ?? true,
},
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { XYProps } from './expression_functions';
export interface XYChartProps {
args: XYProps;
syncTooltips: boolean;
syncCursor: boolean;
syncColors: boolean;
canNavigateToLens?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe('XYChart component', () => {
onSelectRange,
syncColors: false,
syncTooltips: false,
syncCursor: true,
useLegacyTimeAxis: false,
eventAnnotationService: eventAnnotationServiceMock,
renderComplete: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export type XYChartRenderProps = Omit<XYChartProps, 'canNavigateToLens'> & {
renderMode: RenderMode;
syncColors: boolean;
syncTooltips: boolean;
syncCursor: boolean;
eventAnnotationService: EventAnnotationServiceType;
renderComplete: () => void;
uiState?: PersistedState;
Expand Down Expand Up @@ -199,6 +200,7 @@ export function XYChart({
interactive = true,
syncColors,
syncTooltips,
syncCursor,
useLegacyTimeAxis,
renderComplete,
uiState,
Expand Down Expand Up @@ -753,7 +755,7 @@ export function XYChart({
/>
}
onRenderChange={onRenderChange}
onPointerUpdate={handleCursorUpdate}
onPointerUpdate={syncCursor ? handleCursorUpdate : undefined}
externalPointerEvents={{
tooltip: { visible: syncTooltips, placement: Placement.Right },
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ export const getXyChartRenderer = ({
renderMode={handlers.getRenderMode()}
syncColors={config.syncColors}
syncTooltips={config.syncTooltips}
syncCursor={config.syncCursor}
uiState={handlers.uiState as PersistedState}
renderComplete={renderComplete}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ describe('calculateMinInterval', () => {
beforeEach(() => {
const { layers, ...restArgs } = sampleArgs().args;

xyProps = { args: { ...restArgs, layers }, syncColors: false, syncTooltips: false };
xyProps = {
args: { ...restArgs, layers },
syncColors: false,
syncTooltips: false,
syncCursor: true,
};
layer = xyProps.args.layers[0] as DataLayerConfig;
layer.xScaleType = 'time';
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface InheritedChildInput extends IndexSignature {
id: string;
searchSessionId?: string;
syncColors?: boolean;
syncCursor?: boolean;
syncTooltips?: boolean;
executionContext?: KibanaExecutionContext;
}
Expand Down Expand Up @@ -351,6 +352,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
filters,
searchSessionId,
syncColors,
syncCursor,
syncTooltips,
executionContext,
} = this.input;
Expand All @@ -371,6 +373,7 @@ export class DashboardContainer extends Container<InheritedChildInput, Dashboard
searchSessionId,
syncColors,
syncTooltips,
syncCursor,
executionContext,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export class DashboardContainerFactoryDefinition
isFullScreenMode: false,
useMargins: true,
syncColors: true,
syncCursor: true,
syncTooltips: true,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const getDashboardState = (state?: Partial<DashboardState>): DashboardState => {
useMargins: true,
syncColors: false,
syncTooltips: false,
syncCursor: true,
},
panels: {
panel_1: {
Expand Down Expand Up @@ -99,6 +100,7 @@ describe('Dashboard state diff function', () => {
useMargins: false,
syncColors: false,
syncTooltips: false,
syncCursor: true,
},
})
).toEqual(['options']);
Expand All @@ -111,6 +113,7 @@ describe('Dashboard state diff function', () => {
useMargins: true,
syncColors: undefined,
syncTooltips: undefined,
syncCursor: true,
} as unknown as DashboardOptions,
})
).toEqual([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export const dashboardStateSlice = createSlice({
setSyncColors: (state, action: PayloadAction<boolean>) => {
state.options.syncColors = action.payload;
},
setSyncCursor: (state, action: PayloadAction<boolean>) => {
state.options.syncCursor = action.payload;
},
setSyncTooltips: (state, action: PayloadAction<boolean>) => {
state.options.syncTooltips = action.payload;
},
Expand Down Expand Up @@ -128,6 +131,7 @@ export const {
setTimeRange,
setSyncColors,
setSyncTooltips,
setSyncCursor,
setUseMargins,
setViewMode,
setFilters,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
setStateFromSaveModal,
setSyncColors,
setSyncTooltips,
setSyncCursor,
setUseMargins,
setViewMode,
useDashboardDispatch,
Expand Down Expand Up @@ -402,6 +403,10 @@ export function DashboardTopNav({
onSyncColorsChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setSyncColors(isChecked));
},
syncCursor: currentState.options.syncCursor ?? true,
onSyncCursorChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setSyncCursor(isChecked));
},
syncTooltips: Boolean(currentState.options.syncTooltips),
onSyncTooltipsChange: (isChecked: boolean) => {
dispatchDashboardStateChange(setSyncTooltips(isChecked));
Expand Down
22 changes: 22 additions & 0 deletions src/plugins/dashboard/public/application/top_nav/options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ interface Props {
onHidePanelTitlesChange: (hideTitles: boolean) => void;
syncColors: boolean;
onSyncColorsChange: (syncColors: boolean) => void;
syncCursor: boolean;
onSyncCursorChange: (syncCursor: boolean) => void;
syncTooltips: boolean;
onSyncTooltipsChange: (syncTooltips: boolean) => void;
}
Expand All @@ -26,6 +28,7 @@ interface State {
useMargins: boolean;
hidePanelTitles: boolean;
syncColors: boolean;
syncCursor: boolean;
syncTooltips: boolean;
}

Expand All @@ -34,6 +37,7 @@ export class OptionsMenu extends Component<Props, State> {
useMargins: this.props.useMargins,
hidePanelTitles: this.props.hidePanelTitles,
syncColors: this.props.syncColors,
syncCursor: this.props.syncCursor,
syncTooltips: this.props.syncTooltips,
};

Expand All @@ -59,6 +63,12 @@ export class OptionsMenu extends Component<Props, State> {
this.setState({ syncColors: isChecked });
};

handleSyncCursorChange = (evt: any) => {
const isChecked = evt.target.checked;
this.props.onSyncCursorChange(isChecked);
this.setState({ syncCursor: isChecked });
};

handleSyncTooltipsChange = (evt: any) => {
const isChecked = evt.target.checked;
this.props.onSyncTooltipsChange(isChecked);
Expand Down Expand Up @@ -101,12 +111,24 @@ export class OptionsMenu extends Component<Props, State> {
/>
</EuiFormRow>

<EuiFormRow>
<EuiSwitch
label={i18n.translate('dashboard.topNav.options.syncCursorBetweenPanelsSwitchLabel', {
defaultMessage: 'Sync cursor across panels',
})}
checked={this.state.syncCursor}
onChange={this.handleSyncCursorChange}
data-test-subj="dashboardSyncCursorCheckbox"
/>
</EuiFormRow>

stratoula marked this conversation as resolved.
Show resolved Hide resolved
<EuiFormRow>
<EuiSwitch
label={i18n.translate('dashboard.topNav.options.syncTooltipsBetweenPanelsSwitchLabel', {
defaultMessage: 'Sync tooltips across panels',
})}
checked={this.state.syncTooltips}
disabled={!Boolean(this.state.syncCursor)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice touch! If your cursor isn't synced, doesn't make sense that the tooltip is synced 👍

onChange={this.handleSyncTooltipsChange}
data-test-subj="dashboardSyncTooltipsCheckbox"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export interface ShowOptionsPopoverProps {
onUseMarginsChange: (useMargins: boolean) => void;
syncColors: boolean;
onSyncColorsChange: (syncColors: boolean) => void;
syncCursor: boolean;
onSyncCursorChange: (syncCursor: boolean) => void;
syncTooltips: boolean;
onSyncTooltipsChange: (syncTooltips: boolean) => void;
hidePanelTitles: boolean;
Expand All @@ -45,6 +47,8 @@ export function showOptionsPopover({
onHidePanelTitlesChange,
syncColors,
onSyncColorsChange,
syncCursor,
onSyncCursorChange,
syncTooltips,
onSyncTooltipsChange,
}: ShowOptionsPopoverProps) {
Expand Down Expand Up @@ -78,6 +82,8 @@ export function showOptionsPopover({
onHidePanelTitlesChange={onHidePanelTitlesChange}
syncColors={syncColors}
onSyncColorsChange={onSyncColorsChange}
syncCursor={syncCursor}
onSyncCursorChange={onSyncCursorChange}
syncTooltips={syncTooltips}
onSyncTooltipsChange={onSyncTooltipsChange}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ describe('ShowShareModal', () => {
hidePanelTitles: true,
useMargins: true,
syncColors: true,
syncCursor: true,
syncTooltips: true,
},
filters: [
Expand Down
1 change: 1 addition & 0 deletions src/plugins/dashboard/public/dashboard_constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const defaultDashboardState: DashboardState = {
options: {
useMargins: true,
syncColors: false,
syncCursor: true,
syncTooltips: false,
hidePanelTitles: false,
},
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/dashboard/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export interface DashboardContainerInput extends ContainerInput {
useMargins: boolean;
syncColors?: boolean;
syncTooltips?: boolean;
syncCursor?: boolean;
viewMode: ViewMode;
filters: Filter[];
title: string;
Expand Down Expand Up @@ -118,6 +119,7 @@ export type DashboardOptions = {
hidePanelTitles: boolean;
useMargins: boolean;
syncColors: boolean;
syncCursor: boolean;
syncTooltips: boolean;
};

Expand Down
Loading