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

[TSVB] Allows the user to change the tooltip mode #67775

Merged
merged 3 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class TimeseriesPanelConfigUi extends Component {
axis_min: '',
legend_position: 'right',
show_grid: 1,
tooltip_mode: 'show_all',
};
const model = { ...defaults, ...this.props.model };
const { selectedTab } = this.state;
Expand All @@ -85,6 +86,22 @@ class TimeseriesPanelConfigUi extends Component {
value: 'left',
},
];
const tooltipModeOptions = [
{
label: intl.formatMessage({
id: 'visTypeTimeseries.timeseries.tooltipOptions.showAll',
defaultMessage: 'Show all values',
}),
value: 'show_all',
},
{
label: intl.formatMessage({
id: 'visTypeTimeseries.timeseries.tooltipOptions.showFocused',
defaultMessage: 'Show focused values',
}),
value: 'show_focused',
},
];
const selectedPositionOption = positionOptions.find((option) => {
return model.axis_position === option.value;
});
Expand Down Expand Up @@ -134,6 +151,10 @@ class TimeseriesPanelConfigUi extends Component {
return model.legend_position === option.value;
});

const selectedTooltipMode = tooltipModeOptions.find((option) => {
return model.tooltip_mode === option.value;
});

let view;
if (selectedTab === 'data') {
view = (
Expand Down Expand Up @@ -356,6 +377,24 @@ class TimeseriesPanelConfigUi extends Component {
<EuiFlexItem>
<YesNo value={model.show_grid} name="show_grid" onChange={this.props.onChange} />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiFormLabel>
<FormattedMessage
id="visTypeTimeseries.timeseries.optionsTab.tooltipMode"
defaultMessage="Tooltip"
/>
</EuiFormLabel>
</EuiFlexItem>
<EuiFlexItem>
<EuiComboBox
isClearable={false}
id={htmlId('tooltipMode')}
options={tooltipModeOptions}
selectedOptions={selectedTooltipMode ? [selectedTooltipMode] : []}
onChange={handleSelectChange('tooltip_mode')}
singleSelection={{ asPlainText: true }}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiPanel>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export class TimeseriesVisualization extends Component {
showGrid={Boolean(model.show_grid)}
legend={Boolean(model.show_legend)}
legendPosition={model.legend_position}
tooltipMode={model.tooltip_mode}
xAxisLabel={getAxisLabelString(interval)}
xAxisFormatter={this.xAxisFormatter(interval)}
annotations={this.prepareAnnotations()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const TimeSeries = ({
showGrid,
legend,
legendPosition,
tooltipMode,
xAxisLabel,
series,
yAxis,
Expand Down Expand Up @@ -131,7 +132,7 @@ export const TimeSeries = ({
baseTheme={theme}
tooltip={{
snap: true,
type: TooltipType.VerticalCursor,
type: tooltipMode === 'show_focused' ? TooltipType.Follow : TooltipType.VerticalCursor,
headerFormatter: tooltipFormatter,
}}
/>
Expand Down
1 change: 1 addition & 0 deletions src/plugins/vis_type_timeseries/public/metrics_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export const metricsVisDefinition = {
axis_scale: 'normal',
show_legend: 1,
show_grid: 1,
tooltip_mode: 'show_all',
},
component: VisEditor,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,9 @@ export const visPayloadSchema = schema.object({
series: schema.arrayOf(seriesItems),
show_grid: numberIntegerRequired,
show_legend: numberIntegerRequired,
tooltip_mode: schema.maybe(
schema.oneOf([schema.literal('show_all'), schema.literal('show_focused')])
),
time_field: stringOptionalNullable,
time_range_mode: stringOptionalNullable,
type: stringRequired,
Expand Down