Skip to content

Commit 4ad1ae7

Browse files
add category-rollups
1 parent ba79ed5 commit 4ad1ae7

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

x-pack/plugins/maps/public/classes/styles/vector/properties/dynamic_style_property.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import _ from 'lodash';
99
import React from 'react';
1010
import { Feature, FeatureCollection } from 'geojson';
1111
import type { FeatureIdentifier, Map as MbMap } from '@kbn/mapbox-gl';
12-
import { Map } from '@kbn/mapbox-gl';
1312
import { AbstractStyleProperty, IStyleProperty } from './style_property';
1413
import { DEFAULT_SIGMA } from '../vector_style_defaults';
1514
import {
@@ -341,7 +340,7 @@ export class DynamicStyleProperty<T>
341340

342341
const name = this.getFieldName();
343342

344-
const counts = new Map();
343+
const counts = new Map<string, number>();
345344
for (let i = 0; i < metaFeatures.length; i++) {
346345
const fieldMeta = metaFeatures[i].properties.fieldMeta;
347346
if (fieldMeta && fieldMeta[name] && fieldMeta[name].categories) {
@@ -352,7 +351,7 @@ export class DynamicStyleProperty<T>
352351
// properties object may be sparse, so need to check if the field is effectively present
353352
if (typeof category.key !== undefined) {
354353
if (counts.has(category.key)) {
355-
counts.set(category.key, counts.get(category.key) + category.count);
354+
counts.set(category.key, (counts.get(category.key) as number) + category.count);
356355
} else {
357356
counts.set(category.key, category.count);
358357
}

x-pack/plugins/maps/public/classes/styles/vector/vector_style.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,20 @@ export class VectorStyle implements IVectorStyle {
506506
}
507507

508508
dynamicProperties.forEach((dynamicProperty) => {
509-
const name = dynamicProperty.getFieldName();
510-
511509
const ordinalStyleMeta = dynamicProperty.pluckOrdinalStyleMetaFromTileMetaFeatures(
512510
metaFeatures
513511
);
512+
const categoricalStyleMeta = dynamicProperty.pluckCategoricalStyleMetaFromTileMetaFeatures(
513+
metaFeatures
514+
);
514515

516+
const name = dynamicProperty.getFieldName();
515517
if (!styleMeta.fieldMeta[name]) {
516518
styleMeta.fieldMeta[name] = {};
517519
}
520+
if (categoricalStyleMeta) {
521+
styleMeta.fieldMeta[name].categories = categoricalStyleMeta;
522+
}
518523

519524
if (ordinalStyleMeta) {
520525
styleMeta.fieldMeta[name].range = ordinalStyleMeta;

0 commit comments

Comments
 (0)