Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Maps] Add table source for choropleth mapping #89263

Merged
merged 23 commits into from
Feb 1, 2021

Conversation

thomasneirynck
Copy link
Contributor

@thomasneirynck thomasneirynck commented Jan 26, 2021

Summary

This adds a new source TABLE_SOURCE that can be used in descriptors to inject custom tabular data to use in a term join.

Intended for users of the MapsEmbeddable, so they can do choropleth mapping with custom data (e.g. mash up an EMS layer with a custom table).

This is a follow-on to the ML work here: #88416. It would allow ML to map anomalies by state/country.

Example:

const choroplethLayer = {
  joins: [
    {
      leftField: 'iso2',
      right: {
        id: 'foobar',
        type: SOURCE_TYPES.TABLE_SOURCE,
        __rows: 
          [
            {
             population: 300000000,
             iso2_right: 'US'
            },
           {
           population: 1000000000,
           iso2_right: 'CN'
          }
        ],
        __columns: [
          {
            name: 'iso2_right',
            type: 'string',
          },
          {
            name: 'population',
            type: 'number',
          },
        ],
        term: 'iso2_right',
        metrics: [],
      },
    },
  ],
  sourceDescriptor: {
    type: 'EMS_FILE',
    id: 'world_countries',
  },
  style: {
    type: 'VECTOR',
    properties: {
      icon: { type: STYLE_TYPE.STATIC, options: { value: 'marker' } },
      fillColor: {
        type: STYLE_TYPE.DYNAMIC,
        options: {
          customColorRamp: [
            {
              stop: 0,
              color: '#FF0000',
            },
            {
              stop: 1,
              color: '#00FF00',
            },
          ],
          field: {
            name: 'population',
            origin: FIELD_ORIGIN.JOIN,
          },
          useCustomColorRamp: true,
        },
      },
      lineColor: {
        type: STYLE_TYPE.DYNAMIC,
        options: { color: '#3d3d3d', fieldMetaOptions: { isEnabled: true } },
      },
      lineWidth: { type: STYLE_TYPE.STATIC, options: { size: 1 } },
      iconSize: { type: STYLE_TYPE.STATIC, options: { size: 6 } },
      iconOrientation: {
        type: STYLE_TYPE.STATIC,
        options: { orientation: 0 },
      },
      labelText: { type: STYLE_TYPE.STATIC, options: { value: '' } },
      labelColor: {
        type: STYLE_TYPE.STATIC,
        options: { color: '#000000' },
      },
      labelSize: { type: STYLE_TYPE.STATIC, options: { size: 14 } },
      labelBorderColor: {
        type: STYLE_TYPE.STATIC,
        options: { color: '#FFFFFF' },
      },
      symbolizeAs: { options: { value: SYMBOLIZE_AS_TYPES.CIRCLE } },
      labelBorderSize: { options: { size: LABEL_BORDER_SIZES.SMALL } },
    },
    isTimeAware: true,
  },
  id: 'e8d1d974-eed8-462f-be2c-f0004b7619b2',
  label: null,
  minZoom: 0,
  maxZoom: 24,
  alpha: 0.75,
  visible: true,
  type: 'VECTOR',
};


@thomasneirynck thomasneirynck added the [Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation label Jan 26, 2021
@thomasneirynck thomasneirynck changed the title [Maps] Add [Maps] Add table source for choropleth mapping Jan 26, 2021
@thomasneirynck thomasneirynck added release_note:skip Skip the PR/issue when compiling release notes v7.12.0 v8.0.0 WIP Work in progress labels Jan 28, 2021
@thomasneirynck thomasneirynck requested a review from nreese January 28, 2021 21:04

export class GeoJsonFileField extends AbstractField implements IField {
private readonly _source: GeoJsonFileSource;
export class InlineField<T extends IVectorSource> extends AbstractField implements IField {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should getSource method return T instead of IVectorSource?

Copy link
Contributor Author

@thomasneirynck thomasneirynck Jan 28, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that's necessary. IVectorSource is the more generic return-type and none of the other IFields substitute this type for amore specific instance either. getSource is also the method that we want to remove from IField.

x-pack/plugins/maps/public/classes/joins/inner_join.ts Outdated Show resolved Hide resolved
@thomasneirynck thomasneirynck removed the WIP Work in progress label Jan 29, 2021
@thomasneirynck thomasneirynck marked this pull request as ready for review January 29, 2021 17:47
@thomasneirynck thomasneirynck requested a review from a team as a code owner January 29, 2021 17:47
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-gis (Team:Geo)

@botelastic botelastic bot added Team:APM All issues that need APM UI Team support Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability labels Jan 29, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/uptime (Team:uptime)

@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@thomasneirynck thomasneirynck requested a review from a team as a code owner January 29, 2021 22:50
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM
code review

Copy link
Contributor

@justinkambic justinkambic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, UX app working fine with this patch.

@thomasneirynck
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
maps 685 689 +4

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 5.2MB 5.2MB +50.0B
maps 2.6MB 2.6MB +5.3KB
total +5.4KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
maps 138.4KB 138.4KB +44.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Deprecated-Use Team:Presentation]Team:Geo Former Team Label for Geo Team. Now use Team:Presentation release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.12.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants