Skip to content

Commit

Permalink
Merge branch 'master' into rebalanceXpackGroups
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 11, 2020
2 parents 8bc82cf + 4223658 commit 9b7c92d
Show file tree
Hide file tree
Showing 90 changed files with 1,889 additions and 2,848 deletions.
463 changes: 0 additions & 463 deletions docs/developer/visualize/development-create-visualization.asciidoc

This file was deleted.

This file was deleted.

27 changes: 16 additions & 11 deletions docs/developer/visualize/development-visualize-index.asciidoc
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
[[development-visualize-index]]
== Developing Visualizations

Kibana Visualizations are the easiest way to add additional functionality to Kibana.
This part of documentation is split into two parts.
The first part tells you all you need to know on how to embed existing Kibana Visualizations in your plugin.
The second step explains how to create your own custom visualization.

[IMPORTANT]
==============================================
These pages document internal APIs and are not guaranteed to be supported across future versions of Kibana.
However, these docs will be kept up-to-date to reflect the current implementation of Visualization plugins in Kibana.
These pages document internal APIs and are not guaranteed to be supported across future versions of Kibana.
==============================================

* <<development-embedding-visualizations>>
* <<development-create-visualization>>
The internal APIs for creating custom visualizations are in a state of heavy churn as
they are being migrated to the new Kibana platform, and large refactorings have been
happening across minor releases in the `7.x` series. In particular, in `7.5` and later
we have made significant changes to the legacy APIs as we work to gradually replace them.

As a result, starting in `7.5` we have removed the documentation for the legacy APIs
to prevent confusion. We expect to be able to create new documentation later in `7.x`
when the visualizations plugin has been completed.

include::development-embedding-visualizations.asciidoc[]
We would recommend waiting until later in `7.x` to upgrade your plugins if possible.
If you would like to keep up with progress on the visualizations plugin in the meantime,
here are a few resources:

include::development-create-visualization.asciidoc[]
* The <<breaking-changes,breaking changes>> documentation, where we try to capture any changes to the APIs as they occur across minors.
* link:https://github.com/elastic/kibana/issues/44121[Meta issue] which is tracking the move of the plugin to the new Kibana platform
* Our link:https://www.elastic.co/blog/join-our-elastic-stack-workspace-on-slack[Elastic Stack workspace on Slack].
* The {repo}blob/{branch}/src/plugins/visualizations[source code], which will continue to be
the most accurate source of information.
2 changes: 0 additions & 2 deletions docs/visualize/aggregations.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ You can also nest these aggregations. For example, if you want to produce a thir

{ref}/search-aggregations-pipeline-serialdiff-aggregation.html[Serial diff]:: Values in a time series are subtracted from itself at different time lags or periods.

Custom {kib} plugins can <<development-visualize-index, add more capabilities to the default editor>>, which includes support for adding more aggregations.

[float]
[[visualize-sibling-pipeline-aggregations]]
=== Sibling pipeline aggregations
Expand Down
15 changes: 11 additions & 4 deletions x-pack/legacy/plugins/maps/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,16 @@ export const COLOR_PALETTE_MAX_SIZE = 10;
export const CATEGORICAL_DATA_TYPES = ['string', 'ip', 'boolean'];
export const ORDINAL_DATA_TYPES = ['number', 'date'];

export const SYMBOLIZE_AS_TYPES = {
CIRCLE: 'circle',
ICON: 'icon',
};
export enum SYMBOLIZE_AS_TYPES {
CIRCLE = 'circle',
ICON = 'icon',
}

export enum LABEL_BORDER_SIZES {
NONE = 'NONE',
SMALL = 'SMALL',
MEDIUM = 'MEDIUM',
LARGE = 'LARGE',
}

export const DEFAULT_ICON = 'airfield';
123 changes: 123 additions & 0 deletions x-pack/legacy/plugins/maps/common/style_property_descriptor_types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/* eslint-disable @typescript-eslint/consistent-type-definitions */

import { FIELD_ORIGIN, LABEL_BORDER_SIZES, SYMBOLIZE_AS_TYPES } from './constants';

// Non-static/dynamic options
export type SymbolizeAsOptions = {
value: SYMBOLIZE_AS_TYPES;
};

export type LabelBorderSizeOptions = {
size: LABEL_BORDER_SIZES;
};

// Static/dynamic options

export type FieldMetaOptions = {
isEnabled: boolean;
sigma?: number;
};

export type StylePropertyField = {
name: string;
origin: FIELD_ORIGIN;
};

export type OrdinalColorStop = {
stop: number;
color: string;
};

export type CategoryColorStop = {
stop: string | null;
color: string;
};

export type IconStop = {
stop: string | null;
icon: string;
};

