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

[Vis: Default editor] Euification of Metric options tab #46930

Merged
merged 35 commits into from
Oct 8, 2019
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
afe52aa
EUIficate heatmap options
sulemanof Sep 2, 2019
f9b3961
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 16, 2019
aa5908f
Move collections
sulemanof Sep 16, 2019
3aa727a
Split labels in a panel
sulemanof Sep 17, 2019
2aba289
Remove angular templates
sulemanof Sep 17, 2019
bcf83b9
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 17, 2019
5a38e6c
Remove unused translations
sulemanof Sep 17, 2019
d22fe0e
Fix functional tests
sulemanof Sep 18, 2019
58d8a59
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 18, 2019
16afb0d
Fix validation
sulemanof Sep 18, 2019
ce89e49
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 19, 2019
f99b900
Fix UI details
sulemanof Sep 19, 2019
345fc4c
Compress color picker
sulemanof Sep 19, 2019
f123a4f
Change highlight label
sulemanof Sep 19, 2019
9562d72
Improve types
sulemanof Sep 20, 2019
96edb3d
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 20, 2019
a3078b1
Merge branch 'master' into EUIfication/options/heatmap
elasticmachine Sep 23, 2019
9ea7d72
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 25, 2019
75c266b
Fix comments
sulemanof Sep 25, 2019
225e0b8
Merge branch 'EUIfication/options/heatmap' of github.com:sulemanof/ki…
sulemanof Sep 25, 2019
7563c8b
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 26, 2019
a7c1f96
Replace headings h2 with h3
sulemanof Sep 26, 2019
50eaf23
Add functional tests
sulemanof Sep 26, 2019
ea0d897
Create setCustomRangeByIndex
sulemanof Sep 26, 2019
e119c16
Merge remote-tracking branch 'upstream/master' into EUIfication/optio…
sulemanof Sep 27, 2019
540ddcd
EUIfication of metric_vis_options
sulemanof Sep 30, 2019
71dbb3d
Merge remote-tracking branch 'upstream/master' into EUIfiaction/optio…
sulemanof Sep 30, 2019
662c940
Small fixes
sulemanof Sep 30, 2019
ca3f1fe
Remove unused translations
sulemanof Sep 30, 2019
747c93d
Fix style comments
sulemanof Oct 1, 2019
b487187
Remove unused styles
sulemanof Oct 1, 2019
5ab5a0e
Merge remote-tracking branch 'upstream/master' into EUIfiaction/optio…
sulemanof Oct 2, 2019
717310f
Update the separation of the panels
sulemanof Oct 2, 2019
a060a2e
Add style type
sulemanof Oct 3, 2019
02395e0
Merge branch 'master' into EUIfiaction/options/metrics
elasticmachine Oct 7, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

export { BasicOptions } from './basic_options';
export { ColorRanges } from './color_ranges';
export { ColorSchemaOptions } from './color_schema';
export { ColorSchemaOptions, SetColorSchemaOptionsValue } from './color_schema';
export { NumberInputOption } from './number_input';
export { RangeOption } from './range';
export { SelectOption } from './select';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { EuiFormRow, EuiFieldNumber } from '@elastic/eui';

interface TruncateLabelsOptionProps {
disabled?: boolean;
value: number | null;
value?: number | null;
setValue: (paramName: 'truncate', value: null | number) => void;
}

