Skip to content

Commit

Permalink
[Discover] Updating histogram labels and settings
Browse files Browse the repository at this point in the history
  • Loading branch information
davismcphee committed Nov 3, 2022
1 parent 017a7cb commit f38547e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { EuiComboBox, EuiComboBoxOptionOption, useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import { DataView, DataViewField } from '@kbn/data-views-plugin/common';
import { i18n } from '@kbn/i18n';
import React, { useCallback } from 'react';
import { UnifiedHistogramBreakdownContext } from '../types';

Expand Down Expand Up @@ -47,7 +48,9 @@ export const BreakdownFieldSelector = ({

return (
<EuiComboBox
prepend="Breakdown by"
prepend={i18n.translate('unifiedHistogram.breakdownFieldSelectorLabel', {
defaultMessage: 'Break down by',
})}
singleSelection={{ asPlainText: true }}
options={fieldOptions}
selectedOptions={selectedFields}
Expand Down
24 changes: 19 additions & 5 deletions src/plugins/unified_histogram/public/chart/get_lens_attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import type { DataView, DataViewField } from '@kbn/data-views-plugin/public';
import type { AggregateQuery, Filter, Query } from '@kbn/es-query';
import { i18n } from '@kbn/i18n';
import type {
CountIndexPatternColumn,
DateHistogramIndexPatternColumn,
Expand Down Expand Up @@ -52,10 +53,20 @@ export const getLensAttributes = ({
count_column: {
dataType: 'number',
isBucketed: false,
label: 'Count of records',
label: i18n.translate('unifiedHistogram.countColumnLabel', {
defaultMessage: 'Count of records',
}),
operationType: 'count',
scale: 'ratio',
sourceField: '___records___',
params: {
format: {
id: 'number',
params: {
decimals: 0,
},
},
},
} as CountIndexPatternColumn,
};

Expand All @@ -65,7 +76,10 @@ export const getLensAttributes = ({
breakdown_column: {
dataType: 'string',
isBucketed: true,
label: `Top 3 values of ${breakdownField.name}`,
label: i18n.translate('unifiedHistogram.breakdownColumnLabel', {
defaultMessage: 'Top 3 values of {fieldName}',
values: { fieldName: breakdownField?.displayName },
}),
operationType: 'terms',
scale: 'ordinal',
sourceField: breakdownField.name,
Expand Down Expand Up @@ -139,17 +153,17 @@ export const getLensAttributes = ({
axisTitlesVisibilitySettings: {
x: false,
yLeft: false,
yRight: true,
yRight: false,
},
gridlinesVisibilitySettings: {
x: true,
yLeft: true,
yRight: true,
yRight: false,
},
tickLabelsVisibilitySettings: {
x: true,
yLeft: true,
yRight: true,
yRight: false,
},
},
},
Expand Down

0 comments on commit f38547e

Please sign in to comment.