Skip to content

Commit

Permalink
rebase datashader
Browse files Browse the repository at this point in the history
  • Loading branch information
maihde committed Mar 19, 2021
1 parent 797e62c commit 000b2f7
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 8 deletions.
16 changes: 16 additions & 0 deletions x-pack/plugins/maps/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,20 @@

import { schema, TypeOf } from '@kbn/config-schema';

export interface DatashaderConfigType {
url: string;
defaultGeospatialField: string;
defaultEllipseMajor: string;
defaultEllipseMinor: string;
defaultEllipseTilt: string;
}

export interface MapsConfigType {
enabled: boolean;
showMapVisualizationTypes: boolean;
showMapsInspectorAdapter: boolean;
preserveDrawingBuffer: boolean;
datashader: DatashaderConfigType;
}

export const configSchema = schema.object({
Expand All @@ -21,6 +30,13 @@ export const configSchema = schema.object({
showMapsInspectorAdapter: schema.boolean({ defaultValue: false }),
// flag used in functional testing
preserveDrawingBuffer: schema.boolean({ defaultValue: false }),
datashader: schema.object({
url: schema.string(),
defaultGeospatialField: schema.string({ defaultValue: null }),
defaultEllipseMajor: schema.string({ defaultValue: null }),
defaultEllipseMinor: schema.string({ defaultValue: null }),
defaultEllipseTilt: schema.string({ defaultValue: null })
}),
});

export type MapsXPackConfig = TypeOf<typeof configSchema>;
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export function registerLayerWizards() {
return;
}

registerLayerWizard(datashaderWizardConfig);

// Registration order determines display order
registerLayerWizard(uploadLayerWizardConfig);
registerLayerWizard(ObservabilityLayerWizardConfig);
Expand Down
10 changes: 7 additions & 3 deletions x-pack/plugins/maps/public/datashader/datashader_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export class DatashaderLayer extends AbstractLayer {
super({ layerDescriptor, source, style });
if (!layerDescriptor.style) {
const defaultStyle = DatashaderStyle.createDescriptor();
this._style = new DatashaderStyle(defaultStyle);
this._style = new DatashaderStyle(defaultStyle, source, this);
} else {
this._style = new DatashaderStyle(layerDescriptor.style);
this._style = new DatashaderStyle(layerDescriptor.style, source, this);
}
this._mbMap = null;
}
Expand Down Expand Up @@ -70,6 +70,7 @@ export class DatashaderLayer extends AbstractLayer {
const timeFieldName = await this._source.getTimeFieldName();
const geoField = await this._source.getGeoField();
const applyGlobalQuery = this._source.getApplyGlobalQuery();
const applyGlobalTime = this._source.getApplyGlobalTime();

const categoryField = this._style._descriptor.properties.categoryField;
let categoryFormatter = null;
Expand All @@ -91,6 +92,7 @@ export class DatashaderLayer extends AbstractLayer {
timeFieldName: timeFieldName,
geoField: geoField,
applyGlobalQuery: applyGlobalQuery,
applyGlobalTime: applyGlobalTime,
categoryFieldMeta: categoryFieldMeta,
categoryFieldFormatter: categoryFormatter
}
Expand Down Expand Up @@ -158,7 +160,9 @@ export class DatashaderLayer extends AbstractLayer {
let dataMeta = sourceDataRequest.getMeta();
if (dataMeta) {
const currentParamsObj = {};
currentParamsObj.timeFilters = dataMeta.timeFilters;
if (data.applyGlobalTime) {
currentParamsObj.timeFilters = dataMeta.timeFilters;
}
currentParamsObj.filters = []
if (data.applyGlobalQuery) {
currentParamsObj.filters = [...dataMeta.filters];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,11 @@ export class DatashaderSource extends AbstractTMSSource {
});
static icon = 'grid';

static createDescriptor({ urlTemplate, indexTitle, indexPatternId, timeFieldName, geoField, applyGlobalQuery }) {
static createDescriptor({ urlTemplate, indexTitle, indexPatternId, timeFieldName, geoField, applyGlobalQuery, applyGlobalTime }) {
return {
type: DatashaderSource.type,
applyGlobalQuery: applyGlobalQuery,
applyGlobalTime: applyGlobalTime,
urlTemplate,
indexTitle,
indexPatternId,
Expand All @@ -87,6 +88,7 @@ export class DatashaderSource extends AbstractTMSSource {
{
...descriptor,
applyGlobalQuery: _.get(descriptor, 'applyGlobalQuery', true),
applyGlobalTime: _.get(descriptor, 'applyGlobalTime', true),
},
inspectorAdapters
);
Expand Down Expand Up @@ -216,6 +218,14 @@ export class DatashaderSource extends AbstractTMSSource {
return [];
}

getApplyGlobalQuery() {
return this._descriptor.applyGlobalQuery;
}

getApplyGlobalTime() {
return this._descriptor.applyGlobalTime;
}

async getIndexPattern() {
if (this.indexPattern) {
return this.indexPattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export class DatashaderLegend extends React.Component {
}

const currentParamsObj = {};
currentParamsObj.timeFilters = dataMeta.timeFilters;
if (data.applyGlobalTime) {
currentParamsObj.timeFilters = dataMeta.timeFilters;
}
currentParamsObj.filters = []
if (data.applyGlobalQuery) {
currentParamsObj.filters = [...dataMeta.filters];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ import { getDatashader } from '../../../kibana_services';
export class DatashaderStyle {
static type = LAYER_STYLE_TYPE.DATASHADER;

constructor(descriptor = {}) {
constructor(descriptor = {}, source, layer) {
this._descriptor = DatashaderStyle.createDescriptor(descriptor.properties);
this._layer = layer;
this._source = source;
}

static createDescriptor(properties = {}, isTimeAware = true) {
Expand Down Expand Up @@ -51,7 +53,7 @@ export class DatashaderStyle {
return LAYER_STYLE_TYPE.DATASHADER;
}

renderEditor({ layer, onStyleDescriptorChange }) {
renderEditor(onStyleDescriptorChange) {
const rawProperties = this.getRawProperties();
const handlePropertyChange = (propertyName, settings) => {
rawProperties[propertyName] = settings; //override single property, but preserve the rest
Expand All @@ -76,7 +78,7 @@ export class DatashaderStyle {
settings={config}
properties={this._descriptor.properties}
handlePropertyChange={handlePropertyChange}
layer={layer}
layer={this._layer}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/maps/public/kibana_services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const getMapAppConfig = () => mapAppConfig;
export const getEnabled = () => getMapAppConfig().enabled;
export const getShowMapsInspectorAdapter = () => getMapAppConfig().showMapsInspectorAdapter;
export const getPreserveDrawingBuffer = () => getMapAppConfig().preserveDrawingBuffer;
export const getDatashader = () => _.get(getMapAppConfig(), 'datashader', {});

// map.* kibana.yml settings from maps_legacy plugin that are shared between OSS map visualizations and maps app
let kibanaCommonConfig: MapsLegacyConfig;
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/maps/public/selectors/map_selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export function createLayerInstance(
layerDescriptor: layerDescriptor as VectorLayerDescriptor,
source: source as IVectorSource,
});
case DatashaderLayer.type:
return new DatashaderLayer({ layerDescriptor, source });
default:
throw new Error(`Unrecognized layerType ${layerDescriptor.type}`);
}
Expand Down

0 comments on commit 000b2f7

Please sign in to comment.