@vitessce/gl 2.0.3-beta.0 → 2.0.3

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 (50) hide show
  1. package/dist/deflate.04b04545.mjs +11 -0
  2. package/dist/index.9aaafdeb.mjs +118035 -0
  3. package/dist/index.mjs +33 -0
  4. package/dist/jpeg.060c9bc0.mjs +838 -0
  5. package/dist/lerc.62b02b29.mjs +1933 -0
  6. package/dist/lzw.19cdd4de.mjs +126 -0
  7. package/dist/packbits.03fc75de.mjs +28 -0
  8. package/dist/pako.esm.0e57f323.mjs +3940 -0
  9. package/dist/raw.739ce163.mjs +10 -0
  10. package/dist/webimage.4e868fb9.mjs +30 -0
  11. package/{dist → dist-tsc}/index.js +0 -0
  12. package/package.json +7 -7
  13. package/src/BitmaskLayer.js +165 -0
  14. package/src/HeatmapBitmapLayer.js +144 -0
  15. package/src/HeatmapCompositeTextLayer.js +156 -0
  16. package/src/PaddedExpressionHeatmapBitmapLayer.js +154 -0
  17. package/src/PixelatedBitmapLayer.js +30 -0
  18. package/src/ScaledExpressionExtension/ScaledExpressionExtension.js +117 -0
  19. package/{dist → src}/ScaledExpressionExtension/index.js +1 -0
  20. package/{dist → src}/ScaledExpressionExtension/shader-module.js +7 -4
  21. package/src/SelectionExtension/SelectionExtension.js +34 -0
  22. package/{dist → src}/SelectionExtension/index.js +1 -0
  23. package/{dist → src}/SelectionExtension/shader-module.js +7 -5
  24. package/src/SelectionLayer.js +198 -0
  25. package/{dist → src}/bitmask-layer-shaders.js +2 -0
  26. package/{dist → src}/constants.js +5 -3
  27. package/{dist → src}/deck.js +0 -0
  28. package/src/glsl/README.md +8 -0
  29. package/src/glsl/colormaps.in.glsl +15 -0
  30. package/{dist → src}/glsl/index.js +1 -0
  31. package/{dist → src}/heatmap-bitmap-layer-shaders.js +2 -0
  32. package/{dist → src}/heatmap-constants.js +11 -8
  33. package/src/index.js +33 -0
  34. package/{dist → src}/luma.js +0 -0
  35. package/{dist → src}/padded-expression-heatmap-bitmap-layer-shaders.js +2 -0
  36. package/src/selection-utils.js +109 -0
  37. package/src/viv.js +20 -0
  38. package/dist/BitmaskLayer.js +0 -132
  39. package/dist/HeatmapBitmapLayer.js +0 -123
  40. package/dist/HeatmapCompositeTextLayer.js +0 -129
  41. package/dist/PaddedExpressionHeatmapBitmapLayer.js +0 -129
  42. package/dist/PixelatedBitmapLayer.js +0 -26
  43. package/dist/ScaledExpressionExtension/ScaledExpressionExtension.js +0 -105
  44. package/dist/SelectionExtension/SelectionExtension.js +0 -31
  45. package/dist/SelectionLayer.js +0 -167
  46. package/dist/layer-controller.js +0 -109
  47. package/dist/selection-utils.js +0 -92
  48. package/dist/spatial.js +0 -281
  49. package/dist/spatial.test.js +0 -8
  50. package/dist/viv.js +0 -3
