From 2c30dcccd58f2f46c4e770f3b008229dde1a8e6b Mon Sep 17 00:00:00 2001 From: Peter Pan Date: Sat, 20 Feb 2021 21:49:02 +0800 Subject: [PATCH] fix: iteration state error when change dimensional in high-dimensional page (#936) --- .../src/components/HighDimensionalPage/TSNEDetail.tsx | 9 ++++++++- frontend/packages/core/src/pages/high-dimensional.tsx | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/packages/core/src/components/HighDimensionalPage/TSNEDetail.tsx b/frontend/packages/core/src/components/HighDimensionalPage/TSNEDetail.tsx index 7b485f2c..d3c3f8b1 100644 --- a/frontend/packages/core/src/components/HighDimensionalPage/TSNEDetail.tsx +++ b/frontend/packages/core/src/components/HighDimensionalPage/TSNEDetail.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import React, {FunctionComponent, useCallback, useState} from 'react'; +import React, {FunctionComponent, useCallback, useEffect, useState} from 'react'; import Button from '~/components/Button'; import Field from '~/components/Field'; @@ -33,6 +33,7 @@ export type TSNEDetailProps = { iteration: number; perplexity: number; learningRate: number; + is3D: boolean; onChangePerplexity?: (perplexity: number) => void; onChangeLearningRate?: (learningRate: number) => void; onPause?: () => void; @@ -45,6 +46,7 @@ const TSNEDetail: FunctionComponent = ({ iteration, perplexity, learningRate, + is3D, onChangePerplexity, onChangeLearningRate, onPause, @@ -98,6 +100,11 @@ const TSNEDetail: FunctionComponent = ({ }); }, [onRerun, onStop]); + useEffect(() => { + setPaused(false); + setStopped(false); + }, [is3D]); + return ( <> diff --git a/frontend/packages/core/src/pages/high-dimensional.tsx b/frontend/packages/core/src/pages/high-dimensional.tsx index bd8bd9e3..c148a941 100644 --- a/frontend/packages/core/src/pages/high-dimensional.tsx +++ b/frontend/packages/core/src/pages/high-dimensional.tsx @@ -364,6 +364,7 @@ const HighDimensional: FunctionComponent = () => { iteration={(data as TSNEResult)?.step ?? 0} perplexity={perplexity} learningRate={learningRate} + is3D={is3D} onChangePerplexity={setPerplexity} onChangeLearningRate={setLearningRate} onPause={chart.current?.pauseTSNE} @@ -377,7 +378,7 @@ const HighDimensional: FunctionComponent = () => { default: return null as never; } - }, [reduction, dimension, data, perplexity, learningRate, neighbors, runUMAP]); + }, [reduction, dimension, data, perplexity, learningRate, is3D, neighbors, runUMAP]); const aside = useMemo( () => ( -- GitLab