Skip to content

Commit

Permalink
Add histogram icon, fix types showing for hidden fields
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Jul 7, 2021
1 parent bbd6137 commit 48a55e8
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ export const FieldTypeIcon: FC<FieldTypeIconProps> = ({
color = 'euiColorVis0';
break;
case JOB_FIELD_TYPES.NUMBER:
case JOB_FIELD_TYPES.HISTOGRAM:
iconType = 'tokenNumber';
color = fieldName !== undefined ? 'euiColorVis1' : 'euiColorVis2';
break;
case JOB_FIELD_TYPES.HISTOGRAM:
iconType = 'tokenHistogram';
color = 'euiColorVis7';
case JOB_FIELD_TYPES.UNKNOWN:
// Use defaults
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export function kbnTypeToJobType(field: IndexPatternField) {
case KBN_FIELD_TYPES.GEO_SHAPE:
type = JOB_FIELD_TYPES.GEO_SHAPE;
break;
case KBN_FIELD_TYPES.HISTOGRAM:
type = JOB_FIELD_TYPES.HISTOGRAM;
break;

default:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import { useDataVisualizerKibana } from '../../../kibana_context';
import { FieldCountPanel } from '../../../common/components/field_count_panel';
import { DocumentCountContent } from '../../../common/components/document_count_content';
import { DataLoader } from '../../data_loader/data_loader';
import { JOB_FIELD_TYPES } from '../../../../../common';
import { JOB_FIELD_TYPES, OMIT_FIELDS } from '../../../../../common';
import { useTimefilter } from '../../hooks/use_time_filter';
import { kbnTypeToJobType } from '../../../common/util/field_types_utils';
import { SearchPanel } from '../search_panel';
Expand Down Expand Up @@ -204,18 +204,21 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
}
}, [currentIndexPattern, toasts]);

// Obtain the list of non metric field types which appear in the index pattern.
let indexedFieldTypes: JobFieldType[] = [];
const indexPatternFields: IndexPatternField[] = currentIndexPattern.fields;
indexPatternFields.forEach((field) => {
if (field.scripted !== true) {
const dataVisualizerType: JobFieldType | undefined = kbnTypeToJobType(field);
if (dataVisualizerType !== undefined && !indexedFieldTypes.includes(dataVisualizerType)) {
indexedFieldTypes.push(dataVisualizerType);

const fieldTypes = useMemo(() => {
// Obtain the list of non metric field types which appear in the index pattern.
const indexedFieldTypes: JobFieldType[] = [];
indexPatternFields.forEach((field) => {
if (!OMIT_FIELDS.includes(field.name) && field.scripted !== true) {
const dataVisualizerType: JobFieldType | undefined = kbnTypeToJobType(field);
if (dataVisualizerType !== undefined && !indexedFieldTypes.includes(dataVisualizerType)) {
indexedFieldTypes.push(dataVisualizerType);
}
}
}
});
indexedFieldTypes = indexedFieldTypes.sort();
});
return indexedFieldTypes.sort();
}, [indexPatternFields]);

const defaults = getDefaultPageState();

Expand Down Expand Up @@ -859,7 +862,7 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
samplerShardSize={samplerShardSize}
setSamplerShardSize={setSamplerShardSize}
overallStats={overallStats}
indexedFieldTypes={indexedFieldTypes}
indexedFieldTypes={fieldTypes}
setVisibleFieldTypes={setVisibleFieldTypes}
visibleFieldTypes={visibleFieldTypes}
visibleFieldNames={visibleFieldNames}
Expand Down

0 comments on commit 48a55e8

Please sign in to comment.