@vitessce/scatterplot-gating 3.2.1 → 3.2.2

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.
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { B as BaseDecoder } from "./index-743f7ba3.js";
2
+ import { B as BaseDecoder } from "./index-73600fb1.js";
3
3
  import "react";
4
4
  import "@vitessce/vit-s";
5
5
  import "react-dom";
@@ -121094,16 +121094,16 @@ function addDecoder(cases, importFn) {
121094
121094
  }
121095
121095
  cases.forEach((c2) => registry$1.set(c2, importFn));
121096
121096
  }
121097
- addDecoder([void 0, 1], () => import("./raw-4828923d.js").then((m2) => m2.default));
121098
- addDecoder(5, () => import("./lzw-8a95c676.js").then((m2) => m2.default));
121097
+ addDecoder([void 0, 1], () => import("./raw-1b8265a8.js").then((m2) => m2.default));
121098
+ addDecoder(5, () => import("./lzw-66141aea.js").then((m2) => m2.default));
121099
121099
  addDecoder(6, () => {
121100
121100
  throw new Error("old style JPEG compression is not supported.");
121101
121101
  });
121102
- addDecoder(7, () => import("./jpeg-da2166c3.js").then((m2) => m2.default));
121103
- addDecoder([8, 32946], () => import("./deflate-10f9d67d.js").then((m2) => m2.default));
121104
- addDecoder(32773, () => import("./packbits-3b55e8df.js").then((m2) => m2.default));
121105
- addDecoder(34887, () => import("./lerc-ea6f16cd.js").then((m2) => m2.default));
121106
- addDecoder(50001, () => import("./webimage-f3457c94.js").then((m2) => m2.default));
121102
+ addDecoder(7, () => import("./jpeg-d36cd1e8.js").then((m2) => m2.default));
121103
+ addDecoder([8, 32946], () => import("./deflate-34407526.js").then((m2) => m2.default));
121104
+ addDecoder(32773, () => import("./packbits-2838880b.js").then((m2) => m2.default));
121105
+ addDecoder(34887, () => import("./lerc-e5940768.js").then((m2) => m2.default));
121106
+ addDecoder(50001, () => import("./webimage-ae3e1d5b.js").then((m2) => m2.default));
121107
121107
  function decodeRowAcc(row, stride) {
121108
121108
  let length2 = row.length - stride;
121109
121109
  let offset5 = 0;
@@ -130003,6 +130003,67 @@ function makeBoundingBox(viewState) {
130003
130003
  viewport.unproject([0, viewport.height])
130004
130004
  ];
130005
130005
  }
130006
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
130007
+ const MIN_TARGET = TARGETS[0];
130008
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
130009
+ const SI_PREFIXES = [
130010
+ { symbol: "Y", exponent: 24 },
130011
+ { symbol: "Z", exponent: 21 },
130012
+ { symbol: "E", exponent: 18 },
130013
+ { symbol: "P", exponent: 15 },
130014
+ { symbol: "T", exponent: 12 },
130015
+ { symbol: "G", exponent: 9 },
130016
+ { symbol: "M", exponent: 6 },
130017
+ { symbol: "k", exponent: 3 },
130018
+ { symbol: "h", exponent: 2 },
130019
+ { symbol: "da", exponent: 1 },
130020
+ { symbol: "", exponent: 0 },
130021
+ { symbol: "d", exponent: -1 },
130022
+ { symbol: "c", exponent: -2 },
130023
+ { symbol: "m", exponent: -3 },
130024
+ { symbol: "µ", exponent: -6 },
130025
+ { symbol: "n", exponent: -9 },
130026
+ { symbol: "p", exponent: -12 },
130027
+ { symbol: "f", exponent: -15 },
130028
+ { symbol: "a", exponent: -18 },
130029
+ { symbol: "z", exponent: -21 },
130030
+ { symbol: "y", exponent: -24 }
130031
+ ];
130032
+ function sizeToMeters(size, unit) {
130033
+ if (!unit || unit === "m") {
130034
+ return size;
130035
+ }
130036
+ if (unit.length > 1) {
130037
+ let unitPrefix = unit.substring(0, unit.length - 1);
130038
+ if (unitPrefix === "u") {
130039
+ unitPrefix = "µ";
130040
+ }
130041
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
130042
+ if (unitObj) {
130043
+ return size * 10 ** unitObj.exponent;
130044
+ }
130045
+ }
130046
+ throw new Error("Received unknown unit");
130047
+ }
130048
+ function snapValue(value) {
130049
+ let magnitude = 0;
130050
+ if (value < MIN_TARGET || value > MAX_TARGET) {
130051
+ magnitude = Math.floor(Math.log10(value));
130052
+ }
130053
+ let snappedUnit = SI_PREFIXES.find(
130054
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
130055
+ );
130056
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
130057
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
130058
+ snappedUnit = SI_PREFIXES.find(
130059
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
130060
+ );
130061
+ adjustedValue = value / 10 ** snappedUnit.exponent;
130062
+ }
130063
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
130064
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
130065
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
130066
+ }
130006
130067
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
130007
130068
 
