@vitessce/scatterplot-embedding 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-64ed3bae.js";
2
+ import { B as BaseDecoder } from "./index-c4323615.js";
3
3
  import "react";
4
4
  import "@vitessce/vit-s";
5
5
  import "react-dom";
@@ -121180,16 +121180,16 @@ function addDecoder(cases, importFn) {
121180
121180
  }
121181
121181
  cases.forEach((c2) => registry$1.set(c2, importFn));
121182
121182
  }
121183
- addDecoder([void 0, 1], () => import("./raw-4ea71ae5.js").then((m2) => m2.default));
121184
- addDecoder(5, () => import("./lzw-194af29e.js").then((m2) => m2.default));
121183
+ addDecoder([void 0, 1], () => import("./raw-562e7d1c.js").then((m2) => m2.default));
121184
+ addDecoder(5, () => import("./lzw-0659de0e.js").then((m2) => m2.default));
121185
121185
  addDecoder(6, () => {
121186
121186
  throw new Error("old style JPEG compression is not supported.");
121187
121187
  });
121188
- addDecoder(7, () => import("./jpeg-26d14b38.js").then((m2) => m2.default));
121189
- addDecoder([8, 32946], () => import("./deflate-2d5bfeab.js").then((m2) => m2.default));
121190
- addDecoder(32773, () => import("./packbits-40fe7e7e.js").then((m2) => m2.default));
121191
- addDecoder(34887, () => import("./lerc-925e402e.js").then((m2) => m2.default));
121192
- addDecoder(50001, () => import("./webimage-cd737900.js").then((m2) => m2.default));
121188
+ addDecoder(7, () => import("./jpeg-0c6f4d5b.js").then((m2) => m2.default));
121189
+ addDecoder([8, 32946], () => import("./deflate-49eb8bd8.js").then((m2) => m2.default));
121190
+ addDecoder(32773, () => import("./packbits-f0484b5e.js").then((m2) => m2.default));
121191
+ addDecoder(34887, () => import("./lerc-157806a7.js").then((m2) => m2.default));
121192
+ addDecoder(50001, () => import("./webimage-ab07cd7f.js").then((m2) => m2.default));
121193
121193
  function decodeRowAcc(row, stride) {
121194
121194
  let length2 = row.length - stride;
121195
121195
  let offset5 = 0;
@@ -130089,6 +130089,67 @@ function makeBoundingBox(viewState) {
130089
130089
  viewport.unproject([0, viewport.height])
130090
130090
  ];
130091
130091
  }
130092
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
130093
+ const MIN_TARGET = TARGETS[0];
130094
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
130095
+ const SI_PREFIXES = [
130096
+ { symbol: "Y", exponent: 24 },
130097
+ { symbol: "Z", exponent: 21 },
130098
+ { symbol: "E", exponent: 18 },
130099
+ { symbol: "P", exponent: 15 },
130100
+ { symbol: "T", exponent: 12 },
130101
+ { symbol: "G", exponent: 9 },
130102
+ { symbol: "M", exponent: 6 },
130103
+ { symbol: "k", exponent: 3 },
130104
+ { symbol: "h", exponent: 2 },
130105
+ { symbol: "da", exponent: 1 },
130106
+ { symbol: "", exponent: 0 },
130107
+ { symbol: "d", exponent: -1 },
130108
+ { symbol: "c", exponent: -2 },
130109
+ { symbol: "m", exponent: -3 },
130110
+ { symbol: "µ", exponent: -6 },
130111
+ { symbol: "n", exponent: -9 },
130112
+ { symbol: "p", exponent: -12 },
130113
+ { symbol: "f", exponent: -15 },
130114
+ { symbol: "a", exponent: -18 },
130115
+ { symbol: "z", exponent: -21 },
130116
+ { symbol: "y", exponent: -24 }
130117
+ ];
130118
+ function sizeToMeters(size, unit2) {
130119
+ if (!unit2 || unit2 === "m") {
130120
+ return size;
130121
+ }
130122
+ if (unit2.length > 1) {
130123
+ let unitPrefix = unit2.substring(0, unit2.length - 1);
130124
+ if (unitPrefix === "u") {
130125
+ unitPrefix = "µ";
130126
+ }
130127
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
130128
+ if (unitObj) {
130129
+ return size * 10 ** unitObj.exponent;
130130
+ }
130131
+ }
130132
+ throw new Error("Received unknown unit");
130133
+ }
130134
+ function snapValue(value) {
130135
+ let magnitude = 0;
130136
+ if (value < MIN_TARGET || value > MAX_TARGET) {
130137
+ magnitude = Math.floor(Math.log10(value));
130138
+ }
130139
+ let snappedUnit = SI_PREFIXES.find(
130140
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
130141
+ );
130142
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
130143
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
130144
+ snappedUnit = SI_PREFIXES.find(
130145
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
130146
+ );
130147
+ adjustedValue = value / 10 ** snappedUnit.exponent;
130148
+ }
130149
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
130150
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
130151
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
130152
+ }
130092
130153
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
130093
130154
 
