-
Notifications
You must be signed in to change notification settings - Fork 0
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
Use new form for auto histogram #4
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,6 +103,34 @@ describe('Histogram Agg', () => { | |
}); | ||
}); | ||
|
||
describe('useAuto', () => { | ||
test('should not be written to the DSL', () => { | ||
const aggConfigs = getAggConfigs({ | ||
useAuto: true, | ||
field: { | ||
name: 'field', | ||
}, | ||
}); | ||
const { [BUCKET_TYPES.HISTOGRAM]: params } = aggConfigs.aggs[0].toDsl(); | ||
|
||
expect(params).not.toHaveProperty('useAuto'); | ||
}); | ||
}); | ||
|
||
describe('maxBars', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thank you, I'll add that test |
||
test('should not be written to the DSL', () => { | ||
const aggConfigs = getAggConfigs({ | ||
maxBars: 50, | ||
field: { | ||
name: 'field', | ||
}, | ||
}); | ||
const { [BUCKET_TYPES.HISTOGRAM]: params } = aggConfigs.aggs[0].toDsl(); | ||
|
||
expect(params).not.toHaveProperty('maxBars'); | ||
}); | ||
}); | ||
|
||
describe('interval', () => { | ||
test('accepts a whole number', () => { | ||
const params = getParams({ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
import { get } from 'lodash'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { isAutoInterval, KBN_FIELD_TYPES, UI_SETTINGS } from '../../../../common'; | ||
import { KBN_FIELD_TYPES, UI_SETTINGS } from '../../../../common'; | ||
import { AggTypesDependencies } from '../agg_types'; | ||
import { BaseAggParams } from '../types'; | ||
|
||
|
@@ -47,7 +47,9 @@ export interface IBucketHistogramAggConfig extends IBucketAggConfig { | |
|
||
export interface AggParamsHistogram extends BaseAggParams { | ||
field: string; | ||
interval: string; | ||
useAuto: boolean; | ||
maxBars?: number; | ||
interval?: number; | ||
intervalBase?: number; | ||
min_doc_count?: boolean; | ||
has_extended_bounds?: boolean; | ||
|
@@ -101,8 +103,16 @@ export const getHistogramBucketAgg = ({ | |
default: null, | ||
write: () => {}, | ||
}, | ||
{ | ||
name: 'useAuto', | ||
default: true, | ||
write: () => {}, | ||
}, | ||
{ | ||
name: 'interval', | ||
shouldShow(agg) { | ||
return !get(agg, 'params.useAuto'); | ||
}, | ||
modifyAggConfigOnSearchRequestStart( | ||
aggConfig: IBucketHistogramAggConfig, | ||
searchSource: any, | ||
|
@@ -150,6 +160,7 @@ export const getHistogramBucketAgg = ({ | |
const values = aggConfig.getAutoBounds(); | ||
|
||
output.params.interval = calculateHistogramInterval({ | ||
useAuto: aggConfig.params.useAuto, | ||
values, | ||
interval: aggConfig.params.interval, | ||
maxBucketsUiSettings: getConfig(UI_SETTINGS.HISTOGRAM_MAX_BARS), | ||
|
@@ -159,8 +170,9 @@ export const getHistogramBucketAgg = ({ | |
}, | ||
{ | ||
name: 'maxBars', | ||
default: getConfig(UI_SETTINGS.HISTOGRAM_MAX_BARS), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
shouldShow(agg) { | ||
return isAutoInterval(get(agg, 'params.interval')); | ||
return get(agg, 'params.useAuto'); | ||
}, | ||
write: () => {}, | ||
}, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiSwitch, EuiFormRow } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { AggParamEditorProps } from '../agg_param_props'; | ||
|
||
function AutoIntervalParamEditor({ value = false, setValue }: AggParamEditorProps<boolean>) { | ||
const label = i18n.translate('visDefaultEditor.controls.useAutoInterval', { | ||
defaultMessage: 'Use auto interval', | ||
}); | ||
|
||
return ( | ||
<EuiFormRow compressed> | ||
<EuiSwitch | ||
compressed={true} | ||
label={label} | ||
checked={value} | ||
onChange={(ev) => setValue(ev.target.checked)} | ||
/> | ||
</EuiFormRow> | ||
); | ||
} | ||
|
||
export { AutoIntervalParamEditor }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure that it's related to that PR