function TruncateLabelsOption({ disabled, value, setValue }: TruncateLabelsOptionProps) {
function TruncateLabelsOption({ disabled, value = null, setValue }: TruncateLabelsOptionProps) {
const onChange = (ev: ChangeEvent<HTMLInputElement>) =>
setValue('truncate', ev.target.value === '' ? null : parseFloat(ev.target.value));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,13 @@ function HeatmapOptions(props: VisOptionsProps<HeatmapVisParams>) {
/>

{stateParams.setColorRange && (
<>
<EuiSpacer size="s" />
<ColorRanges
data-test-subj="heatmapColorRange"
colorsRange={stateParams.colorsRange}
setValue={setValue}
setTouched={setTouched}
setValidity={setIsColorRangesValid}
/>
</>
<ColorRanges
data-test-subj="heatmapColorRange"
colorsRange={stateParams.colorsRange}
setValue={setValue}
setTouched={setTouched}
setValidity={setIsColorRangesValid}
/>
)}
</EuiPanel>

Expand Down
10 changes: 3 additions & 7 deletions src/legacy/core_plugins/kbn_vislib_vis_types/public/gauge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import { RangeValues } from 'ui/vis/editors/default/controls/ranges';
import { Alignments, GaugeTypes } from './utils/collections';
import { ColorSchemaVislibParams } from './types';
import { ColorSchemaVislibParams, Labels, Style } from './types';

interface Gauge extends ColorSchemaVislibParams {
backStyle: 'Full';
Expand All @@ -30,18 +30,14 @@ interface Gauge extends ColorSchemaVislibParams {
colorsRange: RangeValues[];
extendRange: boolean;
gaugeType: GaugeTypes;
labels: {
show: boolean;
};
labels: Labels;
percentageMode: boolean;
scale: {
show: boolean;
labels: false;
color: 'rgba(105,112,125,0.2)';
};
style: {
subText: string;
};
style: Style;
}

export interface GaugeVisParams {
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/kbn_vislib_vis_types/public/gauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { Schemas } from 'ui/vis/editors/default/schemas';
import { AggGroupNames } from 'ui/vis/editors/default';
import { ColorSchemas } from 'ui/vislib/components/color/colormaps';
import { GaugeOptions } from './components/options';
import { getGaugeCollections, Alignments, GaugeColorModes, GaugeTypes } from './utils/collections';
import { getGaugeCollections, Alignments, ColorModes, GaugeTypes } from './utils/collections';
import { vislibVisController } from './controller';

export default function GaugeVisType() {
Expand All @@ -49,7 +49,7 @@ export default function GaugeVisType() {
backStyle: 'Full',
orientation: 'vertical',
colorSchema: ColorSchemas.GreenToRed,
gaugeColorMode: GaugeColorModes.LABELS,
gaugeColorMode: ColorModes.LABELS,
colorsRange: [
{ from: 0, to: 50 },
{ from: 50, to: 75 },
Expand Down
4 changes: 2 additions & 2 deletions src/legacy/core_plugins/kbn_vislib_vis_types/public/goal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { Schemas } from 'ui/vis/editors/default/schemas';
import { AggGroupNames } from 'ui/vis/editors/default';
import { ColorSchemas } from 'ui/vislib/components/color/colormaps';
import { GaugeOptions } from './components/options';
import { getGaugeCollections, GaugeTypes, GaugeColorModes } from './utils/collections';
import { getGaugeCollections, GaugeTypes, ColorModes } from './utils/collections';
import { vislibVisController } from './controller';
import { visFactory } from '../../../ui/public/vis/vis_factory';

Expand Down Expand Up @@ -52,7 +52,7 @@ export default function GoalVisType() {
orientation: 'vertical',
useRanges: false,
colorSchema: ColorSchemas.GreenToRed,
gaugeColorMode: GaugeColorModes.NONE,
gaugeColorMode: ColorModes.NONE,
colorsRange: [
{ from: 0, to: 10000 }
],
Expand Down
18 changes: 13 additions & 5 deletions src/legacy/core_plugins/kbn_vislib_vis_types/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,21 @@ export interface ColorSchemaVislibParams {
invertColors: boolean;
}

interface Labels {
color: string;
filter: boolean;
export interface Labels {
color?: string;
filter?: boolean;
overwriteColor?: boolean;
rotate?: Rotates;
show: boolean;
truncate: number | null;
truncate?: number | null;
}

export interface Style {
bgFill: string;
bgColor: boolean;
labelColor: boolean;
subText: string;
fontSize: number;
}

export interface Scale {
Expand All @@ -74,7 +82,7 @@ export interface Axis {
position: Positions;
scale: Scale;
show: boolean;
style: object;
style: Style;
title: { text: string };
type: AxisTypes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ export enum GaugeTypes {
CIRCLE = 'Circle',
}

export enum GaugeColorModes {
export enum ColorModes {
BACKGROUND = 'Background',
LABELS = 'Labels',
NONE = 'None',
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
/*
* 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, { useCallback } from 'react';
import { EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';

import { VisOptionsProps } from 'ui/vis/editors/default';
import {
ColorRanges,
ColorSchemaOptions,
SelectOption,
SwitchOption,
RangeOption,
SetColorSchemaOptionsValue,
} from '../../../kbn_vislib_vis_types/public/components';
import { ColorModes } from '../../../kbn_vislib_vis_types/public/utils/collections';
import { MetricVisParam, VisParams } from '../types';

function MetricVisOptions({
stateParams,
setValue,
setValidity,
setTouched,
vis,
uiState,
}: VisOptionsProps<VisParams>) {
const setMetricValue: <T extends keyof MetricVisParam>(
paramName: T,
value: MetricVisParam[T]
) => void = useCallback(
(paramName, value) =>
setValue('metric', {
...stateParams.metric,
[paramName]: value,
}),
[setValue, stateParams.metric]
);

const setMetricLabels: <T extends keyof MetricVisParam['labels']>(
paramName: T,
value: MetricVisParam['labels'][T]
) => void = useCallback(
(paramName, value) =>
setMetricValue('labels', {
...stateParams.metric.labels,
[paramName]: value,
}),
[setMetricValue, stateParams.metric.labels]
);

const setMetricStyle: <T extends keyof MetricVisParam['style']>(
paramName: T,
value: MetricVisParam['style'][T]
) => void = useCallback(
(paramName, value) =>
setMetricValue('style', {
...stateParams.metric.style,
[paramName]: value,
}),
[setMetricValue, stateParams.metric.style]
);

return (
<>
<EuiPanel paddingSize="s">
<EuiTitle size="xs">
<h3>
<FormattedMessage id="visTypeMetric.params.rangesTitle" defaultMessage="Ranges" />
</h3>
</EuiTitle>
<EuiSpacer size="s" />

<ColorRanges
data-test-subj="metricColorRange"
colorsRange={stateParams.metric.colorsRange}
setValue={setMetricValue}
setTouched={setTouched}
setValidity={setValidity}
/>

<SwitchOption
label={i18n.translate('visTypeMetric.params.percentageModeLabel', {
defaultMessage: 'Percentage mode',
})}
paramName="percentageMode"
value={stateParams.metric.percentageMode}
setValue={setMetricValue}
/>
<EuiSpacer size="m" />

<EuiTitle size="xs">
<h3>
<FormattedMessage
id="visTypeMetric.params.color.colorOptionsTitle"
defaultMessage="Color options"
/>
</h3>
</EuiTitle>
<EuiSpacer size="s" />

<SelectOption
disabled={stateParams.metric.colorsRange.length === 1}
label={i18n.translate('visTypeMetric.params.color.useForLabel', {
defaultMessage: 'Use color for',
})}
options={vis.type.editorConfig.collections.metricColorMode}
paramName="metricColorMode"
value={stateParams.metric.metricColorMode}
setValue={setMetricValue}
/>

<ColorSchemaOptions
colorSchema={stateParams.metric.colorSchema}
colorSchemas={vis.type.editorConfig.collections.colorSchemas}
disabled={
stateParams.metric.colorsRange.length === 1 ||
stateParams.metric.metricColorMode === ColorModes.NONE
}
invertColors={stateParams.metric.invertColors}
setValue={setMetricValue as SetColorSchemaOptionsValue}
uiState={uiState}
/>
</EuiPanel>

<EuiSpacer size="s" />

<EuiPanel paddingSize="s">
<EuiTitle size="xs">
<h3>
<FormattedMessage id="visTypeMetric.params.style.styleTitle" defaultMessage="Style" />
</h3>
</EuiTitle>
<EuiSpacer size="s" />

<SwitchOption
label={i18n.translate('visTypeMetric.params.showLabelsLabel', {
defaultMessage: 'Show labels',
})}
paramName="show"
value={stateParams.metric.labels.show}
setValue={setMetricLabels}
/>

<RangeOption
label={i18n.translate('visTypeMetric.params.style.fontSizeLabel', {
defaultMessage: 'Font size in points',
})}
min={12}
max={120}
paramName="fontSize"
value={stateParams.metric.style.fontSize}
setValue={setMetricStyle}
/>
</EuiPanel>
</>
);
}

export { MetricVisOptions };

This file was deleted.

Loading