From 1e0f2174e199fcf13675d78da76f6e42ede64180 Mon Sep 17 00:00:00 2001 From: michaelcheng429 Date: Wed, 20 Jan 2016 19:28:23 -0600 Subject: [PATCH] fix histogram extended bounds persisting after deselection --- .../public/agg_types/__tests__/buckets/_histogram.js | 12 ++++++++++++ src/ui/public/agg_types/buckets/histogram.js | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/ui/public/agg_types/__tests__/buckets/_histogram.js b/src/ui/public/agg_types/__tests__/buckets/_histogram.js index 0aa6a3122bd5bb..ea14171d32e601 100644 --- a/src/ui/public/agg_types/__tests__/buckets/_histogram.js +++ b/src/ui/public/agg_types/__tests__/buckets/_histogram.js @@ -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); @@ -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); @@ -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); @@ -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'); + }); }); }); }); diff --git a/src/ui/public/agg_types/buckets/histogram.js b/src/ui/public/agg_types/buckets/histogram.js index 14d292444b8349..344ab964d005fb 100644 --- a/src/ui/public/agg_types/buckets/histogram.js +++ b/src/ui/public/agg_types/buckets/histogram.js @@ -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