@rfkit/charts 1.3.3 → 1.3.6

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.
package/index.js CHANGED
@@ -14432,25 +14432,49 @@ const useMarkers = (props)=>{
14432
14432
  const totalPoints = segments.totalPoints || dataLength;
14433
14433
  const intervalWidth = zoom.interval.end - zoom.interval.start + 1;
14434
14434
  const insideLeft = (target.left * totalPoints / 100 - zoom.interval.start) * 100 / intervalWidth;
14435
- let currentIndex = Math.round((dataLength - 1) * insideLeft / 100);
14436
- currentIndex = Math.max(1, Math.min(dataLength - 2, currentIndex));
14437
- const isPeakAt = (index)=>{
14438
- if (index <= 0 || index >= dataLength - 1) return false;
14439
- const value1 = data[index];
14440
- return value1 > data[index - 1] && value1 > data[index + 1];
14441
- };
14435
+ let currentIndex = Math.floor(dataLength * insideLeft / 100);
14436
+ if (100 === insideLeft) currentIndex = dataLength - 1;
14442
14437
  let nextIndex = -1;
14443
- if ('left' === direction) {
14444
- for(let i = currentIndex - 1; i > 0; i -= 1)if (isPeakAt(i)) {
14438
+ if (data.peaks?.peaks && Array.isArray(data.peaks.peaks)) {
14439
+ const peaks = data.peaks.peaks;
14440
+ if ('left' === direction) {
14441
+ let closestDist = 1 / 0;
14442
+ for (const peak of peaks)if (peak.index < currentIndex) {
14443
+ const dist = currentIndex - peak.index;
14444
+ if (dist < closestDist) {
14445
+ closestDist = dist;
14446
+ nextIndex = peak.index;
14447
+ }
14448
+ }
14449
+ } else {
14450
+ let closestDist = 1 / 0;
14451
+ for (const peak of peaks)if (peak.index > currentIndex) {
14452
+ const dist = peak.index - currentIndex;
14453
+ if (dist < closestDist) {
14454
+ closestDist = dist;
14455
+ nextIndex = peak.index;
14456
+ }
14457
+ }
14458
+ }
14459
+ }
14460
+ if (-1 === nextIndex) {
14461
+ const isPeakAt = (index)=>{
14462
+ if (index <= 0 || index >= dataLength - 1) return false;
14463
+ const value1 = data[index];
14464
+ return value1 > data[index - 1] && value1 > data[index + 1];
14465
+ };
14466
+ if ('left' === direction) {
14467
+ for(let i = currentIndex - 1; i > 0; i -= 1)if (isPeakAt(i)) {
14468
+ nextIndex = i;
14469
+ break;
14470
+ }
14471
+ } else for(let i = currentIndex + 1; i < dataLength - 1; i += 1)if (isPeakAt(i)) {
14445
14472
  nextIndex = i;
14446
14473
  break;
14447
14474
  }
14448
- } else for(let i = currentIndex + 1; i < dataLength - 1; i += 1)if (isPeakAt(i)) {
14449
- nextIndex = i;
14450
- break;
14451
14475
  }
14452
14476
  if (-1 === nextIndex) return prevState;
14453
- const nextInsideLeft = 100 * nextIndex / (dataLength - 1);
14477
+ const nextInsideLeft = (nextIndex + 0.5) * 100 / dataLength;
14454
14478
  const nextLeft = (nextInsideLeft * intervalWidth / 100 + zoom.interval.start) * (100 / totalPoints);
14455
14479
  const nextMarkers = prevState.markers.map((m)=>{
14456
14480
  if (m.id !== markerId) return {
@@ -4,7 +4,7 @@
4
4
  import { Fluorescence as Chart } from '@rfkit/renderer';
5
5
  import { GradientRenderer, type GradientRenderState } from '../base';
6
6
  interface FluorescenceData {
7
- fluorescenceData: Map<number, number>[];
7
+ fluorescenceData: Uint32Array;
8
8
  fluorescenceMaxCount: number;
9
9
  }
10
10
  interface FluorescenceRenderProps {
package/package.json CHANGED
@@ -5,6 +5,6 @@
5
5
  "types": "index.d.ts",
6
6
  "author": "Hxgh",
7
7
  "license": "MIT",
8
- "version": "1.3.3",
8
+ "version": "1.3.6",
9
9
  "private": false
10
10
  }
@@ -69,7 +69,7 @@ export interface PublishHeatmap {
69
69
  export interface PublishFluorescence {
70
70
  pstype: PSType.Fluorescence;
71
71
  data: {
72
- fluorescenceData: Map<number, number>[];
72
+ fluorescenceData: Uint32Array;
73
73
  fluorescenceMaxCount: number;
74
74
  };
75
75
  }