Skip to content

Commit

Permalink
[Vis: Default Editor] EUIficate 'Metrics & Axis' tab (#43772)
Browse files Browse the repository at this point in the history
* EUIficate pointe-series and grid

* Apply TS

* Show grid on a panel

* Remove extra space

* Add TS

* Use BasicOptions

* Adjust func test

* Add dataTestSubj prop to SelectOption

* Use id instead of data-sest-subj

* Disable show x-axis lines when there is histogram agg

* Add tooltip for disabled 'Show x-axis lines' config

* Add series_options.tsx

* Migrate series

* Improve changeValueAxis

* Create CategoryAxisPanel

* Create ValueAxesPanel

* Create CustomExtentsOptions

* File renaming

* Use TruncateLabelsOption

* Set min value

* Add validation

* Refactoring

* Move types upper

* Convert series logic

* Convert valueAxes logic

* Rename function

* Add validation and refactoring

* Adjust styles

* Fix rotates

* Apply config for other vis

* Remove old directives

* Fix useHook usage

* Update vislib_vis_type.js

* Fix

* Move Threshold line panel into a separate component

* Remove unused translations

* Apply ui suggestions

* Update functional tests

* Remove angular unit test

* Refactoring

* Fix dependencies

* Refactoring

* Add validation

* Add validation for other vis

* Refactoring of onPositionChanged handler

* Refactoring of addValueAxis

* Get rid of a useEffect

* Refactoring of updateAxisTitle

* Update useCallback

* Refactoring

* Refactoring of collections config

* Refactoring of setChartValueByIndex and setValueAxisByIndex

* Update metrics_axes_options.tsx

* Watch current tab for correct accordion height

* Revert axis title logic

* Fix axis id and name number

* Fix code review comments

* Fix functional tests

* Update visualize_page.js

* Move option tabs in common

* Fix code review comments

* Update index.tsx

* Refactoring

* Fix merge conflict

* Show ThresholdPanel when it's configured

* Fix passing a current tab to vis-options

* Localize 'Count' text

* Pass one axis to CategoryAxisPanel

* Fix y-axis name number when x-axis position changed

* Fix Y-axis name number when position Y-axis changed

* Fix refresh loop

* Re-organize controls

* Apply code review comments

* Refactoring

* Fix extents empty value

* Update y_extents.tsx

* Fix code review comments

* Fix updating several seriesParams when removing axis

* Add thresholdLine config to horizontal bar

* Refactoring

* Reset grid.valueAxis when the axis deleted

* Fix refresh loop

* Set interpolate config for line

* Enable "show dots"
  • Loading branch information
maryia-lapata authored Sep 13, 2019
1 parent 680d846 commit 1223ab9
Show file tree
Hide file tree
Showing 50 changed files with 2,412 additions and 1,699 deletions.
116 changes: 49 additions & 67 deletions src/legacy/core_plugins/kbn_vislib_vis_types/public/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,25 @@
import { VisFactoryProvider } from 'ui/vis/vis_factory';
import { i18n } from '@kbn/i18n';
import { Schemas } from 'ui/vis/editors/default/schemas';
import { PointSeriesOptions } from './components/options';
import { getLegendPositions, LegendPositions } from './utils/legend_positions';
import { AggGroupNames } from 'ui/vis/editors/default';
import {
Positions,
ChartTypes,
ChartModes,
InterpolationModes,
AxisTypes,
ScaleTypes,
AxisModes,
Rotates,
ThresholdLineStyles,
getConfigCollections,
} from './utils/collections';
import { getAreaOptionTabs, getCountLabel } from './utils/common_config';
import { palettes } from '@elastic/eui/lib/services';

export default function PointSeriesVisType(Private) {
const VisFactory = Private(VisFactoryProvider);
const countLabel = getCountLabel();

return VisFactory.createVislibVisualization({
name: 'area',
Expand All @@ -42,12 +55,12 @@ export default function PointSeriesVisType(Private) {
categoryAxes: [
{
id: 'CategoryAxis-1',
type: 'category',
position: 'bottom',
type: AxisTypes.CATEGORY,
position: Positions.BOTTOM,
show: true,
style: {},
scale: {
type: 'linear'
type: ScaleTypes.LINEAR,
},
labels: {
show: true,
Expand All @@ -61,93 +74,62 @@ export default function PointSeriesVisType(Private) {
{
id: 'ValueAxis-1',
name: 'LeftAxis-1',
type: 'value',
position: 'left',
type: AxisTypes.VALUE,
position: Positions.LEFT,
show: true,
style: {},
scale: {
type: 'linear',
mode: 'normal'
type: ScaleTypes.LINEAR,
mode: AxisModes.NORMAL,
},
labels: {
show: true,
rotate: 0,
rotate: Rotates.HORIZONTAL,
filter: false,
truncate: 100
},
title: {
text: 'Count'
text: countLabel
}
}
],
seriesParams: [{
show: 'true',
type: 'area',
mode: 'stacked',
data: {
label: 'Count',
id: '1'
},
drawLinesBetweenPoints: true,
showCircles: true,
interpolate: 'linear',
valueAxis: 'ValueAxis-1'
}],
seriesParams: [
{
show: true,
type: ChartTypes.AREA,
mode: ChartModes.STACKED,
data: {
label: countLabel,
id: '1'
},
drawLinesBetweenPoints: true,
lineWidth: 2,
showCircles: true,
interpolate: InterpolationModes.LINEAR,
valueAxis: 'ValueAxis-1',
}
],
addTooltip: true,
addLegend: true,
legendPosition: LegendPositions.RIGHT,
legendPosition: Positions.RIGHT,
times: [],
addTimeMarker: false,
thresholdLine: {
show: false,
value: 10,
width: 1,
style: 'full',
style: ThresholdLineStyles.FULL,
color: palettes.euiPaletteColorBlind.colors[9]
},
labels: {}
},
},
editorConfig: {
collections: {
legendPositions: getLegendPositions(),
positions: ['top', 'left', 'right', 'bottom'],
chartTypes: [{
value: 'line',
text: 'line'
}, {
value: 'area',
text: 'area'
}, {
value: 'histogram',
text: 'bar'
}],
axisModes: ['normal', 'percentage', 'wiggle', 'silhouette'],
scaleTypes: ['linear', 'log', 'square root'],
chartModes: ['normal', 'stacked'],
interpolationModes: [{
value: 'linear',
text: 'straight',
}, {
value: 'cardinal',
text: 'smoothed',
}, {
value: 'step-after',
text: 'stepped',
}],
},
optionTabs: [
{
name: 'advanced',
title: 'Metrics & Axes',
editor: '<div><vislib-series></vislib-series><vislib-value-axes>' +
'</vislib-value-axes><vislib-category-axis></vislib-category-axis></div>'
},
{ name: 'options', title: 'Panel Settings', editor: PointSeriesOptions },
],
collections: getConfigCollections(),
optionTabs: getAreaOptionTabs(),
schemas: new Schemas([
{
group: 'metrics',
group: AggGroupNames.Metrics,
name: 'metric',
title: i18n.translate('kbnVislibVisTypes.area.metricsTitle', { defaultMessage: 'Y-axis' }),
aggFilter: ['!geo_centroid', '!geo_bounds'],
Expand All @@ -157,31 +139,31 @@ export default function PointSeriesVisType(Private) {
]
},
{
group: 'metrics',
group: AggGroupNames.Metrics,
name: 'radius',
title: i18n.translate('kbnVislibVisTypes.area.radiusTitle', { defaultMessage: 'Dot size' }),
min: 0,
max: 1,
aggFilter: ['count', 'avg', 'sum', 'min', 'max', 'cardinality']
},
{
group: 'buckets',
group: AggGroupNames.Buckets,
name: 'segment',
title: i18n.translate('kbnVislibVisTypes.area.segmentTitle', { defaultMessage: 'X-axis' }),
min: 0,
max: 1,
aggFilter: ['!geohash_grid', '!geotile_grid', '!filter']
},
{
group: 'buckets',
group: AggGroupNames.Buckets,
name: 'group',
title: i18n.translate('kbnVislibVisTypes.area.groupTitle', { defaultMessage: 'Split series' }),
min: 0,
max: 3,
aggFilter: ['!geohash_grid', '!geotile_grid', '!filter']
},
{
group: 'buckets',
group: AggGroupNames.Buckets,
name: 'split',
title: i18n.translate('kbnVislibVisTypes.area.splitTitle', { defaultMessage: 'Split chart' }),
min: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ export { SelectOption } from './select';
export { SwitchOption } from './switch';
export { TextInputOption } from './text_input';
export { TruncateLabelsOption } from './truncate_labels';
export { ValidationWrapper, ValidationVisOptionsProps } from './validation_wrapper';
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,39 @@ import React from 'react';
import { EuiFormRow, EuiFieldNumber } from '@elastic/eui';

interface NumberInputOptionProps<ParamName extends string> {
disabled?: boolean;
error?: string[];
isInvalid?: boolean;
label?: React.ReactNode;
max?: number;
min?: number;
step?: string | number;
paramName: ParamName;
step?: number;
value?: number | '';
'data-test-subj'?: string;
setValue: (paramName: ParamName, value: number | '') => void;
}

function NumberInputOption<ParamName extends string>({
disabled,
error,
isInvalid,
label,
max,
min,
paramName,
step,
value = '',
setValue,
'data-test-subj': dataTestSubj,
}: NumberInputOptionProps<ParamName>) {
return (
<EuiFormRow label={label} fullWidth compressed>
<EuiFormRow label={label} error={error} isInvalid={isInvalid} fullWidth compressed>
<EuiFieldNumber
data-test-subj={dataTestSubj}
disabled={disabled}
fullWidth
isInvalid={isInvalid}
step={step}
max={max}
min={min}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import React from 'react';
import { EuiFormRow, EuiSelect } from '@elastic/eui';

interface SelectOptionProps<ParamName extends string, ValidParamValues extends string> {
interface SelectOptionProps<ParamName extends string, ValidParamValues extends string | number> {
disabled?: boolean;
helpText?: React.ReactNode;
id?: string;
Expand All @@ -34,7 +34,7 @@ interface SelectOptionProps<ParamName extends string, ValidParamValues extends s

const emptyValue = { text: '', value: 'EMPTY_VALUE', disabled: true, hidden: true };

function SelectOption<ParamName extends string, ValidParamValues extends string>({
function SelectOption<ParamName extends string, ValidParamValues extends string | number>({
disabled,
helpText,
id,
Expand All @@ -57,7 +57,7 @@ function SelectOption<ParamName extends string, ValidParamValues extends string>
<EuiSelect
disabled={disabled}
options={[emptyValue, ...options]}
value={value || emptyValue.value}
value={value === undefined ? emptyValue.value : value}
onChange={ev => setValue(paramName, ev.target.value as ValidParamValues)}
fullWidth={true}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface SwitchOptionProps<ParamName extends string> {
tooltip?: string;
disabled?: boolean;
value?: boolean;
noStyle?: boolean;
paramName: ParamName;
setValue: (paramName: ParamName, value: boolean) => void;
}
Expand All @@ -36,12 +37,13 @@ function SwitchOption<ParamName extends string>({
tooltip,
label,
disabled,
noStyle = false,
paramName,
value = false,
setValue,
}: SwitchOptionProps<ParamName>) {
return (
<div className="visEditorSidebar__switchOptionFormRow">
<div className={noStyle ? undefined : 'visEditorSidebar__switchOptionFormRow'}>
<EuiToolTip content={tooltip} delay="long" position="right">
<EuiSwitch
label={label}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ interface TextInputOptionProps<ParamName extends string> {
label?: React.ReactNode;
paramName: ParamName;
value?: string;
'data-test-subj'?: string;
setValue: (paramName: ParamName, value: string) => void;
}

function TextInputOption<ParamName extends string>({
'data-test-subj': dataTestSubj,
disabled,
helpText,
label,
Expand All @@ -41,6 +43,7 @@ function TextInputOption<ParamName extends string>({
<EuiFormRow helpText={helpText} label={label} fullWidth compressed>
<EuiFieldText
fullWidth
data-test-subj={dataTestSubj}
disabled={disabled}
value={value}
onChange={ev => setValue(paramName, ev.target.value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ import { i18n } from '@kbn/i18n';
import { EuiFormRow, EuiFieldNumber } from '@elastic/eui';

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

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

Expand All @@ -35,10 +36,15 @@ function TruncateLabelsOption({ value, setValue }: TruncateLabelsOptionProps) {
label={i18n.translate('kbnVislibVisTypes.controls.truncateLabel', {
defaultMessage: 'Truncate',
})}
fullWidth={true}
fullWidth
compressed
>
<EuiFieldNumber value={value === null ? '' : value} onChange={onChange} fullWidth={true} />
<EuiFieldNumber
disabled={disabled}
value={value === null ? '' : value}
onChange={onChange}
fullWidth
/>
</EuiFormRow>
);
}
Expand Down
Loading

0 comments on commit 1223ab9

Please sign in to comment.