Skip to content

Commit

Permalink
[ML] Decouple data_visualizer from MapEmbeddable (#181928)
Browse files Browse the repository at this point in the history
Part of #182020

### test instructions
1. install web logs sample data
2. Open discover
3. In table, click "Field statistics"
4. Expand `geo.dest` row. Verify choropleth map is displayed.
5. Expand `geo.coordinates` row. Verify vector map is displayed.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
nreese and kibanamachine committed May 1, 2024
1 parent 5ba6a39 commit 1e8d51a
Show file tree
Hide file tree
Showing 22 changed files with 289 additions and 361 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,19 @@ import React, { useMemo } from 'react';
import type { Feature, Point } from 'geojson';
import type { FieldDataRowProps } from '../../stats_table/types/field_data_row';
import { DocumentStatsTable } from '../../stats_table/components/field_data_expanded_row/document_stats';
import { EmbeddedMapComponent } from '../../embedded_map';
import { convertWKTGeoToLonLat, getGeoPointsLayer } from './format_utils';
import { ExpandedRowContent } from '../../stats_table/components/field_data_expanded_row/expanded_row_content';
import { ExamplesList } from '../../examples_list';
import { ExpandedRowPanel } from '../../stats_table/components/field_data_expanded_row/expanded_row_panel';
import { useDataVisualizerKibana } from '../../../../kibana_context';

export const DEFAULT_GEO_REGEX = RegExp('(?<lat>.+) (?<lon>.+)');

export const GeoPointContent: FC<FieldDataRowProps> = ({ config }) => {
const {
services: { maps: mapsService },
} = useDataVisualizerKibana();

const formattedResults = useMemo(() => {
const { stats } = config;

Expand Down Expand Up @@ -54,20 +58,18 @@ export const GeoPointContent: FC<FieldDataRowProps> = ({ config }) => {
if (geoPointsFeatures.length > 0) {
return {
examples: formattedExamples,
layerList: [getGeoPointsLayer(geoPointsFeatures)],
pointsLayer: getGeoPointsLayer(geoPointsFeatures),
};
}
}
}, [config]);
return (
<ExpandedRowContent dataTestSubj={'dataVisualizerGeoPointContent'}>
<DocumentStatsTable config={config} />
{formattedResults && Array.isArray(formattedResults.examples) && (
<ExamplesList examples={formattedResults.examples} />
)}
{formattedResults && Array.isArray(formattedResults.layerList) && (
{formattedResults?.examples && <ExamplesList examples={formattedResults.examples} />}
{mapsService && formattedResults?.pointsLayer && (
<ExpandedRowPanel className={'dvPanel__wrapper dvMap__wrapper'} grow={true}>
<EmbeddedMapComponent layerList={formattedResults.layerList} />
<mapsService.PassiveMap passiveLayer={formattedResults.pointsLayer} />
</ExpandedRowPanel>
)}
</ExpandedRowContent>
Expand Down

0 comments on commit 1e8d51a

Please sign in to comment.