Use default precision variable
This commit is contained in:
+6
-2
@@ -1,7 +1,7 @@
|
||||
import { BucketAggregation } from '../../../../types';
|
||||
import { describeMetric, convertOrderByToMetricId } from '../../../../utils';
|
||||
import { useQuery } from '../../ElasticsearchQueryContext';
|
||||
import { bucketAggregationConfig, orderByOptions, orderOptions } from '../utils';
|
||||
import { bucketAggregationConfig, orderByOptions, orderOptions, defaultPrecisionString } from '../utils';
|
||||
|
||||
const hasValue = (value: string) => (object: { value?: string }) => object.value === value;
|
||||
|
||||
@@ -61,7 +61,11 @@ export const useDescription = (bucketAgg: BucketAggregation): string => {
|
||||
}
|
||||
|
||||
case 'geohash_grid': {
|
||||
const precision = Math.max(Math.min(parseInt(bucketAgg.settings?.precision || '3', 10), 12), 1);
|
||||
// We want to use precision from the settings if it's set, but we also want to make sure it's in the range of 1-12
|
||||
const precision = Math.max(
|
||||
Math.min(parseInt(bucketAgg.settings?.precision || defaultPrecisionString, 10), 12),
|
||||
1
|
||||
);
|
||||
return `Precision: ${precision}`;
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ import { InternalTimeZones, SelectableValue } from '@grafana/data';
|
||||
import { BucketsConfiguration } from '../../../types';
|
||||
|
||||
import { defaultFilter } from './SettingsEditor/FiltersSettingsEditor/utils';
|
||||
export const defaultPrecisionString = '3';
|
||||
|
||||
export const bucketAggregationConfig: BucketsConfiguration = {
|
||||
terms: {
|
||||
@@ -26,7 +27,7 @@ export const bucketAggregationConfig: BucketsConfiguration = {
|
||||
label: 'Geo Hash Grid',
|
||||
requiresField: true,
|
||||
defaultSettings: {
|
||||
precision: '3',
|
||||
precision: defaultPrecisionString,
|
||||
},
|
||||
},
|
||||
date_histogram: {
|
||||
|
||||
Reference in New Issue
Block a user