Skip to content

Commit

Permalink
Gauge/goal: Tooltip always includes "_all" (elastic#101064) (elastic#…
Browse files Browse the repository at this point in the history
…101248)

* Don't show _all for goal and gauge in tooltip

* add unit test
  • Loading branch information
VladLasitsa authored Jun 3, 2021
1 parent c42fbf7 commit 70bd851
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function pointSeriesTooltipFormatter() {

const details = [];
const isGauge = config.get('gauge', false);
const chartType = config.get('type', undefined);
const isPercentageMode = config.get(isGauge ? 'gauge.percentageMode' : 'percentageMode', false);
const isSetColorRange = config.get('setColorRange', false);

Expand All @@ -44,7 +45,8 @@ export function pointSeriesTooltipFormatter() {
});
}

if (datum.x !== null && datum.x !== undefined) {
// For goal and gauge we have only one value for x - '_all'. It doesn't have sense to show it
if (datum.x !== null && datum.x !== undefined && !['goal', 'gauge'].includes(chartType)) {
addDetail(data.xAxisLabel, data.xAxisFormatter(datum.x));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,27 @@ describe('tooltipFormatter', function () {
const $rows = $el.find('tr');
expect($rows.length).toBe(3);
});

it('renders correctly for gauge/goal visualizations', function () {
const event = _.cloneDeep(baseEvent);
let type = 'gauge';
event.config.get = (name) => {
const config = {
setColorRange: false,
gauge: false,
percentageMode: false,
type,
};
return config[name];
};

let $el = $(tooltipFormatter(event, uiSettings));
let $rows = $el.find('tr');
expect($rows.length).toBe(2);

type = 'goal';
$el = $(tooltipFormatter(event, uiSettings));
$rows = $el.find('tr');
expect($rows.length).toBe(2);
});
});

0 comments on commit 70bd851

Please sign in to comment.