Skip to content

Commit

Permalink
Add a combobox to select the tooltip mode
Browse files Browse the repository at this point in the history
  • Loading branch information
stratoula committed May 29, 2020
1 parent 84ed509 commit 1a54910
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
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.tooltipOptiond.showAll',
defaultMessage: 'Show All Series values',
}),
value: 'show_all',
},
{
label: intl.formatMessage({
id: 'visTypeTimeseries.timeseries.tooltipOptiond.showFocused',
defaultMessage: 'Show Focused Series 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 Mode"
/>
</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_all' ? TooltipType.VerticalCursor : TooltipType.Follow,
headerFormatter: tooltipFormatter,
}}
/>
Expand Down

0 comments on commit 1a54910

Please sign in to comment.