@@ -0,0 +1,10 @@
1
+ import { B as BaseDecoder } from "./index.9aaafdeb.mjs";
2
+ import "react";
3
+ class RawDecoder extends BaseDecoder {
4
+ decodeBlock(buffer) {
5
+ return buffer;
6
+ }
7
+ }
8
+ export {
9
+ RawDecoder as default
10
+ };
@@ -0,0 +1,30 @@
1
+ import { B as BaseDecoder } from "./index.9aaafdeb.mjs";
2
+ import "react";
3
+ class WebImageDecoder extends BaseDecoder {
4
+ constructor() {
5
+ super();
6
+ if (typeof createImageBitmap === "undefined") {
7
+ throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");
8
+ } else if (typeof document === "undefined" && typeof OffscreenCanvas === "undefined") {
9
+ throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available");
10
+ }
11
+ }
12
+ async decode(fileDirectory, buffer) {
13
+ const blob = new Blob([buffer]);
14
+ const imageBitmap = await createImageBitmap(blob);
15
+ let canvas;
16
+ if (typeof document !== "undefined") {
17
+ canvas = document.createElement("canvas");
18
+ canvas.width = imageBitmap.width;
19
+ canvas.height = imageBitmap.height;
20
+ } else {
21
+ canvas = new OffscreenCanvas(imageBitmap.width, imageBitmap.height);
22
+ }
23
+ const ctx = canvas.getContext("2d");
24
+ ctx.drawImage(imageBitmap, 0, 0);
25
+ return ctx.getImageData(0, 0, imageBitmap.width, imageBitmap.height).data.buffer;
26
+ }
27
+ }
28
+ export {
29
+ WebImageDecoder as default
30
+ };
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/gl",
3
- "version": "2.0.3-beta.0",
3
+ "version": "2.0.3",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -8,9 +8,10 @@
8
8
  "url": "git+https://github.com/vitessce/vitessce.git"
9
9
  },
10
10
  "license": "MIT",
11
- "main": "dist/index.js",
11
+ "main": "dist/index.mjs",
12
12
  "files": [
13
- "dist"
13
+ "dist",
14
+ "src"
14
15
  ],
15
16
  "dependencies": {
16
17
  "@deck.gl/aggregation-layers": "~8.8.6",
@@ -20,7 +21,7 @@
20
21
  "@deck.gl/layers": "~8.8.6",
21
22
  "@deck.gl/mesh-layers": "~8.8.6",
22
23
  "@deck.gl/react": "~8.8.6",
23
- "@hms-dbmi/viv": "~0.13.3",
24
+ "@hms-dbmi/viv": "~0.13.6",
24
25
  "@loaders.gl/3d-tiles": "^3.0.0",
25
26
  "@loaders.gl/core": "^3.0.0",
26
27
  "@loaders.gl/images": "^3.0.0",
@@ -48,14 +49,13 @@
48
49
  "math.gl": "^3.5.6",
49
50
  "mathjs": "^9.2.0",
50
51
  "nebula.gl": "0.23.8",
51
- "@vitessce/utils": "2.0.3-beta.0"
52
+ "@vitessce/utils": "2.0.3"
52
53
  },
53
54
  "devDependencies": {
54
55
  "glsl-colormap": "^1.0.1"
55
56
  },
56
57
  "scripts": {
57
- "start": "tsc --watch",
58
- "build": "tsc",
58
+ "bundle": "pnpm exec vite build -c ../../scripts/vite.config.js",
59
59
  "test": "pnpm exec vitest --run -r ../../ --dir .",
60
60
  "glslify": "cat src/glsl/colormaps.in.glsl | glslify > src/glsl/colormaps.out.glsl"
61
61
  }
