Skip to content

Commit

Permalink
Merge pull request #5960 from michaelcheng429/histogram
Browse files Browse the repository at this point in the history
fix histogram extended bounds persisting after deselection
  • Loading branch information
Rashid Khan committed Mar 11, 2016
2 parents a7d44bd + 1e0f217 commit afff70c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/ui/public/agg_types/__tests__/buckets/_histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ describe('Histogram Agg', function () {
describe('extended_bounds', function () {
it('writes when only eb.min is set', function () {
var output = paramWriter.write({
min_doc_count: true,
extended_bounds: { min: 0 }
});
expect(output.params.extended_bounds).to.have.property('min', 0);
Expand All @@ -90,6 +91,7 @@ describe('Histogram Agg', function () {

it('writes when only eb.max is set', function () {
var output = paramWriter.write({
min_doc_count: true,
extended_bounds: { max: 0 }
});
expect(output.params.extended_bounds).to.have.property('min', undefined);
Expand All @@ -98,6 +100,7 @@ describe('Histogram Agg', function () {

it('writes when both eb.min and eb.max are set', function () {
var output = paramWriter.write({
min_doc_count: true,
extended_bounds: { min: 99, max: 100 }
});
expect(output.params.extended_bounds).to.have.property('min', 99);
Expand All @@ -106,10 +109,19 @@ describe('Histogram Agg', function () {

it('does not write when nothing is set', function () {
var output = paramWriter.write({
min_doc_count: true,
extended_bounds: {}
});
expect(output.params).to.not.have.property('extended_bounds');
});

it('does not write when min_doc_count is false', function () {
var output = paramWriter.write({
min_doc_count: false,
extended_bounds: { min: 99, max: 100 }
});
expect(output.params).to.not.have.property('extended_bounds');
});
});
});
});
2 changes: 1 addition & 1 deletion src/ui/public/agg_types/buckets/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function HistogramAggDefinition(Private) {
write: function (aggConfig, output) {
var val = aggConfig.params.extended_bounds;

if (val.min != null || val.max != null) {
if (aggConfig.params.min_doc_count && (val.min != null || val.max != null)) {
output.params.extended_bounds = {
min: val.min,
max: val.max
Expand Down

0 comments on commit afff70c

Please sign in to comment.