Skip to content

Commit 4ed0198

Browse files
committed
💄 Revisit settings ui
1 parent 1b5ea75 commit 4ed0198

1 file changed

Lines changed: 78 additions & 38 deletions

File tree

x-pack/plugins/lens/public/datasources/form_based/layer_settings.tsx

Lines changed: 78 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,18 @@
55
* 2.0.
66
*/
77

8-
import { EuiFormRow, EuiRange, EuiBetaBadge } from '@elastic/eui';
8+
import {
9+
EuiFormRow,
10+
EuiRange,
11+
EuiFlexGroup,
12+
EuiFlexItem,
13+
EuiBadge,
14+
EuiText,
15+
EuiLink,
16+
} from '@elastic/eui';
917
import { i18n } from '@kbn/i18n';
1018
import React from 'react';
19+
import { FormattedMessage } from '@kbn/i18n-react';
1120
import type { DatasourceLayerSettingsProps } from '../../types';
1221
import type { FormBasedPrivateState } from './types';
1322

@@ -22,54 +31,85 @@ export function LayerSettingsPanel({
2231
const currentSamplingIndex = samplingIndex > -1 ? samplingIndex : samplingValue.length - 1;
2332
return (
2433
<EuiFormRow
25-
display="columnCompressed"
34+
display="rowCompressed"
2635
data-test-subj="lns-indexPattern-random-sampling-row"
2736
fullWidth
28-
helpText={i18n.translate('xpack.lens.xyChart.randomSampling.help', {
29-
defaultMessage: 'Change the sampling probability to see how your chart is affected',
30-
})}
37+
helpText={
38+
<FormattedMessage
39+
id="xpack.lens.xyChart.randomSampling.help"
40+
defaultMessage="The sampling is accomplished by providing a random subset of the entire set of documents. The lower the value the higher the error and speed: consider the usage of lower values for big datasets. {link}"
41+
values={{
42+
link: (
43+
<EuiLink
44+
href="https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-random-sampler-aggregation.html"
45+
target="_blank"
46+
external
47+
>
48+
<FormattedMessage
49+
id="xpack.lens.xyChart.randomSampling.learnMore"
50+
defaultMessage="Learn more"
51+
/>
52+
</EuiLink>
53+
),
54+
}}
55+
/>
56+
}
3157
label={
3258
<>
3359
{i18n.translate('xpack.lens.xyChart.randomSampling.label', {
34-
defaultMessage: 'Sampling',
60+
defaultMessage: 'Random sampling',
3561
})}{' '}
36-
<EuiBetaBadge
37-
label={i18n.translate('xpack.lens.randomSampling.experimentalLabel', {
38-
defaultMessage: 'Technical preview',
39-
})}
40-
color="hollow"
41-
iconType="beaker"
42-
size="s"
43-
tooltipContent={i18n.translate('xpack.lens.randomSampling.experimentalLabel', {
62+
<EuiBadge color="hollow">
63+
{i18n.translate('xpack.lens.randomSampling.experimentalLabel', {
4464
defaultMessage: 'Technical preview',
4565
})}
46-
/>
66+
</EuiBadge>
4767
</>
4868
}
4969
>
50-
<EuiRange
51-
data-test-subj="lns-indexPattern-random-sampling"
52-
value={currentSamplingIndex}
53-
onChange={(e) => {
54-
setState({
55-
...state,
56-
layers: {
57-
...state.layers,
58-
[layerId]: {
59-
...state.layers[layerId],
60-
sampling: samplingValue[Number(e.currentTarget.value)],
61-
},
62-
},
63-
});
64-
}}
65-
showInput={false}
66-
showRange={false}
67-
showTicks
68-
step={1}
69-
min={0}
70-
max={samplingValue.length - 1}
71-
ticks={samplingValue.map((v, i) => ({ label: `${v}`, value: i }))}
72-
/>
70+
<EuiFlexGroup>
71+
<EuiFlexItem grow={false}>
72+
<EuiText size="s">
73+
<FormattedMessage
74+
id="xpack.lens.xyChart.randomSampling.speedLabel"
75+
defaultMessage="Speed"
76+
/>
77+
</EuiText>
78+
</EuiFlexItem>
79+
<EuiFlexItem>
80+
<EuiRange
81+
data-test-subj="lns-indexPattern-random-sampling"
82+
value={currentSamplingIndex}
83+
onChange={(e) => {
84+
setState({
85+
...state,
86+
layers: {
87+
...state.layers,
88+
[layerId]: {
89+
...state.layers[layerId],
90+
sampling: samplingValue[Number(e.currentTarget.value)],
91+
},
92+
},
93+
});
94+
}}
95+
showInput={false}
96+
showRange={false}
97+
showTicks
98+
step={1}
99+
min={0}
100+
max={samplingValue.length - 1}
101+
ticks={samplingValue.map((v, i) => ({ label: `${v * 100}%`, value: i }))}
102+
/>
103+
</EuiFlexItem>
104+
<EuiFlexItem grow={false}>
105+
<EuiText size="s">
106+
<FormattedMessage
107+
id="xpack.lens.xyChart.randomSampling.accuracyLabel"
108+
defaultMessage="Accuracy"
109+
/>
110+
</EuiText>
111+
</EuiFlexItem>
112+
</EuiFlexGroup>
73113
</EuiFormRow>
74114
);
75115
}

0 commit comments

Comments
 (0)