diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/_field_itm.scss b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/_field_itm.scss new file mode 100644 index 0000000000000..be957dbb403bf --- /dev/null +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/_field_itm.scss @@ -0,0 +1,21 @@ +.lnsFieldItem__topValue { + margin-bottom: $euiSizeS; + + &:last-of-type { + margin-bottom: 0; + } +} + +.lnsFieldItem__topValueProgress { + background-color: $euiColorLightestShade; + + &::-webkit-progress-bar { + background-color: $euiColorLightestShade; + } +} + +.lnsFieldItem__fieldPopoverPanel { + min-width: 260px; + max-width: 300px; +} + diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/field_item.tsx b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/field_item.tsx index 0fe94356579a9..51df6cce026ea 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/field_item.tsx +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/field_item.tsx @@ -15,7 +15,8 @@ import { EuiText, EuiToolTip, EuiButtonGroup, - EuiSpacer, + EuiPopoverFooter, + EuiPopoverTitle, } from '@elastic/eui'; import { Chart, @@ -246,49 +247,66 @@ export function FieldItem({ isOpen={infoIsOpen} closePopover={() => setOpen(false)} anchorPosition="rightUp" - panelClassName="lnsFieldListPanel__fieldPopover" + panelClassName="lnsFieldItem__fieldPopoverPanel" > -
- {state.isLoading && } - + {state.histogram && state.histogram.buckets.length && state.topValues && state.topValues.buckets.length && ( - <> - { - setShowingHistogram(optionId === 'histogram'); - }} - idSelected={showingHistogram ? 'histogram' : 'topValues'} - /> - - + { + setShowingHistogram(optionId === 'histogram'); + }} + idSelected={showingHistogram ? 'histogram' : 'topValues'} + /> )} + {state.topValues && state.sampledValues && !state.histogram && !showingHistogram && ( + <> + {i18n.translate('xpack.lens.indexPattern.fieldTopValuesLabel', { + defaultMessage: 'Top Values', + })} + + )} + {field.type === 'date' && ( + <> + {i18n.translate('xpack.lens.indexPattern.fieldTimeDistributionLabel', { + defaultMessage: 'Time distribution', + })} + + )} + +
+ {state.isLoading && } {state.histogram && (!state.topValues || showingHistogram) && ( - + {state.topValues.buckets.map(topValue => ( - - +
+ - - {formatter.convert(topValue.key)} + + + {formatter.convert(topValue.key)} + - + {((topValue.count / state.sampledValues!) * 100).toFixed(1)}% -
- - - -
- - - + +
))} {otherCount ? ( <> - + - + {i18n.translate('xpack.lens.indexPattern.otherDocsLabel', { defaultMessage: 'Other', })} @@ -365,14 +380,13 @@ export function FieldItem({ -
- -
+ ) : ( <> @@ -381,27 +395,26 @@ export function FieldItem({ )} {state.totalDocuments ? ( -
- - {state.sampledDocuments ? ( - - {i18n.translate('xpack.lens.indexPattern.percentageOfTotalDocsLabel', { - defaultMessage: '{percentage}% of {docCount} documents', - values: { - docCount: state.totalDocuments, - percentage: ((state.sampledDocuments / state.totalDocuments) * 100).toFixed(1), - }, - })} - - ) : ( - - {i18n.translate('xpack.lens.indexPattern.totalDocsLabel', { - defaultMessage: '{docCount} documents', - values: { docCount: state.totalDocuments }, - })} - - )} -
+ + + {state.sampledDocuments && ( + <> + {i18n.translate('xpack.lens.indexPattern.percentageOfLabel', { + defaultMessage: '{percentage}% of', + values: { + percentage: ((state.sampledDocuments / state.totalDocuments) * 100).toFixed( + 1 + ), + }, + })} + + )}{' '} + {state.totalDocuments}{' '} + {i18n.translate('xpack.lens.indexPattern.ofDocumentsLabel', { + defaultMessage: 'documents', + })} + + ) : ( <> )} diff --git a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.scss b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.scss index 2ebdf1a2c7e59..733a30858dab7 100644 --- a/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.scss +++ b/x-pack/legacy/plugins/lens/public/indexpattern_plugin/indexpattern.scss @@ -1,3 +1,4 @@ +@import './field_itm'; @import './dimension_panel/index'; @@ -74,12 +75,3 @@ padding: $euiSizeS; font-weight: $euiFontWeightMedium; } - -.lnsDistributionChart { - min-height: 300px; -} - -.lnsFieldListPanel__fieldPopover { - min-width: 300px; - max-width: 300px; -}