export type ColorDynamicOptions = {
// ordinal color properties
color: string; // TODO move color category ramps to constants and make ENUM type
customColorRamp?: OrdinalColorStop[];
useCustomColorRamp?: boolean;

// category color properties
colorCategory?: string; // TODO move color category palettes to constants and make ENUM type
customColorPalette?: CategoryColorStop[];
useCustomColorPalette?: boolean;

field?: StylePropertyField;
fieldMetaOptions: FieldMetaOptions;
};

export type ColorStaticOptions = {
color: string;
};

export type IconDynamicOptions = {
iconPaletteId?: string;
customIconStops?: IconStop[];
useCustomIconMap?: boolean;
field?: StylePropertyField;
fieldMetaOptions: FieldMetaOptions;
};

export type IconStaticOptions = {
value: string; // icon id
};

export type LabelDynamicOptions = {
field: StylePropertyField; // field containing label value
};

export type LabelStaticOptions = {
value: string; // static label text
};

export type OrientationDynamicOptions = {
field?: StylePropertyField;
fieldMetaOptions: FieldMetaOptions;
};

export type OrientationStaticOptions = {
orientation: number;
};

export type SizeDynamicOptions = {
minSize: number;
maxSize: number;
field?: StylePropertyField;
fieldMetaOptions: FieldMetaOptions;
};

export type SizeStaticOptions = {
size: number;
};

export type StylePropertyOptions =
| LabelBorderSizeOptions
| SymbolizeAsOptions
| DynamicStylePropertyOptions
| StaticStylePropertyOptions;

export type StaticStylePropertyOptions =
| ColorStaticOptions
| IconStaticOptions
| LabelStaticOptions
| OrientationStaticOptions
| SizeStaticOptions;

export type DynamicStylePropertyOptions =
| ColorDynamicOptions
| IconDynamicOptions
| LabelDynamicOptions
| OrientationDynamicOptions
| SizeDynamicOptions;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IVectorSource extends ISource {
): Promise<GeoJsonWithMeta>;

getFields(): Promise<IField[]>;
getFieldByName(fieldName: string): IField;
}

export class AbstractVectorSource extends AbstractSource {
Expand All @@ -38,4 +39,5 @@ export class AbstractVectorSource extends AbstractSource {
): Promise<GeoJsonWithMeta>;

getFields(): Promise<IField[]>;
getFieldByName(fieldName: string): IField;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/* eslint-disable @typescript-eslint/consistent-type-definitions */

import _ from 'lodash';
import React from 'react';
import { EuiFormRow, EuiSwitch, EuiSwitchEvent } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FieldMetaPopover } from './field_meta_popover';
import { IDynamicStyleProperty } from '../../properties/dynamic_style_property';
import { FieldMetaOptions } from '../../../../../../common/style_property_descriptor_types';

type Props = {
styleProperty: IDynamicStyleProperty;
onChange: (fieldMetaOptions: FieldMetaOptions) => void;
};

export function CategoricalFieldMetaPopover(props: Props) {
const onIsEnabledChange = (event: EuiSwitchEvent) => {
props.onChange({
...props.styleProperty.getFieldMetaOptions(),
isEnabled: event.target.checked,
});
};

return (
<FieldMetaPopover>
<EuiFormRow display="columnCompressedSwitch">
<EuiSwitch
label={i18n.translate('xpack.maps.styles.fieldMetaOptions.isEnabled.categoricalLabel', {
defaultMessage: 'Get categories from indices',
})}
checked={props.styleProperty.getFieldMetaOptions().isEnabled}
onChange={onIsEnabledChange}
compressed
/>
</EuiFormRow>
</FieldMetaPopover>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
/* eslint-disable @typescript-eslint/consistent-type-definitions */

import React, { Component, ReactElement } from 'react';
import { EuiButtonIcon, EuiPopover } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

type Props = {
children: ReactElement<any>;
};

type State = {
isPopoverOpen: boolean;
};

export class FieldMetaPopover extends Component<Props, State> {
state = {
isPopoverOpen: false,
};

_togglePopover = () => {
this.setState({
isPopoverOpen: !this.state.isPopoverOpen,
});
};

_closePopover = () => {
this.setState({
isPopoverOpen: false,
});
};

_renderButton() {
return (
<EuiButtonIcon
onClick={this._togglePopover}
size="s"
iconType="gear"
aria-label={i18n.translate('xpack.maps.styles.fieldMetaOptions.popoverToggle', {
defaultMessage: 'Field meta options popover toggle',
})}
/>
);
}

render() {
return (
<EuiPopover
id="fieldMetaOptionsPopover"
anchorPosition="leftCenter"
button={this._renderButton()}
isOpen={this.state.isPopoverOpen}
closePopover={this._closePopover}
ownFocus
>
{this.props.children}
</EuiPopover>
);
}
}
Loading

0 comments on commit 9b7c92d

Please sign in to comment.