nmrium 0.55.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/lib/component/1d/Chart1D.js +3 -1
  2. package/lib/component/1d/ExclusionZoneAnnotation.d.ts +0 -1
  3. package/lib/component/1d/Viewer1D.js +36 -11
  4. package/lib/component/1d/database/DatabaseSpectrum.js +14 -19
  5. package/lib/component/1d/jCouplingGraph/JGraphContext.d.ts +0 -1
  6. package/lib/component/1d/matrix/Boxplot.d.ts +6 -0
  7. package/lib/component/1d/matrix/Boxplot.js +97 -0
  8. package/lib/component/1d/matrix/Stocsy.d.ts +5 -0
  9. package/lib/component/1d/matrix/Stocsy.js +101 -0
  10. package/lib/component/1d/matrix/useMatrix.d.ts +29 -0
  11. package/lib/component/1d/matrix/useMatrix.js +93 -0
  12. package/lib/component/1d/peaks/PeakAnnotationsSpreadMode.d.ts +0 -1
  13. package/lib/component/1d/peaks/PeakEditionManager.js +16 -10
  14. package/lib/component/1d/utilities/getDecimalsCount.js +1 -1
  15. package/lib/component/1d/utilities/intersectionResolver.js +1 -1
  16. package/lib/component/1d/utilities/scale.d.ts +2 -1
  17. package/lib/component/1d/utilities/scale.js +6 -1
  18. package/lib/component/1d-2d/FieldEdition.d.ts +3 -1
  19. package/lib/component/1d-2d/FieldEdition.js +26 -10
  20. package/lib/component/2d/1d-tracer/Left1DChart.d.ts +0 -1
  21. package/lib/component/2d/1d-tracer/Top1DChart.d.ts +0 -1
  22. package/lib/component/2d/XAxis.d.ts +0 -1
  23. package/lib/component/2d/YAxis.d.ts +0 -1
  24. package/lib/component/2d/ft/Contours.js +7 -7
  25. package/lib/component/assignment/AssignmentsContext.d.ts +0 -1
  26. package/lib/component/context/ChartContext.d.ts +0 -1
  27. package/lib/component/context/DispatchContext.d.ts +0 -1
  28. package/lib/component/context/GlobalContext.d.ts +0 -1
  29. package/lib/component/context/KeyModifierContext.js +1 -1
  30. package/lib/component/context/LoaderContext.d.ts +0 -1
  31. package/lib/component/context/PreferencesContext.d.ts +0 -1
  32. package/lib/component/context/PrepareExportContext.d.ts +21 -0
  33. package/lib/component/context/PrepareExportContext.js +124 -0
  34. package/lib/component/context/ScaleContext.d.ts +0 -1
  35. package/lib/component/elements/ActionButtons.d.ts +1 -0
  36. package/lib/component/elements/ActionButtons.js +4 -4
  37. package/lib/component/elements/ColorInput.d.ts +0 -1
  38. package/lib/component/elements/ColorPickerDropdownController.d.ts +2 -0
  39. package/lib/component/elements/ColorPickerDropdownController.js +8 -0
  40. package/lib/component/elements/ColumnWrapper.d.ts +0 -1
  41. package/lib/component/elements/ContextMenu.d.ts +0 -1
  42. package/lib/component/elements/Input.d.ts +1 -0
  43. package/lib/component/elements/Input.js +2 -1
  44. package/lib/component/elements/Input2.d.ts +13 -0
  45. package/lib/component/elements/Input2.js +118 -0
  46. package/lib/component/elements/Input2Controller.d.ts +12 -0
  47. package/lib/component/elements/Input2Controller.js +22 -0
  48. package/lib/component/elements/MoleculeSelection.js +1 -1
  49. package/lib/component/elements/NumberInput.js +1 -1
  50. package/lib/component/elements/NumberInput2.d.ts +12 -0
  51. package/lib/component/elements/NumberInput2.js +65 -0
  52. package/lib/component/elements/NumberInput2Controller.d.ts +8 -0
  53. package/lib/component/elements/NumberInput2Controller.js +15 -0
  54. package/lib/component/elements/ReactTable/Elements/ReactTableRow.js +3 -3
  55. package/lib/component/elements/ReactTable/Style.d.ts +3 -1
  56. package/lib/component/elements/ReactTable/Style.js +11 -1
  57. package/lib/component/elements/ReactTable/utility/ReactTableContext.d.ts +0 -1
  58. package/lib/component/elements/Select2.d.ts +26 -0
  59. package/lib/component/elements/Select2.js +25 -0
  60. package/lib/component/elements/Select2Controller.d.ts +7 -0
  61. package/lib/component/elements/Select2Controller.js +12 -0
  62. package/lib/component/elements/draggable/useDraggable.d.ts +0 -1
  63. package/lib/component/elements/dropDownButton/DropDownButton.d.ts +2 -4
  64. package/lib/component/elements/dropDownButton/DropDownButton.js +11 -37
  65. package/lib/component/elements/dropDownButton/DropDownList.js +3 -32
  66. package/lib/component/elements/formik/FormikColorPicker.d.ts +0 -1
  67. package/lib/component/elements/formik/FormikColumnFormatField.d.ts +0 -1
  68. package/lib/component/elements/formik/FormikInput.d.ts +0 -1
  69. package/lib/component/elements/formik/FormikInput2.d.ts +11 -0
  70. package/lib/component/elements/formik/FormikInput2.js +26 -0
  71. package/lib/component/elements/formik/FormikOnChange.d.ts +0 -1
  72. package/lib/component/elements/popup/Modal/Context.d.ts +0 -1
  73. package/lib/component/elements/popup/Modal/ModalContent.d.ts +0 -1
  74. package/lib/component/elements/resizer/SVGResizer.d.ts +0 -1
  75. package/lib/component/elements/useFormValidateField.d.ts +1 -0
  76. package/lib/component/elements/useFormValidateField.js +9 -0
  77. package/lib/component/header/ApodizationOptionsPanel.js +26 -11
  78. package/lib/component/header/AutoPeakPickingOptionPanel.d.ts +1 -4
  79. package/lib/component/header/AutoPeakPickingOptionPanel.js +16 -16
  80. package/lib/component/header/BaseLineCorrectionPanel.js +49 -27
  81. package/lib/component/header/Header.js +1 -1
  82. package/lib/component/header/PhaseCorrectionPanel.js +12 -24
  83. package/lib/component/header/RangesPickingOptionPanel.js +12 -12
  84. package/lib/component/header/ZeroFillingOptionsPanel.js +18 -7
  85. package/lib/component/header/Zones2DOptionPanel.js +19 -18
  86. package/lib/component/hooks/useExport.d.ts +1 -1
  87. package/lib/component/hooks/useExport.js +4 -4
  88. package/lib/component/hooks/usePanelPreferences.d.ts +2 -3
  89. package/lib/component/hooks/usePanelPreferences.js +3 -1
  90. package/lib/component/hooks/useToggleSpectraVisibility.d.ts +10 -0
  91. package/lib/component/hooks/useToggleSpectraVisibility.js +41 -0
  92. package/lib/component/hooks/useWorkspaceAction.d.ts +1 -1
  93. package/lib/component/modal/editRange/forms/components/SignalTab.d.ts +0 -1
  94. package/lib/component/modal/editRange/forms/components/SignalsContent.d.ts +0 -1
  95. package/lib/component/modal/setting/GeneralSettings.d.ts +5 -1
  96. package/lib/component/modal/setting/GeneralSettings.js +107 -111
  97. package/lib/component/modal/setting/WorkspaceItem.js +4 -9
  98. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.d.ts +1 -1
  99. package/lib/component/modal/setting/settings-tabs/DatabasesTabContent.js +95 -59
  100. package/lib/component/modal/setting/settings-tabs/DisplayTabContent.js +33 -25
  101. package/lib/component/modal/setting/settings-tabs/GeneralTabContent.js +15 -4
  102. package/lib/component/modal/setting/settings-tabs/ImportationFiltersTabContent.js +56 -39
  103. package/lib/component/modal/setting/settings-tabs/InfoBlockTabContent.js +36 -36
  104. package/lib/component/modal/setting/settings-tabs/NucleiTabContent.js +44 -36
  105. package/lib/component/modal/setting/settings-tabs/OnLoadProcessingTabContent.js +16 -11
  106. package/lib/component/modal/setting/settings-tabs/SpectraColorsTabContent.js +47 -40
  107. package/lib/component/modal/setting/settings-tabs/ToolsTabContent.js +50 -40
  108. package/lib/component/modal/setting/settingsValidation.js +8 -34
  109. package/lib/component/panels/AutomaticAssignment/AutomaticAssignmentTable.d.ts +0 -1
  110. package/lib/component/panels/IntegralsPanel/IntegralTable.d.ts +0 -1
  111. package/lib/component/panels/IntegralsPanel/IntegralsPreferences.d.ts +0 -1
  112. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.d.ts +2 -2
  113. package/lib/component/panels/MatrixGenerationPanel/MatrixGenerationPanel.js +121 -36
  114. package/lib/component/panels/Panels.js +32 -9
  115. package/lib/component/panels/PeaksPanel/PeaksPreferences.d.ts +0 -1
  116. package/lib/component/panels/PeaksPanel/PeaksTable.d.ts +0 -1
  117. package/lib/component/panels/RangesPanel/RangesPreferences.d.ts +0 -1
  118. package/lib/component/panels/RangesPanel/TableColumns/RangeAssignmentsColumn.d.ts +0 -1
  119. package/lib/component/panels/SpectraPanel/SpectraPanelHeader.js +4 -27
  120. package/lib/component/panels/SpectraPanel/SpectraPreferences.d.ts +0 -1
  121. package/lib/component/panels/SpectraPanel/SpectraPreferences.js +32 -24
  122. package/lib/component/panels/SpectraPanel/SpectraTable.js +17 -2
  123. package/lib/component/panels/SpectraPanel/SpectrumListPanel.d.ts +0 -1
  124. package/lib/component/panels/SpectraPanel/base/ColorIndicator.d.ts +0 -1
  125. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.d.ts +3 -3
  126. package/lib/component/panels/SpectraPanel/base/SpectraColumnsManager.js +25 -16
  127. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DHistogram.d.ts +0 -1
  128. package/lib/component/panels/SpectraPanel/base/setting/Spectrum1DSetting.js +15 -5
  129. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DHistogram.d.ts +0 -1
  130. package/lib/component/panels/SpectraPanel/base/setting/Spectrum2DSetting.js +44 -6
  131. package/lib/component/panels/SpectraPanel/base/setting/SpectrumSetting.d.ts +0 -1
  132. package/lib/component/panels/SummaryPanel/Overview.d.ts +0 -1
  133. package/lib/component/panels/SummaryPanel/SummaryPanel.d.ts +0 -1
  134. package/lib/component/panels/SummaryPanel/utilities/Utilities.d.ts +1 -1
  135. package/lib/component/panels/ZonesPanel/ZonesPreferences.d.ts +0 -1
  136. package/lib/component/panels/databasePanel/DatabasePanel.js +17 -3
  137. package/lib/component/panels/databasePanel/DatabasePreferences.d.ts +0 -1
  138. package/lib/component/panels/databasePanel/DatabaseTable.d.ts +11 -4
  139. package/lib/component/panels/databasePanel/DatabaseTable.js +22 -7
  140. package/lib/component/panels/informationPanel/InformationEditionModal.d.ts +6 -0
  141. package/lib/component/panels/informationPanel/InformationEditionModal.js +105 -0
  142. package/lib/component/panels/informationPanel/InformationPanel.d.ts +1 -0
  143. package/lib/component/panels/{InformationPanel.js → informationPanel/InformationPanel.js} +2 -2
  144. package/lib/component/panels/multipleAnalysisPanel/preferences/MultipleAnalysisCodeEditor.d.ts +0 -1
  145. package/lib/component/panels/multipleAnalysisPanel/preferences/index.d.ts +0 -1
  146. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.d.ts +0 -1
  147. package/lib/component/panels/predictionPanel/PredictionOptionsPanel.js +1 -1
  148. package/lib/component/panels/predictionPanel/PredictionPreferences.d.ts +0 -1
  149. package/lib/component/panels/spectrumSimulation/SpectrumSimulationPreferences.d.ts +0 -1
  150. package/lib/component/reducer/Reducer.d.ts +7 -1
  151. package/lib/component/reducer/Reducer.js +2 -0
  152. package/lib/component/reducer/actions/DatabaseActions.js +22 -5
  153. package/lib/component/reducer/actions/DomainActions.d.ts +5 -2
  154. package/lib/component/reducer/actions/DomainActions.js +6 -4
  155. package/lib/component/reducer/actions/FiltersActions.js +2 -2
  156. package/lib/component/reducer/actions/LoadActions.js +5 -2
  157. package/lib/component/reducer/actions/SpectraActions.d.ts +9 -2
  158. package/lib/component/reducer/actions/SpectraActions.js +65 -23
  159. package/lib/component/reducer/actions/ToolsActions.js +3 -4
  160. package/lib/component/reducer/preferences/actions/matrixGeneration.d.ts +47 -2
  161. package/lib/component/reducer/preferences/actions/matrixGeneration.js +62 -25
  162. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.d.ts +11 -8
  163. package/lib/component/reducer/preferences/panelsPreferencesDefaultValues.js +19 -1
  164. package/lib/component/reducer/preferences/preferencesReducer.d.ts +3 -26
  165. package/lib/component/reducer/preferences/preferencesReducer.js +7 -1
  166. package/lib/component/toolbar/ToolBar.js +6 -7
  167. package/lib/component/utility/PathBuilder.d.ts +1 -0
  168. package/lib/component/utility/PathBuilder.js +8 -1
  169. package/lib/component/utility/checkUniqueByKey.d.ts +2 -0
  170. package/lib/component/utility/checkUniqueByKey.js +40 -0
  171. package/lib/component/utility/colorToHexWithAlpha.d.ts +9 -0
  172. package/lib/component/utility/colorToHexWithAlpha.js +4 -0
  173. package/lib/component/workspaces/exercise.js +2 -0
  174. package/lib/component/workspaces/process1D.js +0 -1
  175. package/lib/component/workspaces/workspaceDefaultProperties.js +1 -0
  176. package/lib/data/PredictionManager.js +3 -5
  177. package/lib/data/data1d/Spectrum1D/ranges/createRange.d.ts +13 -13
  178. package/lib/data/data1d/Spectrum1D/ranges/detectSignals.d.ts +9 -9
  179. package/lib/data/data1d/Spectrum1D/ranges/initiateRanges.d.ts +13 -13
  180. package/lib/data/data1d/Spectrum1D/ranges/resizeRange.d.ts +13 -13
  181. package/lib/data/data1d/database.d.ts +1 -0
  182. package/lib/data/data1d/database.js +4 -2
  183. package/lib/data/data2d/Spectrum2D/contours.d.ts +8 -22
  184. package/lib/data/data2d/Spectrum2D/contours.js +88 -67
  185. package/lib/data/data2d/Spectrum2D/initiateDatum2D.js +4 -2
  186. package/lib/data/data2d/Spectrum2D/zones/detectZonesManual.d.ts +20 -20
  187. package/lib/data/data2d/Spectrum2D/zones/initiateZones.d.ts +20 -20
  188. package/lib/data/getDefaultMatrixFilters.d.ts +1 -1
  189. package/lib/data/initiateFilters.d.ts +1 -1
  190. package/lib/data/matrixGeneration.js +1 -2
  191. package/lib/data/types/common/DeepPartial.d.ts +3 -0
  192. package/lib/data/types/common/DeepPartial.js +1 -0
  193. package/lib/data/types/common/Keys.d.ts +3 -0
  194. package/lib/data/types/common/Keys.js +1 -0
  195. package/lib/data/utilities/generateNumbersPowerOfX.d.ts +2 -2
  196. package/lib/versionInfo.js +1 -1
  197. package/package.json +39 -38
  198. package/lib/component/elements/CustomToolTip.d.ts +0 -8
  199. package/lib/component/elements/CustomToolTip.js +0 -107
  200. package/lib/component/elements/formik/FormikSlider.d.ts +0 -6
  201. package/lib/component/elements/formik/FormikSlider.js +0 -15
  202. package/lib/component/panels/InformationPanel.d.ts +0 -1
