Skip to content

Commit

Permalink
Bug/range slider issue (#1122)
Browse files Browse the repository at this point in the history
* range slide tootip and beyond range value bug

Signed-off-by: Abhay Pandey <[email protected]>

* removed unwanted code

Signed-off-by: Abhay Pandey <[email protected]>

* pr changes

Signed-off-by: Abhay Pandey <[email protected]>

* removed unused code

Signed-off-by: Abhay Pandey <[email protected]>

* snapshot updated

Signed-off-by: Abhay Pandey <[email protected]>

Signed-off-by: Abhay Pandey <[email protected]>
abhaypersistent authored Oct 13, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 2989fe7 commit 249ab50
Showing 6 changed files with 370 additions and 72 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -21,12 +21,18 @@ export const ConfigBarChartStyles = ({
const { data: vizData = {}, metadata: { fields = [] } = {} } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFieldName) => {
(stateFieldName, max) => {
return (changes) => {
handleConfigChange({
...vizState,
[stateFieldName]: changes,
});
if (!max || changes <= max) {
handleConfigChange({
...vizState,
[stateFieldName]: changes,
});
} else {
handleConfigChange({
...vizState,
});
}
};
},
[handleConfigChange, vizState]
@@ -68,15 +74,15 @@ export const ConfigBarChartStyles = ({
label: btn.name,
})),
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id,
handleButtonChange: handleConfigurationChange(schema.mapTo),
handleButtonChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
return createDimensionComponent(params);
}
if (schema.eleType === 'input') {
params = {
title: schema.name,
numValue: vizState[schema.mapTo] || '',
handleInputChange: handleConfigurationChange(schema.mapTo),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
vizState,
...schema.props,
};
@@ -91,7 +97,7 @@ export const ConfigBarChartStyles = ({
currentRange: vizState[schema.mapTo] || schema?.defaultState,
ticks: schema?.props?.ticks,
showTicks: schema?.props?.showTicks || false,
handleSliderChange: handleConfigurationChange(schema.mapTo),
handleSliderChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
return createDimensionComponent(params);
}
Original file line number Diff line number Diff line change
@@ -22,12 +22,18 @@ export const ConfigChartOptions = ({
const { data: vizData = {}, metadata: { fields = [] } = {}, tree_map } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFiledName) => {
(stateFiledName, max) => {
return (changes) => {
handleConfigChange({
...vizState,
[stateFiledName]: changes,
});
if (!max || changes <= max) {
handleConfigChange({
...vizState,
[stateFiledName]: changes,
});
} else {
handleConfigChange({
...vizState,
});
}
};
},
[handleConfigChange, vizState]
@@ -60,15 +66,15 @@ export const ConfigChartOptions = ({
...params,
colorPalettes: schema.options || [],
selectedColor: vizState[schema.mapTo] || schema.defaultState,
onSelectChange: handleConfigurationChange(schema.mapTo),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

case ConfigChartOptionsEnum.singleColorPicker:
params = {
...params,
selectedColor: vizState[schema.mapTo] || schema.defaultState,
onSelectChange: handleConfigurationChange(schema.mapTo),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -77,7 +83,7 @@ export const ConfigChartOptions = ({
...params,
selectedColor: vizState[schema.mapTo] || schema?.defaultState,
colorPalettes: schema.options || [],
onSelectChange: handleConfigurationChange(schema.mapTo),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -89,7 +95,7 @@ export const ConfigChartOptions = ({
numberOfParents:
(tree_map?.dataConfig?.dimensions !== undefined &&
tree_map?.dataConfig.dimensions[0].parentFields.length) | 0,
onSelectChange: handleConfigurationChange(schema.mapTo),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -98,7 +104,7 @@ export const ConfigChartOptions = ({
...params,
currentValue: vizState[schema.mapTo] || '',
numValue: vizState[schema.mapTo] || '',
handleInputChange: handleConfigurationChange(schema.mapTo),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
minLimit: schema.props?.hasOwnProperty('minLimit')
? schema.props.minLimit
: NUMBER_INPUT_MIN_LIMIT,
@@ -110,7 +116,7 @@ export const ConfigChartOptions = ({
...params,
currentValue: vizState[schema.mapTo] || '',
name: schema.mapTo,
handleInputChange: handleConfigurationChange(schema.mapTo),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -119,7 +125,7 @@ export const ConfigChartOptions = ({
...params,
maxRange: schema.props.max,
currentRange: vizState[schema.mapTo] || schema?.defaultState,
handleSliderChange: handleConfigurationChange(schema.mapTo),
handleSliderChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -128,7 +134,7 @@ export const ConfigChartOptions = ({
...params,
title: schema.name,
currentValue: vizState[schema.mapTo],
onToggle: handleConfigurationChange(schema.mapTo),
onToggle: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -142,7 +148,7 @@ export const ConfigChartOptions = ({
label: btn.name,
})),
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id,
handleButtonChange: handleConfigurationChange(schema.mapTo),
handleButtonChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
break;

@@ -152,7 +158,7 @@ export const ConfigChartOptions = ({
paddingTitle: schema.name,
advancedTitle: 'advancedTitle',
dropdownList: schema?.options || fields,
onSelectChange: handleConfigurationChange(schema.mapTo),
onSelectChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
isSingleSelection: schema.isSingleSelection,
selectedAxis: vizState[schema.mapTo] || schema.defaultState,
};
Original file line number Diff line number Diff line change
@@ -21,12 +21,18 @@ export const ConfigLineChartStyles = ({
const { data: vizData = {}, metadata: { fields = [] } = {} } = data?.rawVizData;

const handleConfigurationChange = useCallback(
(stateFiledName) => {
(stateFiledName, max) => {
return (changes) => {
handleConfigChange({
...vizState,
[stateFiledName]: changes,
});
if (!max || changes <= max) {
handleConfigChange({
...vizState,
[stateFiledName]: changes,
});
} else {
handleConfigChange({
...vizState,
});
}
};
},
[handleConfigChange, vizState]
@@ -82,7 +88,7 @@ export const ConfigLineChartStyles = ({
label: btn.name,
})),
idSelected: vizState[schema.mapTo] || schema?.props?.defaultSelections[0]?.id,
handleButtonChange: handleConfigurationChange(schema.mapTo),
handleButtonChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
} else if (schema.eleType === 'slider') {
params = {
@@ -93,18 +99,18 @@ export const ConfigLineChartStyles = ({
currentRange: vizState[schema.mapTo] || schema?.defaultState,
ticks: schema?.props?.ticks,
showTicks: schema?.props?.showTicks || false,
handleSliderChange: handleConfigurationChange(schema.mapTo),
handleSliderChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
} else if (schema.eleType === 'input') {
params = {
...params,
numValue: vizState[schema.mapTo] || '',
handleInputChange: handleConfigurationChange(schema.mapTo),
handleInputChange: handleConfigurationChange(schema.mapTo, schema?.props?.max),
};
}
return (
<Fragment key={`viz-series-${index}`}>
<DimensionComponent {...params} />
<DimensionComponent {...params} />
<EuiSpacer size="s" />
</Fragment>
);
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import React, { useCallback, useState, useEffect } from 'react';
import React, { useState, useEffect } from 'react';
import { EuiFieldText, EuiForm, EuiFormRow, EuiTextArea, EuiAccordion } from '@elastic/eui';
import { VIS_CHART_TYPES } from '../../../../../../../../common/constants/shared';
import { DEFAULT_GAUGE_CHART_PARAMETERS } from '../../../../../../../../common/constants/explorer';
Original file line number Diff line number Diff line change
@@ -4,7 +4,8 @@
*/

import React, { ReactNode } from 'react';
import { EuiTitle, EuiSpacer, EuiRange, htmlIdGenerator } from '@elastic/eui';
import { EuiTitle, EuiSpacer, EuiRange, htmlIdGenerator, EuiToolTip, EuiIcon } from '@elastic/eui';
const tooltipIcon = <EuiIcon type="iInCircle" color="text" size="m" className="info-icon" />;

export interface EuiRangeTick {
value: number;
@@ -24,6 +25,12 @@ interface Props {
) => void;
}

const rangeToolTip = (message: string) => (
<EuiToolTip position="top" content={message} delay="regular" anchorClassName="eui-textTruncate">
{tooltipIcon}
</EuiToolTip>
);

export const SliderConfig: React.FC<Props> = ({
title,
currentRange,
@@ -35,9 +42,12 @@ export const SliderConfig: React.FC<Props> = ({
step,
}) => (
<>
<EuiTitle size="xxs">
<h3>{title}</h3>
</EuiTitle>
<div style={{ display: 'flex' }}>
<EuiTitle size="xxs">
<h3>{title}</h3>
</EuiTitle>
{rangeToolTip(`Value must be in the range of ${minRange} to ${maxRange}`)}
</div>
<EuiSpacer size="s" />
<EuiRange
aria-label="change lineWidth slider"

0 comments on commit 249ab50

Please sign in to comment.