130094
130155
  precision highp float;
@@ -130856,26 +130917,27 @@ const OverviewLayer = class extends CompositeLayer {
130856
130917
  OverviewLayer.layerName = "OverviewLayer";
130857
130918
  OverviewLayer.defaultProps = defaultProps$3;
130858
130919
  function getPosition$1(boundingBox, position, length2) {
130859
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
130920
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
130921
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
130860
130922
  switch (position) {
130861
130923
  case "bottom-right": {
130862
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
130863
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
130924
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
130925
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
130864
130926
  return [yCoord, xLeftCoord];
130865
130927
  }
130866
130928
  case "top-right": {
130867
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
130868
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
130929
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
130930
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
130869
130931
  return [yCoord, xLeftCoord];
130870
130932
  }
130871
130933
  case "top-left": {
130872
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
130873
- const xLeftCoord = viewLength * length2;
130934
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
130935
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
130874
130936
  return [yCoord, xLeftCoord];
130875
130937
  }
130876
130938
  case "bottom-left": {
130877
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
130878
- const xLeftCoord = viewLength * length2;
130939
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
130940
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
130879
130941
  return [yCoord, xLeftCoord];
130880
130942
  }
130881
130943
  default: {
@@ -130893,11 +130955,12 @@ const defaultProps$2$1 = {
130893
130955
  unit: { type: "string", value: "", compare: true },
130894
130956
  size: { type: "number", value: 1, compare: true },
130895
130957
  position: { type: "string", value: "bottom-right", compare: true },
130896
- length: { type: "number", value: 0.085, compare: true }
130958
+ length: { type: "number", value: 0.085, compare: true },
130959
+ snap: { type: "boolean", value: false, compare: true }
130897
130960
  };
130898
130961
  const ScaleBarLayer = class extends CompositeLayer {
130899
130962
  renderLayers() {
130900
- const { id, unit: unit2, size, position, viewState, length: length2 } = this.props;
130963
+ const { id, unit: unit2, size, position, viewState, length: length2, snap } = this.props;
130901
130964
  const boundingBox = makeBoundingBox(viewState);
130902
130965
  const { zoom } = viewState;
130903
130966
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -130906,15 +130969,27 @@ const ScaleBarLayer = class extends CompositeLayer {
130906
130969
  2 ** (-zoom + 1.5),
130907
130970
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
130908
130971
  );
130909
- const numUnits = barLength * size;
130972
+ let adjustedBarLength = barLength;
130973
+ let displayNumber = (barLength * size).toPrecision(5);
130974
+ let displayUnit = unit2;
130975
+ if (snap) {
130976
+ const meterSize = sizeToMeters(size, unit2);
130977
+ const numUnits = barLength * meterSize;
130978
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
130979
+ adjustedBarLength = snappedOrigUnits / meterSize;
130980
+ displayNumber = snappedNewUnits;
130981
+ displayUnit = `${snappedUnitPrefix}m`;
130982
+ }
130910
130983
  const [yCoord, xLeftCoord] = getPosition$1(boundingBox, position, length2);
130984
+ const xRightCoord = xLeftCoord + barLength;
130985
+ const isLeft = position.endsWith("-left");
130911
130986
  const lengthBar = new LineLayer({
130912
130987
  id: `scale-bar-length-${id}`,
130913
130988
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130914
130989
  data: [
130915
130990
  [
130916
- [xLeftCoord, yCoord],
130917
- [xLeftCoord + barLength, yCoord]
130991
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
130992
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
130918
130993
  ]
130919
130994
  ],
130920
130995
  getSourcePosition: (d) => d[0],
@@ -130927,8 +131002,14 @@ const ScaleBarLayer = class extends CompositeLayer {
130927
131002
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130928
131003
  data: [
130929
131004
  [
130930
- [xLeftCoord, yCoord - barHeight],
130931
- [xLeftCoord, yCoord + barHeight]
131005
+ [
131006
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
131007
+ yCoord - barHeight
131008
+ ],
131009
+ [
131010
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
131011
+ yCoord + barHeight
131012
+ ]
130932
131013
  ]
130933
131014
  ],
130934
131015
  getSourcePosition: (d) => d[0],
@@ -130941,8 +131022,14 @@ const ScaleBarLayer = class extends CompositeLayer {
130941
131022
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130942
131023
  data: [
130943
131024
  [
130944
- [xLeftCoord + barLength, yCoord - barHeight],
130945
- [xLeftCoord + barLength, yCoord + barHeight]
131025
+ [
131026
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
131027
+ yCoord - barHeight
131028
+ ],
131029
+ [
131030
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
131031
+ yCoord + barHeight
131032
+ ]
130946
131033
  ]
130947
131034
  ],
130948
131035
  getSourcePosition: (d) => d[0],
@@ -130955,8 +131042,11 @@ const ScaleBarLayer = class extends CompositeLayer {
130955
131042
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
130956
131043
  data: [
130957
131044
  {
130958
- text: numUnits.toPrecision(5) + unit2,
130959
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
131045
+ text: `${displayNumber}${displayUnit}`,
131046
+ position: [
131047
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
131048
+ yCoord + barHeight * 4
131049
+ ]
130960
131050
  }
130961
131051
  ],
130962
131052
  getColor: [220, 220, 220, 255],
@@ -130965,7 +131055,7 @@ const ScaleBarLayer = class extends CompositeLayer {
130965
131055
  sizeUnits: "meters",
130966
131056
  sizeScale: 2 ** -zoom,
130967
131057
  characterSet: [
130968
- ...unit2.split(""),
131058
+ ...displayUnit.split(""),
130969
131059
  ...range(10).map((i2) => String(i2)),
130970
131060
  ".",
130971
131061
  "e",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { E } from "./index-64ed3bae.js";
1
+ import { E } from "./index-c4323615.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-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-c4323615.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-64ed3bae.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-c4323615.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-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-c4323615.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-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-c4323615.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-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-c4323615.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-64ed3bae.js";
1
+ import { B as BaseDecoder } from "./index-c4323615.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-embedding",
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,12 +20,12 @@
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/legend": "3.2.1",
25
- "@vitessce/scatterplot": "3.2.1",
26
- "@vitessce/sets-utils": "3.2.1",
27
- "@vitessce/utils": "3.2.1",
28
- "@vitessce/vit-s": "3.2.1"
23
+ "@vitessce/constants-internal": "3.2.2",
24
+ "@vitessce/legend": "3.2.2",
25
+ "@vitessce/scatterplot": "3.2.2",
26
+ "@vitessce/sets-utils": "3.2.2",
27
+ "@vitessce/utils": "3.2.2",
28
+ "@vitessce/vit-s": "3.2.2"
29
29
  },
30
30
  "devDependencies": {
31
31
  "react": "^18.0.0",