Skip to content

Commit

Permalink
Added showTooltip.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kuznietsov committed Apr 19, 2022
1 parent dfccec6 commit 4d5eea1
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const createArgsWithLayers = (
xTitle: '',
yTitle: '',
yRightTitle: '',
showTooltip: true,
legend: {
type: 'legendConfig',
isVisible: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ export const layeredXyVisFunction: ExpressionFunctionDefinition<
}),
required: false,
},
showTooltip: {
types: ['boolean'],
default: true,
help: i18n.translate('expressionXY.layeredXyVis.showTooltip.help', {
defaultMessage: 'Show tooltip',
}),
},
},
fn(data, args, handlers) {
const layers = (args.layers ?? []).filter<XYExtendedLayerConfigResult>(
Expand All @@ -185,6 +192,7 @@ export const layeredXyVisFunction: ExpressionFunctionDefinition<
value: {
args: {
...args,
showTooltip: args.showTooltip ?? false,
layers,
ariaLabel:
args.ariaLabel ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,13 @@ export const xyVisFunction: ExpressionFunctionDefinition<
defaultMessage: 'Specifies the aria label of the xy chart',
}),
},
showTooltip: {
types: ['boolean'],
default: true,
help: i18n.translate('expressionXY.xyVis.showTooltip.help', {
defaultMessage: 'Show tooltip',
}),
},
},
fn(data, args, handlers) {
const { dataLayers = [], referenceLineLayers = [], annotationLayers = [], ...restArgs } = args;
Expand Down Expand Up @@ -293,6 +300,7 @@ export const xyVisFunction: ExpressionFunctionDefinition<
value: {
args: {
...restArgs,
showTooltip: args.showTooltip ?? false,
layers,
ariaLabel:
args.ariaLabel ??
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ export interface XYArgs {
hideEndzones?: boolean;
valuesInLegend?: boolean;
ariaLabel?: string;
showTooltip?: boolean;
}

export interface LayeredXYArgs {
Expand All @@ -225,6 +226,7 @@ export interface LayeredXYArgs {
hideEndzones?: boolean;
valuesInLegend?: boolean;
ariaLabel?: string;
showTooltip?: boolean;
}

export interface XYProps {
Expand All @@ -248,6 +250,7 @@ export interface XYProps {
hideEndzones?: boolean;
valuesInLegend?: boolean;
ariaLabel?: string;
showTooltip: boolean;
}

export interface AnnotationLayerArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2064,6 +2064,7 @@ describe('XYChart component', () => {
};

const args: XYProps = {
showTooltip: true,
xTitle: '',
yTitle: '',
yRightTitle: '',
Expand Down Expand Up @@ -2151,6 +2152,7 @@ describe('XYChart component', () => {
};

const args: XYProps = {
showTooltip: true,
xTitle: '',
yTitle: '',
yRightTitle: '',
Expand Down Expand Up @@ -2222,6 +2224,7 @@ describe('XYChart component', () => {
};

const args: XYProps = {
showTooltip: true,
xTitle: '',
yTitle: '',
yRightTitle: '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
DisplayValueStyle,
RecursivePartial,
AxisStyle,
TooltipType,
} from '@elastic/charts';
import { IconType } from '@elastic/eui';
import { PaletteRegistry } from '@kbn/coloring';
Expand Down Expand Up @@ -526,6 +527,7 @@ export function XYChart({
tooltip={{
boundary: document.getElementById('app-fixed-viewport') ?? undefined,
headerFormatter: (d) => safeXAccessorLabelRenderer(d.value),
type: args.showTooltip ? TooltipType.VerticalCursor : TooltipType.None,
}}
allowBrushingLastHistogramBin={isTimeViz}
rotation={shouldRotate ? 90 : 0}
Expand Down

0 comments on commit 4d5eea1

Please sign in to comment.