@@ -10,6 +10,8 @@ import XAxis from './XAxis';
10
10
  import DatabaseElements from './database/DatabaseElements';
11
11
  import IntegralsSeries from './integral/IntegralsSeries';
12
12
  import JGraph from './jCouplingGraph/JGraph';
13
+ import { Boxplot } from './matrix/Boxplot';
14
+ import { Stocsy } from './matrix/Stocsy';
13
15
  import MultiAnalysisRanges from './multiAnalysis/MultiAnalysisRanges';
14
16
  import MultiplicityTrees from './multiplicityTree/MultiplicityTrees';
15
17
  import { PeakEditionProvider } from './peaks/PeakEditionManager';
@@ -22,6 +24,6 @@ function Chart1D({ mode, width, height, margin, displayerKey }) {
22
24
  const { current: { general: { spectraRendering }, }, } = usePreferences();
23
25
  const innerWidth = width - margin.left - margin.right;
24
26
  const innerHeight = height - margin.bottom;
25
- return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { id: "nmrSVG", width: width, height: height, viewBox: `0 0 ${width} ${height}`, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Ranges, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(MultiplicityTrees, {}), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx(SimilarityTree, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
27
+ return (_jsx(PeakEditionProvider, { children: _jsxs("svg", { id: "nmrSVG", width: width, height: height, viewBox: `0 0 ${width} ${height}`, fontFamily: "Arial, Helvetica, sans-serif", shapeRendering: spectraRendering, children: [_jsx("defs", { children: _jsx("clipPath", { id: `${displayerKey}clip-chart-1d`, children: _jsx("rect", { width: innerWidth, height: innerHeight, x: margin.left, y: "0" }) }) }), _jsx(LinesSeries, {}), _jsx(ApodizationLine, {}), _jsx(IntegralsSeries, {}), _jsx(Peaks, { peaksSource: "peaks" }), _jsx(RangesIntegrals, {}), _jsx(Ranges, {}), _jsx(Peaks, { peaksSource: "ranges" }), _jsx(MultiplicityTrees, {}), _jsx(JGraph, {}), _jsx(MultiAnalysisRanges, {}), _jsx(BaseLineZones, {}), _jsx(ExclusionZonesAnnotations, {}), _jsx(DatabaseElements, {}), _jsx(PeaksShapes, {}), _jsx(Stocsy, {}), _jsx(Boxplot, {}), _jsx(SpectraTracker, {}), _jsx(SpectrumInfoBlock, {}), _jsx(SimilarityTree, {}), _jsx("g", { className: "container", style: { pointerEvents: 'none' }, children: _jsx(XAxis, { showGrid: true, mode: mode }) })] }) }));
26
28
  }
27
29
  export default Chart1D;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ExclusionZone } from '../../data/types/data1d/ExclusionZone';
3
2
  interface ExclusionZoneProps {
4
3
  zone: ExclusionZone;
@@ -16,6 +16,7 @@ import { useLogger } from '../context/LoggerContext';
16
16
  import { usePreferences } from '../context/PreferencesContext';
17
17
  import { ScaleProvider } from '../context/ScaleContext';
18
18
  import { useActiveSpectrum } from '../hooks/useActiveSpectrum';
19
+ import { usePanelPreferences } from '../hooks/usePanelPreferences';
19
20
  import useSpectrum from '../hooks/useSpectrum';
20
21
  import { useVerticalAlign } from '../hooks/useVerticalAlign';
21
22
  import Spinner from '../loader/Spinner';
@@ -41,6 +42,7 @@ function Viewer1D({ emptyText = undefined }) {
41
42
  const spectrum = useSpectrum();
42
43
  const dispatch = useDispatch();
43
44
  const { dispatch: dispatchPreferences } = usePreferences();
45
+ const { showBoxPlot, showStocsy } = usePanelPreferences('matrixGeneration', activeTab);
44
46
  const { logger } = useLogger();
45
47
  const [scaleState, dispatchScale] = useReducer(scaleReducer, scaleInitialState);
46
48
  useEffect(() => {
@@ -238,8 +240,27 @@ function Viewer1D({ emptyText = undefined }) {
238
240
  });
239
241
  }, [dispatch]);
240
242
  const handleZoom = useCallback((options) => {
241
- dispatch({ type: 'SET_ZOOM', payload: { options } });
242
- }, [dispatch]);
243
+ if ((showBoxPlot || showStocsy) &&
244
+ options.altKey &&
245
+ (selectedTool === 'zoom' ||
246
+ selectedTool === 'matrixGenerationExclusionZones')) {
247
+ //change the matrix generation vertical scale
248
+ dispatchPreferences({
249
+ type: 'CHANGE_MATRIX_GENERATION_SCALE',
250
+ payload: { nucleus: activeTab, zoomOptions: options },
251
+ });
252
+ }
253
+ else {
254
+ dispatch({ type: 'SET_ZOOM', payload: { options } });
255
+ }
256
+ }, [
257
+ activeTab,
258
+ dispatch,
259
+ dispatchPreferences,
260
+ selectedTool,
261
+ showBoxPlot,
262
+ showStocsy,
263
+ ]);
243
264
  const mouseClick = useCallback((event) => {
244
265
  if (!scaleState.scaleX)
245
266
  return;
@@ -252,19 +273,19 @@ function Viewer1D({ emptyText = undefined }) {
252
273
  switch (keyModifiers) {
253
274
  case primaryKeyIdentifier: {
254
275
  switch (selectedTool) {
255
- case options.peakPicking.id:
276
+ case 'peakPicking':
256
277
  dispatch({
257
278
  type: 'ADD_PEAK',
258
279
  payload: event,
259
280
  });
260
281
  break;
261
- case options.integral.id:
282
+ case 'integral':
262
283
  dispatch({
263
284
  type: 'CUT_INTEGRAL',
264
285
  payload: { cutValue: xPPM },
265
286
  });
266
287
  break;
267
- case options.rangePicking.id: {
288
+ case 'rangePicking': {
268
289
  if (!spectrum)
269
290
  break;
270
291
  if (isSpectrum1D(spectrum)) {
@@ -276,12 +297,13 @@ function Viewer1D({ emptyText = undefined }) {
276
297
  }
277
298
  break;
278
299
  }
279
- case options.phaseCorrection.id:
280
- dispatch({
281
- type: 'SET_ONE_DIMENSION_PIVOT_POINT',
282
- payload: {
283
- value: event.x,
284
- },
300
+ case 'zoom':
301
+ case 'matrixGenerationExclusionZones':
302
+ if (!showStocsy || !event.shiftKey)
303
+ break;
304
+ dispatchPreferences({
305
+ type: 'CHANGE_MATRIX_GENERATION_STOCSY_CHEMICAL_SHIFT',
306
+ payload: { nucleus: activeTab, chemicalShift: xPPM },
285
307
  });
286
308
  break;
287
309
  default:
@@ -293,11 +315,14 @@ function Viewer1D({ emptyText = undefined }) {
293
315
  break;
294
316
  }
295
317
  }, [
318
+ activeTab,
296
319
  dispatch,
320
+ dispatchPreferences,
297
321
  getModifiersKey,
298
322
  primaryKeyIdentifier,
299
323
  scaleState,
300
324
  selectedTool,
325
+ showStocsy,
301
326
  spectrum,
302
327
  ]);
303
328
  return (_jsxs(ScaleProvider, { value: scaleState, children: [_jsx(ResponsiveChart, { children: ({ height, width }) => (_jsx(ViewerResponsiveWrapper, { height: height, width: width, children: _jsxs("div", { style: { height: '100%', position: 'relative' }, children: [_jsx(Spinner, { isLoading: isLoading, emptyText: emptyText }), scaleState.scaleX &&
@@ -1,4 +1,5 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { extent } from 'd3';
2
3
  import throttle from 'lodash/throttle';
3
4
  import { readFromWebSource } from 'nmr-load-save';
4
5
  import { useCallback, useContext, useEffect, useRef, useState } from 'react';
@@ -7,13 +8,11 @@ import { useScaleChecked } from '../../context/ScaleContext';
7
8
  import { useToaster } from '../../context/ToasterContext';
8
9
  import { HighlightEventSource, useHighlightData } from '../../highlight';
9
10
  import { usePanelPreferences } from '../../hooks/usePanelPreferences';
10
- import { useVerticalAlign } from '../../hooks/useVerticalAlign';
11
11
  import { spinnerContext } from '../../loader/SpinnerContext';
12
12
  import { PathBuilder } from '../../utility/PathBuilder';
13
- import { getYScale } from '../utilities/scale';
13
+ import { getYScaleWithRation } from '../utilities/scale';
14
14
  function DatabaseSpectrum() {
15
- const { displayerKey, height, yDomain, yDomains, margin } = useChartData();
16
- const verticalAlign = useVerticalAlign();
15
+ const { displayerKey, height, margin } = useChartData();
17
16
  const [path, setPath] = useState();
18
17
  const [isLoading, setLoading] = useState(false);
19
18
  const { highlight } = useHighlightData();
@@ -22,21 +21,16 @@ function DatabaseSpectrum() {
22
21
  const { color, marginBottom } = usePanelPreferences('database');
23
22
  const { jcampURL: jcampRelativeURL = '', baseURL } = highlight?.sourceData?.extra || {};
24
23
  const getSpinner = useContext(spinnerContext);
25
- const scaleY = useCallback(() => getYScale({
26
- height,
27
- margin: { top: margin.top, bottom: margin.bottom + marginBottom },
28
- verticalAlign,
24
+ const scaleY = useCallback((yDomain) => getYScaleWithRation({
29
25
  yDomain,
30
- yDomains,
31
- }), [
32
- verticalAlign,
33
26
  height,
34
- margin.bottom,
35
- margin.top,
36
- marginBottom,
37
- yDomain,
38
- yDomains,
39
- ]);
27
+ margin: {
28
+ ...margin,
29
+ bottom: margin.bottom + marginBottom,
30
+ top: margin.top,
31
+ },
32
+ scaleRatio: 1,
33
+ }), [height, margin, marginBottom]);
40
34
  const loadSpectrum = useRef(throttle(async (baseURL, jcampRelativeURL) => {
41
35
  try {
42
36
  setLoading(true);
@@ -48,9 +42,10 @@ function DatabaseSpectrum() {
48
42
  const spectrum = data?.spectra?.[0] || null;
49
43
  if (spectrum) {
50
44
  const pathBuilder = new PathBuilder();
51
- const finalScaleX = scaleX();
52
- const finalScaleY = scaleY();
53
45
  const { x, re: y } = spectrum.data;
46
+ const yDomain = extent(y);
47
+ const finalScaleX = scaleX();
48
+ const finalScaleY = scaleY(yDomain);
54
49
  pathBuilder.moveTo(finalScaleX(x[0]), finalScaleY(y[0]));
55
50
  for (let i = 1; i < x.length; i++) {
56
51
  pathBuilder.lineTo(finalScaleX(x[i]), finalScaleY(y[i]));
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ScaleLinear } from 'd3';
3
2
  interface JGraphState {
4
3
  scaleY: ScaleLinear<number, number> | null;
@@ -0,0 +1,6 @@
1
+ interface InnerBoxplotProps {
2
+ scaleRatio: number;
3
+ }
4
+ export declare function Boxplot(): import("react/jsx-runtime").JSX.Element | null | undefined;
5
+ export declare function InnerBoxplot(props: InnerBoxplotProps): import("react/jsx-runtime").JSX.Element | null;
6
+ export {};
@@ -0,0 +1,97 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { extent } from 'd3';
3
+ import { xFindClosestIndex } from 'ml-spectra-processing';
4
+ import { matrixToBoxPlot } from 'nmr-processing';
5
+ import { useMemo } from 'react';
6
+ import { useChartData } from '../../context/ChartContext';
7
+ import { useScaleChecked } from '../../context/ScaleContext';
8
+ import { usePanelPreferences } from '../../hooks/usePanelPreferences';
9
+ import { PathBuilder } from '../../utility/PathBuilder';
10
+ import { getYScaleWithRation } from '../utilities/scale';
11
+ import { sliceArrayForDomain, useMatrix } from './useMatrix';
12
+ function useYScale(scaleRatio, yDomain) {
13
+ const { margin, height } = useChartData();
14
+ return getYScaleWithRation({
15
+ height,
16
+ yDomain,
17
+ scaleRatio,
18
+ margin,
19
+ });
20
+ }
21
+ function usePath(pathPoints, scaleRatio, yDomain) {
22
+ const { scaleX } = useScaleChecked();
23
+ const scaleY = useYScale(scaleRatio, yDomain);
24
+ const pathBuilder = new PathBuilder();
25
+ const xScaler = scaleX();
26
+ pathBuilder.moveTo(xScaler(pathPoints.x[0]), scaleY(pathPoints.y[0]));
27
+ for (let i = 1; i < pathPoints.x.length; i++) {
28
+ pathBuilder.lineTo(xScaler(pathPoints.x[i]), scaleY(pathPoints.y[i]));
29
+ }
30
+ return pathBuilder.toString();
31
+ }
32
+ function useAreaPath(pathPoints, scaleRatio, yDomain) {
33
+ const { scaleX } = useScaleChecked();
34
+ const scaleY = useYScale(scaleRatio, yDomain);
35
+ const pathBuilder = new PathBuilder();
36
+ const pathBuilder2 = new PathBuilder();
37
+ const xScaler = scaleX();
38
+ pathBuilder.moveTo(xScaler(pathPoints.x[0]), scaleY(pathPoints.y1[0]));
39
+ for (let i = 1; i < pathPoints.x.length; i++) {
40
+ pathBuilder.lineTo(xScaler(pathPoints.x[i]), scaleY(pathPoints.y1[i]));
41
+ }
42
+ for (let i = pathPoints.x.length - 1; i >= 0; i--) {
43
+ pathBuilder2.lineTo(xScaler(pathPoints.x[i]), scaleY(pathPoints.y2[i]));
44
+ }
45
+ return pathBuilder.concatPath(pathBuilder2);
46
+ }
47
+ function useBoxPlot() {
48
+ const matrix = useMatrix();
49
+ const { xDomain: [from, to], } = useChartData();
50
+ return useMemo(() => {
51
+ if (!matrix)
52
+ return null;
53
+ const { x, matrixY } = matrix;
54
+ const { max, min, median, q1, q3 } = matrixToBoxPlot(matrixY);
55
+ const fromIndex = xFindClosestIndex(x, from);
56
+ const toIndex = xFindClosestIndex(x, to);
57
+ const yDomain = extent(median);
58
+ return {
59
+ x: sliceArrayForDomain(x, { fromIndex, toIndex }),
60
+ max: sliceArrayForDomain(max, { fromIndex, toIndex }),
61
+ min: sliceArrayForDomain(min, { fromIndex, toIndex }),
62
+ median: sliceArrayForDomain(median, { fromIndex, toIndex }),
63
+ q1: sliceArrayForDomain(q1, { fromIndex, toIndex }),
64
+ q3: sliceArrayForDomain(q3, { fromIndex, toIndex }),
65
+ yDomain,
66
+ };
67
+ }, [from, matrix, to]);
68
+ }
69
+ export function Boxplot() {
70
+ const { view: { spectra: { activeTab }, }, } = useChartData();
71
+ const options = usePanelPreferences('matrixGeneration', activeTab);
72
+ if (!options)
73
+ return;
74
+ const { scaleRatio, showBoxPlot } = options;
75
+ if (!showBoxPlot)
76
+ return null;
77
+ return _jsx(InnerBoxplot, { scaleRatio: scaleRatio });
78
+ }
79
+ export function InnerBoxplot(props) {
80
+ const { scaleRatio } = props;
81
+ const data = useBoxPlot();
82
+ const { displayerKey } = useChartData();
83
+ if (!data)
84
+ return null;
85
+ const { x, max, min, median, q1, q3, yDomain } = data;
86
+ return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: [_jsx(RenderAreaPath, { x: x, y1: max, y2: min, color: "black", scaleRatio: scaleRatio, yDomain: yDomain }), _jsx(RenderAreaPath, { x: x, y1: q3, y2: q1, color: "black", scaleRatio: scaleRatio, yDomain: yDomain }), _jsx(RenderPath, { x: x, y: median, color: "black", scaleRatio: scaleRatio, yDomain: yDomain })] }));
87
+ }
88
+ function RenderAreaPath(props) {
89
+ const { x, y1, y2, scaleRatio, color, yDomain } = props;
90
+ const areaPath = useAreaPath({ x, y1, y2 }, scaleRatio, yDomain);
91
+ return _jsx("path", { d: areaPath, fill: color, opacity: 0.2 });
92
+ }
93
+ function RenderPath(props) {
94
+ const { x, y, scaleRatio, color, yDomain } = props;
95
+ const areaPath = usePath({ x, y }, scaleRatio, yDomain);
96
+ return _jsx("path", { d: areaPath, fill: "transparent", stroke: color });
97
+ }
@@ -0,0 +1,5 @@
1
+ export declare function Stocsy(): import("react/jsx-runtime").JSX.Element | null | undefined;
2
+ export declare function InnerStocsy({ scaleRatio, chemicalShift }: {
3
+ scaleRatio: any;
4
+ chemicalShift: any;
5
+ }): import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { extent } from 'd3';
3
+ import { xFindClosestIndex } from 'ml-spectra-processing';
4
+ import { matrixToStocsy } from 'nmr-processing';
5
+ import { useMemo } from 'react';
6
+ import { useChartData } from '../../context/ChartContext';
7
+ import { useScaleChecked } from '../../context/ScaleContext';
8
+ import { usePanelPreferences } from '../../hooks/usePanelPreferences';
9
+ import { PathBuilder } from '../../utility/PathBuilder';
10
+ import { getYScaleWithRation } from '../utilities/scale';
11
+ import { sliceArrayForDomain, groupPointsByColor, useMatrix, } from './useMatrix';
12
+ function useStocsy(chemicalShift) {
13
+ const matrix = useMatrix();
14
+ return useMemo(() => {
15
+ if (!matrix)
16
+ return null;
17
+ const { x, matrixY } = matrix;
18
+ const cIndex = xFindClosestIndex(x, chemicalShift ?? x[0]);
19
+ const { color, y } = matrixToStocsy(matrixY, cIndex);
20
+ const yDomain = extent(y);
21
+ return {
22
+ color,
23
+ y,
24
+ yDomain,
25
+ x,
26
+ };
27
+ }, [chemicalShift, matrix]);
28
+ }
29
+ function useSliceStocsyData(options) {
30
+ const { xDomain: [from, to], } = useChartData();
31
+ return useMemo(() => {
32
+ if (!options)
33
+ return null;
34
+ const { color, y, x } = options;
35
+ const fromIndex = xFindClosestIndex(x, from);
36
+ const toIndex = xFindClosestIndex(x, to);
37
+ return {
38
+ x: sliceArrayForDomain(x, { fromIndex, toIndex }),
39
+ y: sliceArrayForDomain(y, { fromIndex, toIndex }),
40
+ color: sliceArrayForDomain(color, { fromIndex, toIndex }),
41
+ };
42
+ }, [from, options, to]);
43
+ }
44
+ export function Stocsy() {
45
+ const { view: { spectra: { activeTab }, }, } = useChartData();
46
+ const options = usePanelPreferences('matrixGeneration', activeTab);
47
+ if (!options)
48
+ return;
49
+ const { scaleRatio, showStocsy, chemicalShift } = options;
50
+ if (!showStocsy)
51
+ return null;
52
+ return _jsx(InnerStocsy, { scaleRatio: scaleRatio, chemicalShift: chemicalShift });
53
+ }
54
+ export function InnerStocsy({ scaleRatio, chemicalShift }) {
55
+ const stocsyData = useStocsy(chemicalShift);
56
+ const data = useSliceStocsyData(stocsyData);
57
+ const { displayerKey } = useChartData();
58
+ if (!data || !stocsyData)
59
+ return null;
60
+ const { yDomain } = stocsyData;
61
+ const { x, y, color } = data;
62
+ return (_jsxs("g", { clipPath: `url(#${displayerKey}clip-chart-1d)`, children: [_jsx(StocsyIndexPoint, { chemicalShift: chemicalShift }), _jsx(RenderStocsyAsSVG, { x: x, y: y, color: color, scaleRatio: scaleRatio, yDomain: yDomain })] }));
63
+ }
64
+ function useYScale(scaleRatio, yDomain) {
65
+ const { margin, height } = useChartData();
66
+ return getYScaleWithRation({
67
+ height,
68
+ yDomain,
69
+ scaleRatio,
70
+ margin,
71
+ });
72
+ }
73
+ function StocsyIndexPoint(props) {
74
+ const { chemicalShift } = props;
75
+ const { scaleX } = useScaleChecked();
76
+ const { xDomain: [from, to], } = useChartData();
77
+ if (!chemicalShift || chemicalShift < from || chemicalShift > to)
78
+ return null;
79
+ const xPixel = scaleX()(chemicalShift);
80
+ return (_jsx("g", { transform: `translate(${xPixel} 0)`, children: _jsx("line", { x1: -0.5, y1: 0, x2: -0.5, y2: "100%", stroke: "red", strokeDasharray: "5 2" }) }));
81
+ }
82
+ function RenderStocsyAsSVG(props) {
83
+ const { x, y, color, scaleRatio, yDomain } = props;
84
+ const scaleY = useYScale(scaleRatio, yDomain);
85
+ const { scaleX } = useScaleChecked();
86
+ const colorGroups = groupPointsByColor({ x, y, color });
87
+ const xScaler = scaleX();
88
+ return Object.keys(colorGroups).map((color) => {
89
+ const points = colorGroups[color];
90
+ const pathBuilder = new PathBuilder();
91
+ pathBuilder.moveTo(xScaler(points[0].x), scaleY(points[0].y));
92
+ for (let i = 1; i < points.length; i++) {
93
+ const point = points[i];
94
+ pathBuilder.lineTo(xScaler(points[i].x), scaleY(points[i].y));
95
+ if (point.endPath && i < points.length - 1) {
96
+ pathBuilder.moveTo(xScaler(points[i + 1].x), scaleY(points[i + 1].y));
97
+ }
98
+ }
99
+ return (_jsx("path", { d: pathBuilder.toString(), stroke: color, fill: "transparent" }, color));
100
+ });
101
+ }
@@ -0,0 +1,29 @@
1
+ import { NumberArray } from 'cheminfo-types';
2
+ /**
3
+ * This method will slice the array from the fromIndex to the toIndex and add the first and last element of the original array
4
+ * if needed
5
+ * It will also add one extra point at the beginning or the end if the fromIndex or toIndex is not the first or the last point of the array
6
+ *
7
+ * @param array
8
+ * @param options
9
+ * @returns
10
+ */
11
+ export declare function sliceArrayForDomain<T extends string[] | NumberArray>(array: T, options: {
12
+ fromIndex: number;
13
+ toIndex: number;
14
+ }): T;
15
+ export declare function useMatrix(): {
16
+ x: Float64Array | never[];
17
+ matrixY: Float64Array[];
18
+ } | null;
19
+ interface InterpolateColorsPointsOptions {
20
+ x: Float64Array | number[];
21
+ y: number[];
22
+ color: string[];
23
+ }
24
+ export declare function groupPointsByColor(data: InterpolateColorsPointsOptions): Record<string, {
25
+ x: number;
26
+ y: number;
27
+ endPath: boolean;
28
+ }[]>;
29
+ export {};
@@ -0,0 +1,93 @@
1
+ import { Filters } from 'nmr-processing';
2
+ import { useMemo } from 'react';
3
+ import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
4
+ import { useChartData } from '../../context/ChartContext';
5
+ import useSpectraByActiveNucleus from '../../hooks/useSpectraPerNucleus';
6
+ const { signalProcessing } = Filters;
7
+ /**
8
+ * This method will slice the array from the fromIndex to the toIndex and add the first and last element of the original array
9
+ * if needed
10
+ * It will also add one extra point at the beginning or the end if the fromIndex or toIndex is not the first or the last point of the array
11
+ *
12
+ * @param array
13
+ * @param options
14
+ * @returns
15
+ */
16
+ export function sliceArrayForDomain(array, options) {
17
+ let { fromIndex, toIndex } = options;
18
+ if (fromIndex > 0)
19
+ fromIndex--;
20
+ if (toIndex < array.length)
21
+ toIndex++;
22
+ // because slice does not include the last index we need to add one
23
+ if (toIndex < array.length)
24
+ toIndex++;
25
+ if (fromIndex > 0 || toIndex < array.length) {
26
+ return array.slice(fromIndex, toIndex);
27
+ }
28
+ return array;
29
+ }
30
+ function getX(spectra) {
31
+ const spectrum = spectra?.[0];
32
+ if (!spectrum || !isSpectrum1D(spectrum))
33
+ return [];
34
+ return spectrum.data.x;
35
+ }
36
+ export function useMatrix() {
37
+ const { displayerMode } = useChartData();
38
+ const spectra = useSpectraByActiveNucleus();
39
+ return useMemo(() => {
40
+ if (displayerMode !== '1D')
41
+ return null;
42
+ const matrixY = [];
43
+ for (let i = 0; i < spectra.length; i++) {
44
+ const spectrum = spectra[i];
45
+ const filter = spectrum.filters.find((filter) => filter.name === signalProcessing.id);
46
+ if (isSpectrum1D(spectrum) && filter?.flag) {
47
+ matrixY[i] = spectrum.data.re;
48
+ }
49
+ }
50
+ if (matrixY.length === 0)
51
+ return null;
52
+ return {
53
+ x: getX(spectra) || [],
54
+ matrixY,
55
+ };
56
+ }, [displayerMode, spectra]);
57
+ }
58
+ export function groupPointsByColor(data) {
59
+ const groups = {};
60
+ for (let i = 0; i < data.color.length - 1; i++) {
61
+ const color = data.color[i];
62
+ const x1 = data.x[i];
63
+ const y1 = data.y[i];
64
+ const nextColor = data.color[i + 1];
65
+ const x2 = data.x[i + 1];
66
+ const y2 = data.y[i + 1];
67
+ // add the original point
68
+ if (!groups[color])
69
+ groups[color] = [];
70
+ groups[color].push({ x: x1, y: y1, endPath: false });
71
+ // If the next point has a different color, add a segment with that color
72
+ if (color !== nextColor) {
73
+ // add the interpolated point
74
+ const interpolatedX = (x1 + x2) / 2;
75
+ const interpolatedY = (y1 + y2) / 2;
76
+ groups[color].push({ x: interpolatedX, y: interpolatedY, endPath: true });
77
+ if (!groups[nextColor])
78
+ groups[nextColor] = [];
79
+ groups[nextColor].push({
80
+ x: interpolatedX,
81
+ y: interpolatedY,
82
+ endPath: false,
83
+ });
84
+ }
85
+ }
86
+ // Add the last original point
87
+ const lastIndex = data.x.length - 1;
88
+ const lastColor = data.color[lastIndex];
89
+ const lastX = data.x[lastIndex];
90
+ const lastY = data.y[lastIndex];
91
+ groups[lastColor].push({ x: lastX, y: lastY, endPath: true });
92
+ return groups;
93
+ }
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { PeaksAnnotationsProps } from './Peaks';
3
2
  declare function PeakAnnotationsTreeStyle(props: PeaksAnnotationsProps): import("react/jsx-runtime").JSX.Element;
4
3
  declare const _default: import("react").MemoExoticComponent<typeof PeakAnnotationsTreeStyle>;
@@ -1,11 +1,12 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Formik } from 'formik';
2
+ import { yupResolver } from '@hookform/resolvers/yup';
3
3
  import { createContext, useCallback, useContext, useMemo, useState, } from 'react';
4
+ import { useForm } from 'react-hook-form';
4
5
  import * as Yup from 'yup';
5
6
  import { useChartData } from '../../context/ChartContext';
6
7
  import { useDispatch } from '../../context/DispatchContext';
7
8
  import { useScaleChecked } from '../../context/ScaleContext';
8
- import FormikInput from '../../elements/formik/FormikInput';
9
+ import { NumberInput2Controller } from '../../elements/NumberInput2Controller';
9
10
  import { useActiveSpectrum } from '../../hooks/useActiveSpectrum';
10
11
  const validationSchema = Yup.object({
11
12
  value: Yup.number().required(),
@@ -71,6 +72,10 @@ export function PeakEditionProvider({ children }) {
71
72
  }
72
73
  function PeakEditionField({ value, onClose }) {
73
74
  const dispatch = useDispatch();
75
+ const { control, handleSubmit } = useForm({
76
+ defaultValues: { value },
77
+ resolver: yupResolver(validationSchema),
78
+ });
74
79
  function keyDownCheck(event) {
75
80
  if (event.key === 'Enter') {
76
81
  return true;
@@ -80,20 +85,21 @@ function PeakEditionField({ value, onClose }) {
80
85
  return false;
81
86
  }
82
87
  }
83
- function hanldeOnSubmit({ value: newValue }) {
88
+ function handleOnSubmit({ value: newValue }) {
84
89
  if (value) {
85
90
  const shift = newValue - value;
86
91
  dispatch({ type: 'SHIFT_SPECTRUM', payload: { shift } });
87
92
  onClose();
88
93
  }
89
94
  }
90
- return (_jsx(Formik, { initialValues: { value }, onSubmit: hanldeOnSubmit, validationSchema: validationSchema, children: ({ submitForm }) => (_jsx(FormikInput, { type: "number", style: {
91
- input: {
92
- height: `${InputDimension.height}px`,
93
- padding: '5px',
94
- outline: 'none',
95
- },
96
- }, name: "value", autoSelect: true, onKeyDown: (e) => keyDownCheck(e) && submitForm(), onClick: stopPropagation, onMouseDown: stopPropagation })) }));
95
+ return (_jsx(NumberInput2Controller, { control: control, name: "value", style: {
96
+ height: `${InputDimension.height}px`,
97
+ outline: 'none',
98
+ }, autoSelect: true, onKeyDown: (e) => {
99
+ if (keyDownCheck(e)) {
100
+ void handleSubmit(handleOnSubmit)();
101
+ }
102
+ }, onClick: stopPropagation, onMouseDown: stopPropagation, buttonPosition: "none" }));
97
103
  }
98
104
  export function PeakEditionListener(props) {
99
105
  const { children, x, y, value, useScaleX = false, useScaleY = false, dx = 0, dy = -InputDimension.height, id, } = props;
@@ -1,6 +1,6 @@
1
1
  export function getDecimalsCount(max, format) {
2
2
  const numberOfDigits = format.replace(/\./, '').length;
3
- const fractionDigits = format.split('.')[1].length;
3
+ const fractionDigits = (format.split('.')[1] || '').length;
4
4
  return (Math.max(String(max.toFixed(0)).length, numberOfDigits - fractionDigits) +
5
5
  fractionDigits);
6
6
  }
@@ -25,7 +25,7 @@ function resolveGroupsIntersection(groups, options) {
25
25
  const { maxIteration = 3, groupMargin = 0 } = options;
26
26
  let iteration = 1;
27
27
  let hasIntersection = true;
28
- const newGroups = JSON.parse(JSON.stringify(groups));
28
+ const newGroups = structuredClone(groups);
29
29
  while (iteration < maxIteration && hasIntersection) {
30
30
  iteration++;
31
31
  hasIntersection = false;
@@ -23,6 +23,7 @@ interface IntegralYScaleOptions {
23
23
  scaleRatio: number;
24
24
  }
25
25
  declare function getIntegralYScale(options: IntegralYScaleOptions): import("d3-scale").ScaleLinear<number, number, never>;
26
+ declare function getYScaleWithRation(options: IntegralYScaleOptions): import("d3-scale").ScaleLinear<number, number, never>;
26
27
  declare function reScaleY(scale: number, { domain, height, margin }: {
27
28
  domain: any;
28
29
  height: any;
@@ -30,4 +31,4 @@ declare function reScaleY(scale: number, { domain, height, margin }: {
30
31
  }): number[];
31
32
  declare function useScaleX(): (spectrumId?: null) => import("d3-scale").ScaleLinear<number, number, never>;
32
33
  declare function useScaleY(): (spectrumId?: null) => import("d3-scale").ScaleLinear<number, number, never>;
33
- export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, };
34
+ export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, getYScaleWithRation, };
@@ -34,6 +34,11 @@ function getIntegralYScale(options) {
34
34
  const [min, max] = yDomain;
35
35
  return scaleLinear([min * scaleRatio, max * scaleRatio], [height * 0.3, margin.top + height * 0.1]);
36
36
  }
37
+ function getYScaleWithRation(options) {
38
+ const { height, margin, yDomain, scaleRatio } = options;
39
+ const [min, max] = yDomain;
40
+ return scaleLinear([min * scaleRatio, max * scaleRatio], [height - margin.bottom - SPECTRA_BOTTOM_MARGIN, margin.top]);
41
+ }
37
42
  function reScaleY(scale, { domain, height, margin }) {
38
43
  const _scale = scaleLinear(domain, [height - margin.bottom, margin.top]);
39
44
  const t = zoomIdentity
@@ -51,4 +56,4 @@ function useScaleY() {
51
56
  const verticalAlign = useVerticalAlign();
52
57
  return useCallback((spectrumId = null) => getYScale({ margin, height, verticalAlign, yDomain, yDomains }, spectrumId), [margin, height, verticalAlign, yDomain, yDomains]);
53
58
  }
54
- export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, };
59
+ export { useScaleX, useScaleY, getXScale, getYScale, getIntegralYScale, reScaleY, getYScaleWithRation, };