130008
130069
  precision highp float;
@@ -130770,26 +130831,27 @@ const OverviewLayer = class extends CompositeLayer {
130770
130831
  OverviewLayer.layerName = "OverviewLayer";
130771
130832
  OverviewLayer.defaultProps = defaultProps$3;
130772
130833
  function getPosition$1(boundingBox, position, length2) {
130773
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
130834
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
130835
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
130774
130836
  switch (position) {
130775
130837
  case "bottom-right": {
130776
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
130777
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
130838
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
130839
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
130778
130840
  return [yCoord, xLeftCoord];
130779
130841
  }
130780
130842
  case "top-right": {
130781
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
130782
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
130843
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
130844
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
130783
130845
  return [yCoord, xLeftCoord];
130784
130846
  }
130785
130847
  case "top-left": {
130786
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
130787
- const xLeftCoord = viewLength * length2;
130848
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
130849
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
130788
130850
  return [yCoord, xLeftCoord];
130789
130851
  }
130790
130852
  case "bottom-left": {
130791
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
130792
- const xLeftCoord = viewLength * length2;
130853
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
130854
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
130793
130855
  return [yCoord, xLeftCoord];
130794
130856
  }
130795
130857
  default: {
@@ -130807,11 +130869,12 @@ const defaultProps$2$1 = {
130807
130869
  unit: { type: "string", value: "", compare: true },
130808
130870
  size: { type: "number", value: 1, compare: true },
130809
130871
  position: { type: "string", value: "bottom-right", compare: true },
130810
- length: { type: "number", value: 0.085, compare: true }
130872
+ length: { type: "number", value: 0.085, compare: true },
130873
+ snap: { type: "boolean", value: false, compare: true }
130811
130874
  };
130812
130875
  const ScaleBarLayer = class extends CompositeLayer {
130813
130876
  renderLayers() {
130814
- const { id, unit, size, position, viewState, length: length2 } = this.props;
130877
+ const { id, unit, size, position, viewState, length: length2, snap } = this.props;
130815
130878
  const boundingBox = makeBoundingBox(viewState);
130816
130879
  const { zoom } = viewState;
130817
130880
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -130820,15 +130883,27 @@ const ScaleBarLayer = class extends CompositeLayer {
130820
130883
  2 ** (-zoom + 1.5),
130821
130884
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
130822
130885
  );
130823
- const numUnits = barLength * size;
130886
+ let adjustedBarLength = barLength;
130887
+ let displayNumber = (barLength * size).toPrecision(5);
130888
+ let displayUnit = unit;
130889
+ if (snap) {
130890
+ const meterSize = sizeToMeters(size, unit);
130891
+ const numUnits = barLength * meterSize;
130892
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
130893
+ adjustedBarLength = snappedOrigUnits / meterSize;
130894
+ displayNumber = snappedNewUnits;
130895
+ displayUnit = `${snappedUnitPrefix}m`;
130896
+ }
130824
130897
  const [yCoord, xLeftCoord] = getPosition$1(boundingBox, position, length2);
130898
+ const xRightCoord = xLeftCoord + barLength;
130899
+ const isLeft = position.endsWith("-left");
130825
130900
  const lengthBar = new LineLayer({
130826
130901
  id: `scale-bar-length-${id}`,
130827
130902
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130828
130903
  data: [
130829
130904
  [
130830
- [xLeftCoord, yCoord],
130831
- [xLeftCoord + barLength, yCoord]
130905
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
130906
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
130832
130907
  ]
130833
130908
  ],
130834
130909
  getSourcePosition: (d) => d[0],
@@ -130841,8 +130916,14 @@ const ScaleBarLayer = class extends CompositeLayer {
130841
130916
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130842
130917
  data: [
130843
130918
  [
130844
- [xLeftCoord, yCoord - barHeight],
130845
- [xLeftCoord, yCoord + barHeight]
130919
+ [
130920
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
130921
+ yCoord - barHeight
130922
+ ],
130923
+ [
130924
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
130925
+ yCoord + barHeight
130926
+ ]
130846
130927
  ]
130847
130928
  ],
130848
130929
  getSourcePosition: (d) => d[0],
@@ -130855,8 +130936,14 @@ const ScaleBarLayer = class extends CompositeLayer {
130855
130936
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130856
130937
  data: [
130857
130938
  [
130858
- [xLeftCoord + barLength, yCoord - barHeight],
130859
- [xLeftCoord + barLength, yCoord + barHeight]
130939
+ [
130940
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
130941
+ yCoord - barHeight
130942
+ ],
130943
+ [
130944
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
130945
+ yCoord + barHeight
130946
+ ]
130860
130947
  ]
130861
130948
  ],
130862
130949
  getSourcePosition: (d) => d[0],
@@ -130869,8 +130956,11 @@ const ScaleBarLayer = class extends CompositeLayer {
130869
130956
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130870
130957
  data: [
130871
130958
  {
130872
- text: numUnits.toPrecision(5) + unit,
130873
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
130959
+ text: `${displayNumber}${displayUnit}`,
130960
+ position: [
130961
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
130962
+ yCoord + barHeight * 4
130963
+ ]
130874
130964
  }
130875
130965
  ],
130876
130966
  getColor: [220, 220, 220, 255],
@@ -130879,7 +130969,7 @@ const ScaleBarLayer = class extends CompositeLayer {
130879
130969
  sizeUnits: "meters",
130880
130970
  sizeScale: 2 ** -zoom,
130881
130971
  characterSet: [
130882
- ...unit.split(""),
130972
+ ...displayUnit.split(""),
130883
130973
  ...range(10).map((i2) => String(i2)),
130884
130974
  ".",
130885
130975
  "e",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { G } from "./index-743f7ba3.js";
1
+ import { G } from "./index-73600fb1.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-743f7ba3.js";
1
+ import { B as BaseDecoder } from "./index-73600fb1.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-743f7ba3.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-73600fb1.js";
3
3
  import "react";
4
4
  import "@vitessce/vit-s";
5
5
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-743f7ba3.js";
1
+ import { B as BaseDecoder } from "./index-73600fb1.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-743f7ba3.js";
1
+ import { B as BaseDecoder } from "./index-73600fb1.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-743f7ba3.js";
1
+ import { B as BaseDecoder } from "./index-73600fb1.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-743f7ba3.js";
1
+ import { B as BaseDecoder } from "./index-73600fb1.js";
2
2
  import "react";
3
3
  import "@vitessce/vit-s";
4
4
  import "react-dom";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/scatterplot-gating",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,11 +20,11 @@
20
20
  "d3-array": "^2.4.0",
21
21
  "lodash-es": "^4.17.21",
22
22
  "react-aria": "^3.28.0",
23
- "@vitessce/constants-internal": "3.2.1",
24
- "@vitessce/scatterplot": "3.2.1",
25
- "@vitessce/sets-utils": "3.2.1",
26
- "@vitessce/utils": "3.2.1",
27
- "@vitessce/vit-s": "3.2.1"
23
+ "@vitessce/constants-internal": "3.2.2",
24
+ "@vitessce/scatterplot": "3.2.2",
25
+ "@vitessce/sets-utils": "3.2.2",
26
+ "@vitessce/utils": "3.2.2",
27
+ "@vitessce/vit-s": "3.2.2"
28
28
  },
29
29
  "devDependencies": {
30
30
  "react": "^18.0.0",