-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: auto (peaks and ranges) picking window size
- Loading branch information
1 parent
e71873d
commit 2b6a045
Showing
3 changed files
with
57 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { xGetFromToIndex } from 'ml-spectra-processing'; | ||
|
||
import { useChartData } from '../context/ChartContext'; | ||
|
||
import useSpectrum from './useSpectrum'; | ||
|
||
export const MIN_AREA_POINTS = 5 as const; | ||
|
||
export function useCheckPointsNumberInWindowArea() { | ||
const state = useChartData(); | ||
const spectrum = useSpectrum(null); | ||
const { | ||
xDomain: [from, to], | ||
} = state; | ||
|
||
if (spectrum) { | ||
const { fromIndex, toIndex } = xGetFromToIndex(spectrum.data.x, { | ||
from, | ||
to, | ||
}); | ||
return toIndex - fromIndex; | ||
} | ||
|
||
return 0; | ||
} |