diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/area.js b/src/legacy/core_plugins/kbn_vislib_vis_types/public/area.js
index a33d333867e62..435fc7d14528e 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/area.js
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/area.js
@@ -20,7 +20,8 @@
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { i18n } from '@kbn/i18n';
import { Schemas } from 'ui/vis/editors/default/schemas';
-import pointSeriesTemplate from './editors/point_series.html';
+import { PointSeriesOptions } from './editors/point_series';
+import { getLegendPositions, LegendPositions } from './utils/legend_positions';
export default function PointSeriesVisType(Private) {
const VisFactory = Private(VisFactoryProvider);
@@ -93,13 +94,15 @@ export default function PointSeriesVisType(Private) {
}],
addTooltip: true,
addLegend: true,
- legendPosition: 'right',
+ legendPosition: LegendPositions.RIGHT,
times: [],
addTimeMarker: false,
+ labels: {},
},
},
editorConfig: {
collections: {
+ legendPositions: getLegendPositions(),
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
value: 'line',
@@ -132,7 +135,7 @@ export default function PointSeriesVisType(Private) {
editor: '
' +
'
'
},
- { name: 'options', title: 'Panel Settings', editor: pointSeriesTemplate },
+ { name: 'options', title: 'Panel Settings', editor: PointSeriesOptions },
],
schemas: new Schemas([
{
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html
deleted file mode 100644
index 73832f7b741bb..0000000000000
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.html
+++ /dev/null
@@ -1,59 +0,0 @@
-
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.js b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.js
deleted file mode 100644
index c0635d949115d..0000000000000
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid.js
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to Elasticsearch B.V. under one or more contributor
- * license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright
- * ownership. Elasticsearch B.V. licenses this file to you under
- * the Apache License, Version 2.0 (the "License"); you may
- * not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import { uiModules } from 'ui/modules';
-import vislibGridTemplate from './grid.html';
-const module = uiModules.get('kibana');
-
-module.directive('vislibGrid', function () {
- return {
- restrict: 'E',
- template: vislibGridTemplate,
- replace: true,
- link: function ($scope) {
-
- $scope.isGridOpen = true;
- }
- };
-});
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid_options.tsx b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid_options.tsx
new file mode 100644
index 0000000000000..069a2a0dcbeab
--- /dev/null
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/grid_options.tsx
@@ -0,0 +1,107 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React, { useMemo, useEffect } from 'react';
+import { EuiPanel, EuiTitle } from '@elastic/eui';
+import { i18n } from '@kbn/i18n';
+import { FormattedMessage } from '@kbn/i18n/react';
+
+import { VisOptionsProps } from 'ui/vis/editors/default';
+import { SwitchOption } from '../switch';
+import { SelectOption } from '../select';
+import { BasicVislibParams, ValueAxis } from '../../types';
+
+function GridOptions({
+ stateParams,
+ setValue,
+ hasHistogramAgg,
+}: VisOptionsProps) {
+ const setGrid = (
+ paramName: T,
+ value: BasicVislibParams['grid'][T]
+ ) => setValue('grid', { ...stateParams.grid, [paramName]: value });
+
+ const options = useMemo(
+ () => [
+ ...stateParams.valueAxes.map(({ id, name }: ValueAxis) => ({
+ text: name,
+ value: id,
+ })),
+ {
+ text: i18n.translate('kbnVislibVisTypes.controls.pointSeries.gridAxis.dontShowLabel', {
+ defaultMessage: "Don't show",
+ }),
+ value: '',
+ },
+ ],
+ [stateParams.valueAxes.map(({ id }: ValueAxis) => id)]
+ );
+
+ useEffect(() => {
+ if (hasHistogramAgg) {
+ setGrid('categoryLines', false);
+ }
+ }, [hasHistogramAgg]);
+
+ return (
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export { GridOptions };
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/index.js b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/index.js
index 599a99b921486..87289e9aa410d 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/index.js
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/point_series/index.js
@@ -20,4 +20,3 @@
import './value_axes.js';
import './category_axis.js';
import './series.js';
-import './grid.js';
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/select.tsx b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/select.tsx
index 01c6a576d4d1b..0a0aeeb26dcef 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/select.tsx
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/controls/select.tsx
@@ -21,14 +21,17 @@ import React from 'react';
import { EuiFormRow, EuiSelect } from '@elastic/eui';
interface SelectOptionProps {
+ id?: string;
label: string;
options: Array<{ value: ValidParamValues; text: string }>;
paramName: ParamName;
value?: ValidParamValues;
+ dataTestSubj?: string;
setValue: (paramName: ParamName, value: ValidParamValues) => void;
}
function SelectOption({
+ id,
label,
options,
paramName,
@@ -36,7 +39,7 @@ function SelectOption
setValue,
}: SelectOptionProps) {
return (
-
+
-
-
-
-
\ No newline at end of file
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/editors/point_series.tsx b/src/legacy/core_plugins/kbn_vislib_vis_types/public/editors/point_series.tsx
new file mode 100644
index 0000000000000..fcff704878fed
--- /dev/null
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/editors/point_series.tsx
@@ -0,0 +1,89 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import React from 'react';
+import { EuiPanel, EuiTitle, EuiSpacer } from '@elastic/eui';
+import { i18n } from '@kbn/i18n';
+import { FormattedMessage } from '@kbn/i18n/react';
+
+import { VisOptionsProps } from 'ui/vis/editors/default';
+import { SwitchOption } from '../controls/switch';
+import { GridOptions } from '../controls/point_series/grid_options';
+import { BasicOptions } from '../controls/basic_options';
+import { BasicVislibParams } from '../types';
+
+function PointSeriesOptions(props: VisOptionsProps) {
+ const { stateParams, setValue, vis } = props;
+
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+ {vis.hasSchemaAgg('segment', 'date_histogram') ? (
+
+ ) : (
+
+ )}
+
+ {vis.type.type === 'histogram' && (
+
+ setValue('labels', { ...stateParams.labels, [paramName]: value })
+ }
+ />
+ )}
+
+
+
+
+
+ >
+ );
+}
+
+export { PointSeriesOptions };
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/histogram.js b/src/legacy/core_plugins/kbn_vislib_vis_types/public/histogram.js
index 07ddbcb941fdc..4c699ab22ed62 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/histogram.js
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/histogram.js
@@ -20,7 +20,8 @@
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { i18n } from '@kbn/i18n';
import { Schemas } from 'ui/vis/editors/default/schemas';
-import pointSeriesTemplate from './editors/point_series.html';
+import { PointSeriesOptions } from './editors/point_series';
+import { getLegendPositions, LegendPositions } from './utils/legend_positions';
export default function PointSeriesVisType(Private) {
const VisFactory = Private(VisFactoryProvider);
@@ -95,7 +96,7 @@ export default function PointSeriesVisType(Private) {
],
addTooltip: true,
addLegend: true,
- legendPosition: 'right',
+ legendPosition: LegendPositions.RIGHT,
times: [],
addTimeMarker: false,
labels: {
@@ -105,6 +106,7 @@ export default function PointSeriesVisType(Private) {
},
editorConfig: {
collections: {
+ legendPositions: getLegendPositions(),
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
value: 'line',
@@ -137,7 +139,7 @@ export default function PointSeriesVisType(Private) {
editor: '' +
'
'
},
- { name: 'options', title: 'Panel Settings', editor: pointSeriesTemplate },
+ { name: 'options', title: 'Panel Settings', editor: PointSeriesOptions },
],
schemas: new Schemas([
{
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js b/src/legacy/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js
index 5707b32b2c395..c3f0b6ab0c8a9 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/horizontal_bar.js
@@ -20,7 +20,8 @@
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { i18n } from '@kbn/i18n';
import { Schemas } from 'ui/vis/editors/default/schemas';
-import pointSeriesTemplate from './editors/point_series.html';
+import { PointSeriesOptions } from './editors/point_series';
+import { getLegendPositions, LegendPositions } from './utils/legend_positions';
export default function PointSeriesVisType(Private) {
const VisFactory = Private(VisFactoryProvider);
@@ -96,13 +97,15 @@ export default function PointSeriesVisType(Private) {
}],
addTooltip: true,
addLegend: true,
- legendPosition: 'right',
+ legendPosition: LegendPositions.RIGHT,
times: [],
addTimeMarker: false,
+ labels: {},
},
},
editorConfig: {
collections: {
+ legendPositions: getLegendPositions(),
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
value: 'line',
@@ -135,7 +138,7 @@ export default function PointSeriesVisType(Private) {
editor: '' +
'
'
},
- { name: 'options', title: 'Panel Settings', editor: pointSeriesTemplate },
+ { name: 'options', title: 'Panel Settings', editor: PointSeriesOptions },
],
schemas: new Schemas([
{
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/line.js b/src/legacy/core_plugins/kbn_vislib_vis_types/public/line.js
index e7c84fb6fc1ce..5261b757a7820 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/line.js
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/line.js
@@ -20,7 +20,8 @@
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { i18n } from '@kbn/i18n';
import { Schemas } from 'ui/vis/editors/default/schemas';
-import pointSeriesTemplate from './editors/point_series.html';
+import { PointSeriesOptions } from './editors/point_series';
+import { getLegendPositions, LegendPositions } from './utils/legend_positions';
export default function PointSeriesVisType(Private) {
const VisFactory = Private(VisFactoryProvider);
@@ -93,13 +94,15 @@ export default function PointSeriesVisType(Private) {
],
addTooltip: true,
addLegend: true,
- legendPosition: 'right',
+ legendPosition: LegendPositions.RIGHT,
times: [],
addTimeMarker: false,
+ labels: {},
},
},
editorConfig: {
collections: {
+ legendPositions: getLegendPositions(),
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
value: 'line',
@@ -132,7 +135,7 @@ export default function PointSeriesVisType(Private) {
editor: '' +
'
'
},
- { name: 'options', title: 'Panel Settings', editor: pointSeriesTemplate },
+ { name: 'options', title: 'Panel Settings', editor: PointSeriesOptions },
],
schemas: new Schemas([
{
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/types.ts b/src/legacy/core_plugins/kbn_vislib_vis_types/public/types.ts
index 8bf941d8b9458..05d049d1c9e1e 100644
--- a/src/legacy/core_plugins/kbn_vislib_vis_types/public/types.ts
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/types.ts
@@ -17,7 +17,38 @@
* under the License.
*/
+import { LegendPositions } from './utils/legend_positions';
+
export interface CommonVislibParams {
addTooltip: boolean;
- legendPosition: 'right' | 'left' | 'top' | 'bottom';
+ legendPosition: LegendPositions;
+}
+
+interface Labels {
+ filter: boolean;
+ rotate?: number;
+ show: boolean;
+ truncate: number;
+}
+export interface ValueAxis {
+ id: string;
+ labels: Labels;
+ name: string;
+ position: LegendPositions;
+ scale: { type: string };
+ show: boolean;
+ style: object;
+ title: { text: string };
+ type: string;
+}
+
+export interface BasicVislibParams extends CommonVislibParams {
+ addTimeMarker: boolean;
+ orderBucketsBySum?: boolean;
+ labels: Labels;
+ valueAxes: ValueAxis[];
+ grid: {
+ categoryLines: boolean;
+ valueAxis?: string;
+ };
}
diff --git a/src/legacy/core_plugins/kbn_vislib_vis_types/public/utils/legend_positions.ts b/src/legacy/core_plugins/kbn_vislib_vis_types/public/utils/legend_positions.ts
new file mode 100644
index 0000000000000..ffe70eba19b39
--- /dev/null
+++ b/src/legacy/core_plugins/kbn_vislib_vis_types/public/utils/legend_positions.ts
@@ -0,0 +1,56 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you under
+ * the Apache License, Version 2.0 (the "License"); you may
+ * not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import { i18n } from '@kbn/i18n';
+
+export enum LegendPositions {
+ RIGHT = 'right',
+ LEFT = 'left',
+ TOP = 'top',
+ BOTTOM = 'bottom',
+}
+
+const getLegendPositions = () => [
+ {
+ text: i18n.translate('kbnVislibVisTypes.legendPositions.topText', {
+ defaultMessage: 'Top',
+ }),
+ value: LegendPositions.TOP,
+ },
+ {
+ text: i18n.translate('kbnVislibVisTypes.legendPositions.leftText', {
+ defaultMessage: 'Left',
+ }),
+ value: LegendPositions.LEFT,
+ },
+ {
+ text: i18n.translate('kbnVislibVisTypes.legendPositions.rightText', {
+ defaultMessage: 'Right',
+ }),
+ value: LegendPositions.RIGHT,
+ },
+ {
+ text: i18n.translate('kbnVislibVisTypes.legendPositions.bottomText', {
+ defaultMessage: 'Bottom',
+ }),
+ value: LegendPositions.BOTTOM,
+ },
+];
+
+export { getLegendPositions };
diff --git a/src/legacy/ui/public/vis/editors/default/default.js b/src/legacy/ui/public/vis/editors/default/default.js
index da8ab50b7805c..af0ebc65680c3 100644
--- a/src/legacy/ui/public/vis/editors/default/default.js
+++ b/src/legacy/ui/public/vis/editors/default/default.js
@@ -126,7 +126,9 @@ const defaultEditor = function ($rootScope, $compile) {
return $scope.vis.getSerializableState($scope.state);
}, function (newState) {
$scope.vis.dirty = !angular.equals(newState, $scope.oldState);
- $scope.metricAggs = $scope.state.aggs.getResponseAggs().filter(agg =>
+ const responseAggs = $scope.state.aggs.getResponseAggs();
+ $scope.hasHistogramAgg = responseAggs.some(agg => agg.type.name === 'histogram');
+ $scope.metricAggs = responseAggs.filter(agg =>
_.get(agg, 'schema.group') === AggGroupNames.Metrics);
const lastParentPipelineAgg = _.findLast($scope.metricAggs, ({ type }) => type.subtype === parentPipelineAggHelper.subtype);
$scope.lastParentPipelineAggTitle = lastParentPipelineAgg && lastParentPipelineAgg.type.title;
diff --git a/src/legacy/ui/public/vis/editors/default/sidebar.html b/src/legacy/ui/public/vis/editors/default/sidebar.html
index 14e9bd46c376d..07c2e2b1730ee 100644
--- a/src/legacy/ui/public/vis/editors/default/sidebar.html
+++ b/src/legacy/ui/public/vis/editors/default/sidebar.html
@@ -175,6 +175,7 @@