Skip to content

Commit

Permalink
Switch to select
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Feb 7, 2023
1 parent 1a45f6a commit 7b2b7e9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
EuiPanel,
EuiSpacer,
EuiCallOut,
EuiRange,
EuiSelect,
EuiFormRow,
} from '@elastic/eui';
Expand All @@ -25,7 +24,6 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { isDefined } from '@kbn/ml-is-defined';
import type { DocumentCountChartPoint } from './document_count_chart';
import {
RANDOM_SAMPLER_STEP,
RANDOM_SAMPLER_PROBABILITIES,
RandomSamplerOption,
RANDOM_SAMPLER_SELECT_OPTIONS,
Expand Down Expand Up @@ -169,7 +167,7 @@ export const DocumentCountContent: FC<Props> = ({
panelPaddingSize="none"
anchorPosition="downLeft"
>
<EuiPanel style={{ maxWidth: 400 }}>
<EuiPanel style={{ maxWidth: 450 }}>
<EuiFlexItem grow={true}>
<EuiCallOut size="s" color={'primary'} title={calloutInfoMessage} />
</EuiFlexItem>
Expand Down Expand Up @@ -205,21 +203,15 @@ export const DocumentCountContent: FC<Props> = ({
}
)}
>
<EuiRange
fullWidth
showValue
showTicks
showRange={false}
min={RANDOM_SAMPLER_STEP}
max={50}
<EuiSelect
value={(samplingProbability ?? 1) * 100}
ticks={RANDOM_SAMPLER_PROBABILITIES.map((d) => ({
options={RANDOM_SAMPLER_PROBABILITIES.map((d, idx) => ({
value: d,
label: d === 0.001 || d >= 5 ? `${d}%` : '',
text: `${d}%`,
}))}
onChange={(e) => updateSamplingProbability(Number(e.currentTarget.value))}
step={RANDOM_SAMPLER_STEP}
data-test-subj="dvRandomSamplerProbabilityRange"
onChange={(e) => {
updateSamplingProbability(Number(e.currentTarget.value));
}}
/>
</EuiFormRow>
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ import { DataVisualizerDataViewManagement } from '../data_view_management';
import { GetAdditionalLinks } from '../../../common/components/results_links';
import { useDataVisualizerGridData } from '../../hooks/use_data_visualizer_grid_data';
import { DataVisualizerGridInput } from '../../embeddables/grid_embeddable/grid_embeddable';
import { RANDOM_SAMPLER_OPTION, RandomSamplerOption } from '../../constants/random_sampler';
import { RANDOM_SAMPLER_OPTION } from '../../constants/random_sampler';

interface DataVisualizerPageState {
overallStats: OverallStats;
Expand Down Expand Up @@ -323,19 +323,6 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
[dataVisualizerListState, setDataVisualizerListState]
);

const setRandomSamplerPreference = useCallback(
(pref: RandomSamplerOption) => {
if (
savedRandomSamplerPreference === RANDOM_SAMPLER_OPTION.ON_AUTOMATIC &&
pref === RANDOM_SAMPLER_OPTION.ON_MANUAL
) {
setSamplingProbability(0.5);
}
saveRandomSamplerPreference(pref);
},
[setSamplingProbability, savedRandomSamplerPreference, saveRandomSamplerPreference]
);

useEffect(
function clearFiltersOnLeave() {
return () => {
Expand Down Expand Up @@ -582,7 +569,7 @@ export const IndexDataVisualizerView: FC<IndexDataVisualizerViewProps> = (dataVi
}
loading={overallStatsProgress.loaded < 100}
randomSamplerPreference={savedRandomSamplerPreference}
setRandomSamplerPreference={setRandomSamplerPreference}
setRandomSamplerPreference={saveRandomSamplerPreference}
/>
</EuiFlexGroup>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { i18n } from '@kbn/i18n';

export const RANDOM_SAMPLER_PROBABILITIES = [
0.5, 0.25, 0.1, 0.05, 0.025, 0.01, 0.005, 0.0025, 0.001, 0.0005, 0.00025, 0.0001, 0.00005,
1, 0.5, 0.25, 0.1, 0.05, 0.025, 0.01, 0.005, 0.0025, 0.001, 0.0005, 0.00025, 0.0001, 0.00005,
0.00001,
]
.reverse()
Expand Down

0 comments on commit 7b2b7e9

Please sign in to comment.