@vitessce/scatterplot 3.8.8 → 3.8.10
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/dist/{deflate-B59Iec3_.js → deflate-BUOOeR_H.js} +1 -1
- package/dist/{index-B9HtnmvK.js → index-BgH5JCMh.js} +19 -9
- package/dist/index.js +1 -1
- package/dist/{jpeg-BRLf1BFV.js → jpeg-DOj-mktM.js} +1 -1
- package/dist/{lerc-Bm1LBCBR.js → lerc-DJ1FEjnQ.js} +1 -1
- package/dist/{lzw-DdQkXqbQ.js → lzw-CgToJLS_.js} +1 -1
- package/dist/{packbits-D7iShEMY.js → packbits-Co4VqP5m.js} +1 -1
- package/dist/{raw-DAqPf4b8.js → raw-ChRkwMzK.js} +1 -1
- package/dist/{webimage-DVQqsXwn.js → webimage-Mf5GLiYz.js} +1 -1
- package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.d.ts +44 -2
- package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.d.ts.map +1 -1
- package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.js +48 -6
- package/dist-tsc/shared-spatial-scatterplot/dynamic-opacity.test.js +27 -3
- package/package.json +8 -8
- package/src/shared-spatial-scatterplot/dynamic-opacity.js +60 -6
- package/src/shared-spatial-scatterplot/dynamic-opacity.test.js +32 -3
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as inflate_1 } from "./pako.esm-SxljTded.js";
|
|
2
|
-
import { B as BaseDecoder } from "./index-
|
|
2
|
+
import { B as BaseDecoder } from "./index-BgH5JCMh.js";
|
|
3
3
|
class DeflateDecoder extends BaseDecoder {
|
|
4
4
|
decodeBlock(buffer) {
|
|
5
5
|
return inflate_1(new Uint8Array(buffer)).buffer;
|
|
@@ -105941,22 +105941,22 @@ function addDecoder(cases, importFn) {
|
|
|
105941
105941
|
}
|
|
105942
105942
|
cases.forEach((c2) => registry$1.set(c2, importFn));
|
|
105943
105943
|
}
|
|
105944
|
-
addDecoder([void 0, 1], () => import("./raw-
|
|
105945
|
-
addDecoder(5, () => import("./lzw-
|
|
105944
|
+
addDecoder([void 0, 1], () => import("./raw-ChRkwMzK.js").then((m2) => m2.default));
|
|
105945
|
+
addDecoder(5, () => import("./lzw-CgToJLS_.js").then((m2) => m2.default));
|
|
105946
105946
|
addDecoder(6, () => {
|
|
105947
105947
|
throw new Error("old style JPEG compression is not supported.");
|
|
105948
105948
|
});
|
|
105949
|
-
addDecoder(7, () => import("./jpeg-
|
|
105950
|
-
addDecoder([8, 32946], () => import("./deflate-
|
|
105951
|
-
addDecoder(32773, () => import("./packbits-
|
|
105949
|
+
addDecoder(7, () => import("./jpeg-DOj-mktM.js").then((m2) => m2.default));
|
|
105950
|
+
addDecoder([8, 32946], () => import("./deflate-BUOOeR_H.js").then((m2) => m2.default));
|
|
105951
|
+
addDecoder(32773, () => import("./packbits-Co4VqP5m.js").then((m2) => m2.default));
|
|
105952
105952
|
addDecoder(
|
|
105953
105953
|
34887,
|
|
105954
|
-
() => import("./lerc-
|
|
105954
|
+
() => import("./lerc-DJ1FEjnQ.js").then(async (m2) => {
|
|
105955
105955
|
await m2.zstd.init();
|
|
105956
105956
|
return m2;
|
|
105957
105957
|
}).then((m2) => m2.default)
|
|
105958
105958
|
);
|
|
105959
|
-
addDecoder(50001, () => import("./webimage-
|
|
105959
|
+
addDecoder(50001, () => import("./webimage-Mf5GLiYz.js").then((m2) => m2.default));
|
|
105960
105960
|
function decodeRowAcc(row, stride) {
|
|
105961
105961
|
let length2 = row.length - stride;
|
|
105962
105962
|
let offset2 = 0;
|
|
@@ -138285,8 +138285,18 @@ function forceCollideRects() {
|
|
|
138285
138285
|
};
|
|
138286
138286
|
return force;
|
|
138287
138287
|
}
|
|
138288
|
-
|
|
138289
|
-
|
|
138288
|
+
const BASE_POINT_SIZE = 5;
|
|
138289
|
+
const LARGE_DATASET_CELL_COUNT = 1e4;
|
|
138290
|
+
const SMALL_DATASET_CELL_COUNT = 100;
|
|
138291
|
+
function getInitialPointSize(numCells = LARGE_DATASET_CELL_COUNT) {
|
|
138292
|
+
return BASE_POINT_SIZE / clamp$4(
|
|
138293
|
+
numCells,
|
|
138294
|
+
SMALL_DATASET_CELL_COUNT,
|
|
138295
|
+
LARGE_DATASET_CELL_COUNT
|
|
138296
|
+
);
|
|
138297
|
+
}
|
|
138298
|
+
function getPointSizeDevicePixels(devicePixelRatio, zoom, xRange, yRange, width2, height2, numCells) {
|
|
138299
|
+
const pointSize = getInitialPointSize(numCells);
|
|
138290
138300
|
const pointScreenSizeMax = 10;
|
|
138291
138301
|
const pointScreenSizeMin = 1 / devicePixelRatio;
|
|
138292
138302
|
const scaleFactor = 2 ** zoom;
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as inflate_1 } from "./pako.esm-SxljTded.js";
|
|
2
|
-
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-
|
|
2
|
+
import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-BgH5JCMh.js";
|
|
3
3
|
const LercParameters = {
|
|
4
4
|
AddCompression: 1
|
|
5
5
|
};
|
|
@@ -1,3 +1,45 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Calculates initial point size based on dataset size.
|
|
3
|
+
* The point size decreases as the number of cells increases to avoid overplotting.
|
|
4
|
+
* The maximum point size is 0.05, for small datasets.
|
|
5
|
+
* The minimum point size is 0.0005, for large datasets.
|
|
6
|
+
* @param {number} numCells
|
|
7
|
+
* @returns {number} Initial point size.
|
|
8
|
+
*/
|
|
9
|
+
export function getInitialPointSize(numCells?: number): number;
|
|
10
|
+
/**
|
|
11
|
+
* Calculates point size in device pixels based on dataset size and view parameters.
|
|
12
|
+
* Reference: https://observablehq.com/@rreusser/selecting-the-right-opacity-for-2d-point-clouds
|
|
13
|
+
* Reference: https://observablehq.com/@bmschmidt/dot-density-election-maps-with-webgl
|
|
14
|
+
*
|
|
15
|
+
* @param {number} devicePixelRatio The device pixel ratio.
|
|
16
|
+
* @param {number} zoom The current zoom level.
|
|
17
|
+
* @param {number} xRange The range of the x-axis.
|
|
18
|
+
* @param {number} yRange The range of the y-axis.
|
|
19
|
+
* @param {number} width The width of the viewport.
|
|
20
|
+
* @param {number} height The height of the viewport.
|
|
21
|
+
* @param {number} numCells The number of cells in the dataset.
|
|
22
|
+
* @returns {number} Point size in device pixels.
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export function getPointSizeDevicePixels(devicePixelRatio: number, zoom: number, xRange: number, yRange: number, width: number, height: number, numCells: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* Calculates point opacity based on dataset size and view parameters.
|
|
28
|
+
* Reference: https://observablehq.com/@rreusser/selecting-the-right-opacity-for-2d-point-clouds
|
|
29
|
+
*
|
|
30
|
+
* @param {*} zoom The current zoom level.
|
|
31
|
+
* @param {number} zoom The current zoom level.
|
|
32
|
+
* @param {number} xRange The range of the x-axis.
|
|
33
|
+
* @param {number} yRange The range of the y-axis.
|
|
34
|
+
* @param {number} width The width of the viewport.
|
|
35
|
+
* @param {number} height The height of the viewport.
|
|
36
|
+
* @param {number} numCells The number of cells in the dataset.
|
|
37
|
+
* @param {number} avgFillDensity Optional average fill density to use instead of calculating one.
|
|
38
|
+
* @returns {number} The calculated point opacity.
|
|
39
|
+
*/
|
|
40
|
+
export function getPointOpacity(zoom: any, xRange: number, yRange: number, width: number, height: number, numCells: number, avgFillDensity: number): number;
|
|
41
|
+
export const LARGE_DATASET_CELL_COUNT: 10000;
|
|
42
|
+
export const SMALL_DATASET_CELL_COUNT: 100;
|
|
43
|
+
export const LARGE_DATASET_POINT_SIZE: number;
|
|
44
|
+
export const SMALL_DATASET_POINT_SIZE: number;
|
|
3
45
|
//# sourceMappingURL=dynamic-opacity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-opacity.d.ts","sourceRoot":"","sources":["../../src/shared-spatial-scatterplot/dynamic-opacity.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic-opacity.d.ts","sourceRoot":"","sources":["../../src/shared-spatial-scatterplot/dynamic-opacity.js"],"names":[],"mappings":"AAYA;;;;;;;GAOG;AACH,+CAHW,MAAM,GACJ,MAAM,CAQlB;AAED;;;;;;;;;;;;;;GAcG;AACH,2DAVW,MAAM,QACN,MAAM,UACN,MAAM,UACN,MAAM,SACN,MAAM,UACN,MAAM,YACN,MAAM,GACJ,MAAM,CAgClB;AAED;;;;;;;;;;;;;GAaG;AACH,sCAVW,GAAC,UAED,MAAM,UACN,MAAM,SACN,MAAM,UACN,MAAM,YACN,MAAM,kBACN,MAAM,GACJ,MAAM,CA+BlB;AAhHD,6CAA8C;AAC9C,2CAA4C;AAE5C,8CAAmF;AACnF,8CAAmF"}
|
|
@@ -1,10 +1,39 @@
|
|
|
1
1
|
import { deck } from '@vitessce/gl';
|
|
2
2
|
import { clamp } from 'lodash-es';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
const BASE_POINT_SIZE = 5;
|
|
4
|
+
export const LARGE_DATASET_CELL_COUNT = 10000;
|
|
5
|
+
export const SMALL_DATASET_CELL_COUNT = 100;
|
|
6
|
+
export const LARGE_DATASET_POINT_SIZE = BASE_POINT_SIZE / LARGE_DATASET_CELL_COUNT;
|
|
7
|
+
export const SMALL_DATASET_POINT_SIZE = BASE_POINT_SIZE / SMALL_DATASET_CELL_COUNT;
|
|
8
|
+
/**
|
|
9
|
+
* Calculates initial point size based on dataset size.
|
|
10
|
+
* The point size decreases as the number of cells increases to avoid overplotting.
|
|
11
|
+
* The maximum point size is 0.05, for small datasets.
|
|
12
|
+
* The minimum point size is 0.0005, for large datasets.
|
|
13
|
+
* @param {number} numCells
|
|
14
|
+
* @returns {number} Initial point size.
|
|
15
|
+
*/
|
|
16
|
+
export function getInitialPointSize(numCells = LARGE_DATASET_CELL_COUNT) {
|
|
17
|
+
return BASE_POINT_SIZE / clamp(numCells, SMALL_DATASET_CELL_COUNT, LARGE_DATASET_CELL_COUNT);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Calculates point size in device pixels based on dataset size and view parameters.
|
|
21
|
+
* Reference: https://observablehq.com/@rreusser/selecting-the-right-opacity-for-2d-point-clouds
|
|
22
|
+
* Reference: https://observablehq.com/@bmschmidt/dot-density-election-maps-with-webgl
|
|
23
|
+
*
|
|
24
|
+
* @param {number} devicePixelRatio The device pixel ratio.
|
|
25
|
+
* @param {number} zoom The current zoom level.
|
|
26
|
+
* @param {number} xRange The range of the x-axis.
|
|
27
|
+
* @param {number} yRange The range of the y-axis.
|
|
28
|
+
* @param {number} width The width of the viewport.
|
|
29
|
+
* @param {number} height The height of the viewport.
|
|
30
|
+
* @param {number} numCells The number of cells in the dataset.
|
|
31
|
+
* @returns {number} Point size in device pixels.
|
|
32
|
+
*
|
|
33
|
+
*/
|
|
34
|
+
export function getPointSizeDevicePixels(devicePixelRatio, zoom, xRange, yRange, width, height, numCells) {
|
|
35
|
+
// Smaller datasets get larger point sizes
|
|
36
|
+
const pointSize = getInitialPointSize(numCells);
|
|
8
37
|
// Point size maximum, in screen pixels.
|
|
9
38
|
const pointScreenSizeMax = 10;
|
|
10
39
|
// Point size minimum, in screen pixels.
|
|
@@ -21,7 +50,20 @@ export function getPointSizeDevicePixels(devicePixelRatio, zoom, xRange, yRange,
|
|
|
21
50
|
const pointSizeDevicePixels = clamp(deviceSize, pointScreenSizeMin, pointScreenSizeMax);
|
|
22
51
|
return pointSizeDevicePixels;
|
|
23
52
|
}
|
|
24
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Calculates point opacity based on dataset size and view parameters.
|
|
55
|
+
* Reference: https://observablehq.com/@rreusser/selecting-the-right-opacity-for-2d-point-clouds
|
|
56
|
+
*
|
|
57
|
+
* @param {*} zoom The current zoom level.
|
|
58
|
+
* @param {number} zoom The current zoom level.
|
|
59
|
+
* @param {number} xRange The range of the x-axis.
|
|
60
|
+
* @param {number} yRange The range of the y-axis.
|
|
61
|
+
* @param {number} width The width of the viewport.
|
|
62
|
+
* @param {number} height The height of the viewport.
|
|
63
|
+
* @param {number} numCells The number of cells in the dataset.
|
|
64
|
+
* @param {number} avgFillDensity Optional average fill density to use instead of calculating one.
|
|
65
|
+
* @returns {number} The calculated point opacity.
|
|
66
|
+
*/
|
|
25
67
|
export function getPointOpacity(zoom, xRange, yRange, width, height, numCells, avgFillDensity) {
|
|
26
68
|
const N = numCells;
|
|
27
69
|
let minX;
|
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { getPointSizeDevicePixels, getPointOpacity } from './dynamic-opacity.js';
|
|
2
|
+
import { getPointSizeDevicePixels, getPointOpacity, getInitialPointSize, LARGE_DATASET_CELL_COUNT, SMALL_DATASET_CELL_COUNT, LARGE_DATASET_POINT_SIZE, SMALL_DATASET_POINT_SIZE } from './dynamic-opacity.js';
|
|
3
3
|
describe('dynamic-opacity.js', () => {
|
|
4
|
+
describe('getInitialPointSize', () => {
|
|
5
|
+
it('returns large point size for small datasets', () => {
|
|
6
|
+
const numCells = SMALL_DATASET_CELL_COUNT;
|
|
7
|
+
const pointSize = getInitialPointSize(numCells);
|
|
8
|
+
expect(pointSize).toBe(SMALL_DATASET_POINT_SIZE);
|
|
9
|
+
});
|
|
10
|
+
it('returns small point size for large datasets', () => {
|
|
11
|
+
const numCells = LARGE_DATASET_CELL_COUNT;
|
|
12
|
+
const pointSize = getInitialPointSize(numCells);
|
|
13
|
+
expect(pointSize).toBe(LARGE_DATASET_POINT_SIZE);
|
|
14
|
+
});
|
|
15
|
+
it('returns intermediate point size for medium datasets', () => {
|
|
16
|
+
const numCells = (SMALL_DATASET_CELL_COUNT + LARGE_DATASET_CELL_COUNT) / 2;
|
|
17
|
+
const pointSize = getInitialPointSize(numCells);
|
|
18
|
+
expect(pointSize).toBeLessThan(SMALL_DATASET_POINT_SIZE);
|
|
19
|
+
expect(pointSize).toBeGreaterThan(LARGE_DATASET_POINT_SIZE);
|
|
20
|
+
});
|
|
21
|
+
it('handles missing numCells by using default large dataset size', () => {
|
|
22
|
+
const numCells = undefined;
|
|
23
|
+
const pointSize = getInitialPointSize(numCells);
|
|
24
|
+
expect(pointSize).toBe(LARGE_DATASET_POINT_SIZE);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
4
27
|
describe('getPointSizeDevicePixels', () => {
|
|
5
28
|
it('calculates point size', () => {
|
|
6
29
|
const devicePixelRatio = 2.0;
|
|
@@ -9,7 +32,8 @@ describe('dynamic-opacity.js', () => {
|
|
|
9
32
|
const yRange = 18;
|
|
10
33
|
const width = 1000;
|
|
11
34
|
const height = 650;
|
|
12
|
-
const
|
|
35
|
+
const numCells = 50000;
|
|
36
|
+
const pointSize = getPointSizeDevicePixels(devicePixelRatio, zoom, xRange, yRange, width, height, numCells);
|
|
13
37
|
expect(pointSize).toBeCloseTo(0.5);
|
|
14
38
|
});
|
|
15
39
|
});
|
|
@@ -17,7 +41,7 @@ describe('dynamic-opacity.js', () => {
|
|
|
17
41
|
it('calculates point opacity', () => {
|
|
18
42
|
const zoom = null;
|
|
19
43
|
const width = 1000;
|
|
20
|
-
const height =
|
|
44
|
+
const height = 1000;
|
|
21
45
|
const xRange = 20;
|
|
22
46
|
const yRange = 18;
|
|
23
47
|
const numCells = 500000;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/scatterplot",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.10",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"d3-quadtree": "^1.0.7",
|
|
22
22
|
"lodash-es": "^4.17.21",
|
|
23
23
|
"react-aria": "^3.28.0",
|
|
24
|
-
"@vitessce/styles": "3.8.
|
|
25
|
-
"@vitessce/constants-internal": "3.8.
|
|
26
|
-
"@vitessce/gl": "3.8.
|
|
27
|
-
"@vitessce/icons": "3.8.
|
|
28
|
-
"@vitessce/tooltip": "3.8.
|
|
29
|
-
"@vitessce/utils": "3.8.
|
|
30
|
-
"@vitessce/vit-s": "3.8.
|
|
24
|
+
"@vitessce/styles": "3.8.10",
|
|
25
|
+
"@vitessce/constants-internal": "3.8.10",
|
|
26
|
+
"@vitessce/gl": "3.8.10",
|
|
27
|
+
"@vitessce/icons": "3.8.10",
|
|
28
|
+
"@vitessce/tooltip": "3.8.10",
|
|
29
|
+
"@vitessce/utils": "3.8.10",
|
|
30
|
+
"@vitessce/vit-s": "3.8.10"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -1,11 +1,52 @@
|
|
|
1
1
|
import { deck } from '@vitessce/gl';
|
|
2
2
|
import { clamp } from 'lodash-es';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
|
|
5
|
+
const BASE_POINT_SIZE = 5;
|
|
6
|
+
export const LARGE_DATASET_CELL_COUNT = 10000;
|
|
7
|
+
export const SMALL_DATASET_CELL_COUNT = 100;
|
|
8
|
+
|
|
9
|
+
export const LARGE_DATASET_POINT_SIZE = BASE_POINT_SIZE / LARGE_DATASET_CELL_COUNT;
|
|
10
|
+
export const SMALL_DATASET_POINT_SIZE = BASE_POINT_SIZE / SMALL_DATASET_CELL_COUNT;
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Calculates initial point size based on dataset size.
|
|
15
|
+
* The point size decreases as the number of cells increases to avoid overplotting.
|
|
16
|
+
* The maximum point size is 0.05, for small datasets.
|
|
17
|
+
* The minimum point size is 0.0005, for large datasets.
|
|
18
|
+
* @param {number} numCells
|
|
19
|
+
* @returns {number} Initial point size.
|
|
20
|
+
*/
|
|
21
|
+
export function getInitialPointSize(numCells = LARGE_DATASET_CELL_COUNT) {
|
|
22
|
+
return BASE_POINT_SIZE / clamp(
|
|
23
|
+
numCells,
|
|
24
|
+
SMALL_DATASET_CELL_COUNT,
|
|
25
|
+
LARGE_DATASET_CELL_COUNT,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Calculates point size in device pixels based on dataset size and view parameters.
|
|
31
|
+
* Reference: https://observablehq.com/@rreusser/selecting-the-right-opacity-for-2d-point-clouds
|
|
32
|
+
* Reference: https://observablehq.com/@bmschmidt/dot-density-election-maps-with-webgl
|
|
33
|
+
*
|
|
34
|
+
* @param {number} devicePixelRatio The device pixel ratio.
|
|
35
|
+
* @param {number} zoom The current zoom level.
|
|
36
|
+
* @param {number} xRange The range of the x-axis.
|
|
37
|
+
* @param {number} yRange The range of the y-axis.
|
|
38
|
+
* @param {number} width The width of the viewport.
|
|
39
|
+
* @param {number} height The height of the viewport.
|
|
40
|
+
* @param {number} numCells The number of cells in the dataset.
|
|
41
|
+
* @returns {number} Point size in device pixels.
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
export function getPointSizeDevicePixels(
|
|
45
|
+
devicePixelRatio, zoom, xRange, yRange, width, height, numCells,
|
|
46
|
+
) {
|
|
47
|
+
// Smaller datasets get larger point sizes
|
|
48
|
+
const pointSize = getInitialPointSize(numCells);
|
|
49
|
+
|
|
9
50
|
// Point size maximum, in screen pixels.
|
|
10
51
|
const pointScreenSizeMax = 10;
|
|
11
52
|
|
|
@@ -31,7 +72,20 @@ export function getPointSizeDevicePixels(devicePixelRatio, zoom, xRange, yRange,
|
|
|
31
72
|
return pointSizeDevicePixels;
|
|
32
73
|
}
|
|
33
74
|
|
|
34
|
-
|
|
75
|
+
/**
|
|
76
|
+
* Calculates point opacity based on dataset size and view parameters.
|
|
77
|
+
* Reference: https://observablehq.com/@rreusser/selecting-the-right-opacity-for-2d-point-clouds
|
|
78
|
+
*
|
|
79
|
+
* @param {*} zoom The current zoom level.
|
|
80
|
+
* @param {number} zoom The current zoom level.
|
|
81
|
+
* @param {number} xRange The range of the x-axis.
|
|
82
|
+
* @param {number} yRange The range of the y-axis.
|
|
83
|
+
* @param {number} width The width of the viewport.
|
|
84
|
+
* @param {number} height The height of the viewport.
|
|
85
|
+
* @param {number} numCells The number of cells in the dataset.
|
|
86
|
+
* @param {number} avgFillDensity Optional average fill density to use instead of calculating one.
|
|
87
|
+
* @returns {number} The calculated point opacity.
|
|
88
|
+
*/
|
|
35
89
|
export function getPointOpacity(zoom, xRange, yRange, width, height, numCells, avgFillDensity) {
|
|
36
90
|
const N = numCells;
|
|
37
91
|
let minX; let minY; let maxX; let
|
|
@@ -1,7 +1,35 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { getPointSizeDevicePixels, getPointOpacity
|
|
2
|
+
import { getPointSizeDevicePixels, getPointOpacity, getInitialPointSize,
|
|
3
|
+
LARGE_DATASET_CELL_COUNT, SMALL_DATASET_CELL_COUNT,
|
|
4
|
+
LARGE_DATASET_POINT_SIZE, SMALL_DATASET_POINT_SIZE } from './dynamic-opacity.js';
|
|
3
5
|
|
|
4
6
|
describe('dynamic-opacity.js', () => {
|
|
7
|
+
describe('getInitialPointSize', () => {
|
|
8
|
+
it('returns large point size for small datasets', () => {
|
|
9
|
+
const numCells = SMALL_DATASET_CELL_COUNT;
|
|
10
|
+
const pointSize = getInitialPointSize(numCells);
|
|
11
|
+
expect(pointSize).toBe(SMALL_DATASET_POINT_SIZE);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('returns small point size for large datasets', () => {
|
|
15
|
+
const numCells = LARGE_DATASET_CELL_COUNT;
|
|
16
|
+
const pointSize = getInitialPointSize(numCells);
|
|
17
|
+
expect(pointSize).toBe(LARGE_DATASET_POINT_SIZE);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('returns intermediate point size for medium datasets', () => {
|
|
21
|
+
const numCells = (SMALL_DATASET_CELL_COUNT + LARGE_DATASET_CELL_COUNT) / 2;
|
|
22
|
+
const pointSize = getInitialPointSize(numCells);
|
|
23
|
+
expect(pointSize).toBeLessThan(SMALL_DATASET_POINT_SIZE);
|
|
24
|
+
expect(pointSize).toBeGreaterThan(LARGE_DATASET_POINT_SIZE);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('handles missing numCells by using default large dataset size', () => {
|
|
28
|
+
const numCells = undefined;
|
|
29
|
+
const pointSize = getInitialPointSize(numCells);
|
|
30
|
+
expect(pointSize).toBe(LARGE_DATASET_POINT_SIZE);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
5
33
|
describe('getPointSizeDevicePixels', () => {
|
|
6
34
|
it('calculates point size', () => {
|
|
7
35
|
const devicePixelRatio = 2.0;
|
|
@@ -10,8 +38,9 @@ describe('dynamic-opacity.js', () => {
|
|
|
10
38
|
const yRange = 18;
|
|
11
39
|
const width = 1000;
|
|
12
40
|
const height = 650;
|
|
41
|
+
const numCells = 50000;
|
|
13
42
|
const pointSize = getPointSizeDevicePixels(
|
|
14
|
-
devicePixelRatio, zoom, xRange, yRange, width, height,
|
|
43
|
+
devicePixelRatio, zoom, xRange, yRange, width, height, numCells,
|
|
15
44
|
);
|
|
16
45
|
expect(pointSize).toBeCloseTo(0.5);
|
|
17
46
|
});
|
|
@@ -20,7 +49,7 @@ describe('dynamic-opacity.js', () => {
|
|
|
20
49
|
it('calculates point opacity', () => {
|
|
21
50
|
const zoom = null;
|
|
22
51
|
const width = 1000;
|
|
23
|
-
const height =
|
|
52
|
+
const height = 1000;
|
|
24
53
|
const xRange = 20;
|
|
25
54
|
const yRange = 18;
|
|
26
55
|
const numCells = 500000;
|