@@ -0,0 +1,165 @@
1
+ import GL from '@luma.gl/constants'; // eslint-disable-line import/no-extraneous-dependencies
2
+ import { project32, picking } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
3
+ import { Texture2D, isWebGL2 } from '@luma.gl/core';
4
+ import { XRLayer } from '@hms-dbmi/viv';
5
+ import { fs, vs } from './bitmask-layer-shaders';
6
+ import {
7
+ GLSL_COLORMAPS,
8
+ GLSL_COLORMAP_DEFAULT,
9
+ COLORMAP_SHADER_PLACEHOLDER,
10
+ } from './constants';
11
+
12
+ function padWithDefault(arr, defaultValue, padWidth) {
13
+ const newArr = [...arr];
14
+ for (let i = 0; i < padWidth; i += 1) {
15
+ newArr.push(defaultValue);
16
+ }
17
+ return newArr;
18
+ }
19
+
20
+ const defaultProps = {
21
+ hoveredCell: { type: 'number', value: null, compare: true },
22
+ cellColorData: { type: 'object', value: null, compare: true },
23
+ colormap: { type: 'string', value: GLSL_COLORMAP_DEFAULT, compare: true },
24
+ expressionData: { type: 'object', value: null, compare: true },
25
+ };
26
+
27
+ /**
28
+ * A BitmapLayer that performs aggregation in the fragment shader,
29
+ * and renders its texture from a Uint8Array rather than an ImageData.
30
+ */
31
+ export default class BitmaskLayer extends XRLayer {
32
+ // eslint-disable-next-line class-methods-use-this
33
+ getShaders() {
34
+ const { colormap } = this.props;
35
+ return {
36
+ fs,
37
+ vs,
38
+ modules: [project32, picking],
39
+ defines: {
40
+ [COLORMAP_SHADER_PLACEHOLDER]: GLSL_COLORMAPS.includes(colormap)
41
+ ? colormap
42
+ : GLSL_COLORMAP_DEFAULT,
43
+ },
44
+ };
45
+ }
46
+
47
+ updateState({ props, oldProps, changeFlags }) {
48
+ super.updateState({ props, oldProps, changeFlags });
49
+ if (props.cellColorData !== oldProps.cellColorData) {
50
+ this.setColorTexture();
51
+ }
52
+ if (props.expressionData !== oldProps.expressionData) {
53
+ const { expressionData, cellTexHeight, cellTexWidth } = this.props;
54
+ const expressionTex = this.dataToTexture(
55
+ expressionData,
56
+ cellTexWidth,
57
+ cellTexHeight,
58
+ );
59
+ this.setState({ expressionTex });
60
+ }
61
+ if (props.colormap !== oldProps.colormap) {
62
+ const { gl } = this.context;
63
+ if (this.state.model) {
64
+ this.state.model.delete();
65
+ }
66
+ // eslint-disable-next-line no-underscore-dangle
67
+ this.setState({ model: this._getModel(gl) });
68
+
69
+ this.getAttributeManager().invalidateAll();
70
+ }
71
+ }
72
+
73
+ setColorTexture() {
74
+ const {
75
+ cellColorData: data,
76
+ cellTexHeight: height,
77
+ cellTexWidth: width,
78
+ } = this.props;
79
+ const colorTex = new Texture2D(this.context.gl, {
80
+ width,
81
+ height,
82
+ // Only use Float32 so we don't have to write two shaders
83
+ data,
84
+ // we don't want or need mimaps
85
+ mipmaps: false,
86
+ parameters: {
87
+ // NEAREST for integer data
88
+ [GL.TEXTURE_MIN_FILTER]: GL.NEAREST,
89
+ [GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
90
+ // CLAMP_TO_EDGE to remove tile artifacts
91
+ [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
92
+ [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
93
+ },
94
+ format: GL.RGB,
95
+ dataFormat: GL.RGB,
96
+ type: GL.UNSIGNED_BYTE,
97
+ });
98
+ this.setState({ colorTex });
99
+ }
100
+
101
+ draw(opts) {
102
+ const { uniforms } = opts;
103
+ const {
104
+ channelsVisible,
105
+ hoveredCell,
106
+ colorScaleLo,
107
+ colorScaleHi,
108
+ isExpressionMode,
109
+ } = this.props;
110
+ const {
111
+ textures, model, colorTex, expressionTex,
112
+ } = this.state;
113
+ // Render the image
114
+ if (textures && model && colorTex) {
115
+ model
116
+ .setUniforms(
117
+ Object.assign({}, uniforms, {
118
+ hovered: hoveredCell || 0,
119
+ colorTex,
120
+ expressionTex,
121
+ colorTexHeight: colorTex.height,
122
+ colorTexWidth: colorTex.width,
123
+ channelsVisible: padWithDefault(
124
+ channelsVisible,
125
+ false,
126
+ // There are six texture entries on the shaders
127
+ 6 - channelsVisible.length,
128
+ ),
129
+ uColorScaleRange: [colorScaleLo, colorScaleHi],
130
+ uIsExpressionMode: isExpressionMode,
131
+ ...textures,
132
+ }),
133
+ )
134
+ .draw();
135
+ }
136
+ }
137
+
138
+ /**
139
+ * This function creates textures from the data
140
+ */
141
+ dataToTexture(data, width, height) {
142
+ const isWebGL2On = isWebGL2(this.context.gl);
143
+ return new Texture2D(this.context.gl, {
144
+ width,
145
+ height,
146
+ // Only use Float32 so we don't have to write two shaders
147
+ data: new Float32Array(data),
148
+ // we don't want or need mimaps
149
+ mipmaps: false,
150
+ parameters: {
151
+ // NEAREST for integer data
152
+ [GL.TEXTURE_MIN_FILTER]: GL.NEAREST,
153
+ [GL.TEXTURE_MAG_FILTER]: GL.NEAREST,
154
+ // CLAMP_TO_EDGE to remove tile artifacts
155
+ [GL.TEXTURE_WRAP_S]: GL.CLAMP_TO_EDGE,
156
+ [GL.TEXTURE_WRAP_T]: GL.CLAMP_TO_EDGE,
157
+ },
158
+ format: isWebGL2On ? GL.R32F : GL.LUMINANCE,
159
+ dataFormat: isWebGL2On ? GL.RED : GL.LUMINANCE,
160
+ type: GL.FLOAT,
161
+ });
162
+ }
163
+ }
164
+ BitmaskLayer.layerName = 'BitmaskLayer';
165
+ BitmaskLayer.defaultProps = defaultProps;
@@ -0,0 +1,144 @@
1
+ import GL from '@luma.gl/constants'; // eslint-disable-line import/no-extraneous-dependencies
2
+ import { _mergeShaders, project32, picking } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
3
+ import { BitmapLayer } from '@deck.gl/layers'; // eslint-disable-line import/no-extraneous-dependencies
4
+ import { Texture2D } from '@luma.gl/core';
5
+ import { PIXELATED_TEXTURE_PARAMETERS, TILE_SIZE } from './heatmap-constants';
6
+ import {
7
+ GLSL_COLORMAPS,
8
+ GLSL_COLORMAP_DEFAULT,
9
+ COLORMAP_SHADER_PLACEHOLDER,
10
+ } from './constants';
11
+ import { vertexShader, fragmentShader } from './heatmap-bitmap-layer-shaders';
12
+
13
+ const defaultProps = {
14
+ image: { type: 'object', value: null, async: true },
15
+ colormap: { type: 'string', value: GLSL_COLORMAP_DEFAULT, compare: true },
16
+ bounds: { type: 'array', value: [1, 0, 0, 1], compare: true },
17
+ aggSizeX: { type: 'number', value: 8.0, compare: true },
18
+ aggSizeY: { type: 'number', value: 8.0, compare: true },
19
+ colorScaleLo: { type: 'number', value: 0.0, compare: true },
20
+ colorScaleHi: { type: 'number', value: 1.0, compare: true },
21
+ };
22
+ /**
23
+ * A BitmapLayer that performs aggregation in the fragment shader,
24
+ * and renders its texture from a Uint8Array rather than an ImageData.
25
+ */
26
+ export default class HeatmapBitmapLayer extends BitmapLayer {
27
+ /**
28
+ * Copy of getShaders from Layer (grandparent, parent of BitmapLayer).
29
+ * Reference: https://github.com/visgl/deck.gl/blob/0afd4e99a6199aeec979989e0c361c97e6c17a16/modules/core/src/lib/layer.js#L302
30
+ * @param {object} shaders
31
+ * @returns {object} Merged shaders.
32
+ */
33
+ // eslint-disable-next-line no-underscore-dangle
34
+ _getShaders(shaders) {
35
+ this.props.extensions.forEach((extension) => {
36
+ // eslint-disable-next-line no-param-reassign
37
+ shaders = _mergeShaders(
38
+ shaders,
39
+ extension.getShaders.call(this, extension),
40
+ );
41
+ });
42
+ return shaders;
43
+ }
44
+
45
+ /**
46
+ * Need to override to provide custom shaders.
47
+ */
48
+ getShaders() {
49
+ const { colormap } = this.props;
50
+ const fragmentShaderWithColormap = GLSL_COLORMAPS.includes(colormap)
51
+ ? fragmentShader.replace(COLORMAP_SHADER_PLACEHOLDER, colormap)
52
+ : fragmentShader.replace(
53
+ COLORMAP_SHADER_PLACEHOLDER,
54
+ GLSL_COLORMAP_DEFAULT,
55
+ );
56
+ // eslint-disable-next-line no-underscore-dangle
57
+ return this._getShaders({
58
+ vs: vertexShader,
59
+ fs: fragmentShaderWithColormap,
60
+ modules: [project32, picking],
61
+ });
62
+ }
63
+
64
+ updateState(args) {
65
+ super.updateState(args);
66
+ this.loadTexture(this.props.image);
67
+ const { props, oldProps } = args;
68
+ if (props.colormap !== oldProps.colormap) {
69
+ const { gl } = this.context;
70
+ // eslint-disable-next-line no-unused-expressions
71
+ this.state.model?.delete();
72
+ // eslint-disable-next-line no-underscore-dangle
73
+ this.state.model = this._getModel(gl);
74
+ this.getAttributeManager().invalidateAll();
75
+ }
76
+ }
77
+
78
+ /**
79
+ * Need to override to provide additional uniform values.
80
+ * Simplified by removing video-related code.
81
+ * Reference: https://github.com/visgl/deck.gl/blob/0afd4e99a6199aeec979989e0c361c97e6c17a16/modules/layers/src/bitmap-layer/bitmap-layer.js#L173
82
+ * @param {*} opts
83
+ */
84
+ draw(opts) {
85
+ const { uniforms } = opts;
86
+ const { bitmapTexture, model } = this.state;
87
+ const {
88
+ aggSizeX, aggSizeY, colorScaleLo, colorScaleHi,
89
+ } = this.props;
90
+
91
+ // Render the image
92
+ if (bitmapTexture && model) {
93
+ model
94
+ .setUniforms(
95
+ Object.assign({}, uniforms, {
96
+ uBitmapTexture: bitmapTexture,
97
+ uTextureSize: [TILE_SIZE, TILE_SIZE],
98
+ uAggSize: [aggSizeX, aggSizeY],
99
+ uColorScaleRange: [colorScaleLo, colorScaleHi],
100
+ }),
101
+ )
102
+ .draw();
103
+ }
104
+ }
105
+
106
+ /**
107
+ * Need to override to provide the custom DEFAULT_TEXTURE_PARAMETERS
108
+ * object.
109
+ * Simplified by removing video-related code.
110
+ * Reference: https://github.com/visgl/deck.gl/blob/0afd4e99a6199aeec979989e0c361c97e6c17a16/modules/layers/src/bitmap-layer/bitmap-layer.js#L218
111
+ * @param {Uint8Array} image
112
+ */
113
+ loadTexture(image) {
114
+ const { gl } = this.context;
115
+
116
+ if (this.state.bitmapTexture) {
117
+ this.state.bitmapTexture.delete();
118
+ }
119
+
120
+ if (image instanceof Texture2D) {
121
+ this.setState({
122
+ bitmapTexture: image,
123
+ });
124
+ } else if (image) {
125
+ this.setState({
126
+ bitmapTexture: new Texture2D(gl, {
127
+ data: image,
128
+ mipmaps: false,
129
+ parameters: PIXELATED_TEXTURE_PARAMETERS,
130
+ // Each color contains a single luminance value.
131
+ // When sampled, rgb are all set to this luminance, alpha is 1.0.
132
+ // Reference: https://luma.gl/docs/api-reference/webgl/texture#texture-formats
133
+ format: GL.LUMINANCE,
134
+ dataFormat: GL.LUMINANCE,
135
+ type: GL.UNSIGNED_BYTE,
136
+ width: TILE_SIZE,
137
+ height: TILE_SIZE,
138
+ }),
139
+ });
140
+ }
141
+ }
142
+ }
143
+ HeatmapBitmapLayer.layerName = 'HeatmapBitmapLayer';
144
+ HeatmapBitmapLayer.defaultProps = defaultProps;
@@ -0,0 +1,156 @@
1
+ /* eslint-disable no-underscore-dangle */
2
+ import { COORDINATE_SYSTEM, CompositeLayer } from '@deck.gl/core'; // eslint-disable-line import/no-extraneous-dependencies
3
+ import { TextLayer } from '@deck.gl/layers'; // eslint-disable-line import/no-extraneous-dependencies
4
+ import {
5
+ AXIS_LABEL_TEXT_SIZE,
6
+ AXIS_TITLE_TEXT_SIZE,
7
+ AXIS_MARGIN,
8
+ THEME_TO_TEXT_COLOR,
9
+ AXIS_FONT_FAMILY,
10
+ COLOR_BAR_SIZE,
11
+ } from './heatmap-constants';
12
+
13
+ export default class HeatmapCompositeTextLayer extends CompositeLayer {
14
+ _renderAxisTopLayers() {
15
+ const {
16
+ axisTopLabelData, matrixLeft, width, matrixWidth, viewWidth, theme,
17
+ targetX, targetY, axisTopTitle, cellWidth, axisOffsetTop, scaleFactor,
18
+ hideTopLabels,
19
+ } = this.props;
20
+ const showAxisTopLabels = cellWidth >= AXIS_LABEL_TEXT_SIZE;
21
+ const axisLabelTop = targetY + (axisOffsetTop - AXIS_MARGIN) / 2 / scaleFactor;
22
+ return hideTopLabels ? [] : [
23
+ new TextLayer({
24
+ id: 'axisTopLabels',
25
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
26
+ data: axisTopLabelData,
27
+ getText: d => d[1],
28
+ getPosition: d => [matrixLeft + ((d[0] + 0.5) / width) * matrixWidth, axisLabelTop],
29
+ getTextAnchor: 'start',
30
+ getColor: () => THEME_TO_TEXT_COLOR[theme],
31
+ getSize: (showAxisTopLabels ? AXIS_LABEL_TEXT_SIZE : 0),
32
+ getAngle: 75,
33
+ fontFamily: AXIS_FONT_FAMILY,
34
+ updateTriggers: {
35
+ getPosition: [axisLabelTop, matrixLeft, matrixWidth, viewWidth],
36
+ getSize: [showAxisTopLabels],
37
+ getColor: [theme],
38
+ },
39
+ }),
40
+ new TextLayer({
41
+ id: 'axisTopTitle',
42
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
43
+ data: [{ title: axisTopTitle }],
44
+ getText: d => d.title,
45
+ getPosition: [targetX, targetY],
46
+ getTextAnchor: 'middle',
47
+ getColor: () => THEME_TO_TEXT_COLOR[theme],
48
+ getSize: (!showAxisTopLabels ? AXIS_TITLE_TEXT_SIZE : 0),
49
+ getAngle: 0,
50
+ fontFamily: AXIS_FONT_FAMILY,
51
+ updateTriggers: {
52
+ getSize: [showAxisTopLabels],
53
+ getColor: [theme],
54
+ },
55
+ }),
56
+ ];
57
+ }
58
+
59
+ _renderCornerLayers() {
60
+ const {
61
+ theme, targetX, targetY, axisOffsetTop, scaleFactor,
62
+ cellColorLabelsData, axisOffsetLeft, transpose,
63
+ } = this.props;
64
+ const axisLabelTop = targetY + (axisOffsetTop - AXIS_MARGIN) / 2 / scaleFactor;
65
+ const axisLabelLeft = targetX + (axisOffsetLeft - AXIS_MARGIN) / 2 / scaleFactor;
66
+ return cellColorLabelsData.map(data => (
67
+ new TextLayer({
68
+ id: `cellColorLabel-${data[0]}`,
69
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
70
+ data: [data],
71
+ getText: d => d[1],
72
+ getTextAnchor: (transpose ? 'end' : 'start'),
73
+ getAlignmentBaseline: 'top',
74
+ getColor: () => THEME_TO_TEXT_COLOR[theme],
75
+ getSize: AXIS_LABEL_TEXT_SIZE,
76
+ getPosition: d => [
77
+ (transpose
78
+ ? axisLabelLeft
79
+ : targetX
80
+ + ((-cellColorLabelsData.length + d[0] * 2) * COLOR_BAR_SIZE + AXIS_MARGIN)
81
+ / 2 / scaleFactor
82
+ ),
83
+ (transpose
84
+ ? targetY
85
+ + ((-cellColorLabelsData.length + d[0] * 2) * COLOR_BAR_SIZE + AXIS_MARGIN)
86
+ / 2 / scaleFactor
87
+ : axisLabelTop
88
+ ),
89
+ ],
90
+ getAngle: (transpose ? 0 : 90),
91
+ fontFamily: AXIS_FONT_FAMILY,
92
+ })
93
+ ));
94
+ }
95
+
96
+ _renderAxisLeftLayers() {
97
+ const {
98
+ axisLeftLabelData, matrixTop, height, matrixHeight,
99
+ viewHeight, theme, axisLeftTitle, targetX, targetY, cellHeight, axisOffsetLeft,
100
+ scaleFactor, hideLeftLabels,
101
+ } = this.props;
102
+ const showAxisLeftLabels = cellHeight >= AXIS_LABEL_TEXT_SIZE;
103
+ const axisLabelLeft = targetX + (axisOffsetLeft - AXIS_MARGIN) / 2 / scaleFactor;
104
+ return hideLeftLabels ? [] : [
105
+ new TextLayer({
106
+ id: 'axisLeftLabels',
107
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
108
+ data: axisLeftLabelData,
109
+ getText: d => d[1],
110
+ getPosition: d => [axisLabelLeft, matrixTop + ((d[0] + 0.5) / height) * matrixHeight],
111
+ getTextAnchor: 'end',
112
+ getColor: () => THEME_TO_TEXT_COLOR[theme],
113
+ getSize: (showAxisLeftLabels ? AXIS_LABEL_TEXT_SIZE : 0),
114
+ getAngle: 0,
115
+ fontFamily: AXIS_FONT_FAMILY,
116
+ updateTriggers: {
117
+ getPosition: [axisLabelLeft, matrixTop, matrixHeight, viewHeight],
118
+ getSize: [showAxisLeftLabels],
119
+ getColor: [theme],
120
+ },
121
+ }),
122
+ new TextLayer({
123
+ id: 'axisLeftTitle',
124
+ coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
125
+ data: [{ title: axisLeftTitle }],
126
+ getText: d => d.title,
127
+ getPosition: [targetX, targetY],
128
+ getTextAnchor: 'middle',
129
+ getColor: () => THEME_TO_TEXT_COLOR[theme],
130
+ getSize: (!showAxisLeftLabels ? AXIS_TITLE_TEXT_SIZE : 0),
131
+ getAngle: 90,
132
+ fontFamily: AXIS_FONT_FAMILY,
133
+ updateTriggers: {
134
+ getSize: [showAxisLeftLabels],
135
+ getColor: [theme],
136
+ },
137
+ }),
138
+ ];
139
+ }
140
+
141
+ renderLayers() {
142
+ const { axis } = this.props;
143
+ if (axis === 'left') {
144
+ return this._renderAxisLeftLayers();
145
+ }
146
+ if (axis === 'top') {
147
+ return this._renderAxisTopLayers();
148
+ }
149
+ if (axis === 'corner') {
150
+ return this._renderCornerLayers();
151
+ }
152
+ return [];
153
+ }
154
+ }
155
+
156
+ HeatmapCompositeTextLayer.layerName = 'HeatmapCompositeTextLayer';