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

Honor custom label, if set, in percentile and median metric visualizations #7021

Merged
merged 3 commits into from
Apr 28, 2016
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
38 changes: 38 additions & 0 deletions src/ui/public/agg_types/__tests__/metrics/percentiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import AggTypeMetricPercentilesProvider from 'ui/agg_types/metrics/percentiles';
import VisProvider from 'ui/vis';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

describe('AggTypeMetricPercentilesProvider class', function () {

let Vis;
let indexPattern;
let aggTypeMetricPercentiles;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
Vis = Private(VisProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
aggTypeMetricPercentiles = Private(AggTypeMetricPercentilesProvider);
}));

it('uses the custom label if it is set', function () {
const vis = new Vis(indexPattern, {});

// Grab the aggConfig off the vis (we don't actually use the vis for
// anything else)
const aggConfig = vis.aggs[0];
aggConfig.params.customLabel = 'prince';
aggConfig.params.percents = [ 95 ];
aggConfig.params.field = {
displayName: 'bytes'
};

const responseAggs = aggTypeMetricPercentiles.getResponseAggs(aggConfig);
const ninetyFifthPercentileLabel = responseAggs[0].makeLabel();

expect(ninetyFifthPercentileLabel).to.be('95th percentile of prince');
});

});
3 changes: 2 additions & 1 deletion src/ui/public/agg_types/metrics/percentiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export default function AggTypeMetricPercentilesProvider(Private) {

let valueProps = {
makeLabel: function () {
return ordinalSuffix(this.key) + ' percentile of ' + this.fieldDisplayName();
const label = this.params.customLabel || this.fieldDisplayName();
return ordinalSuffix(this.key) + ' percentile of ' + label;
}
};

Expand Down