gridviz 3.0.18 → 3.0.20

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 (56) hide show
  1. package/README.md +128 -127
  2. package/dist/gridviz.js +7862 -7819
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +74 -74
  5. package/src/button/ZoomButtons.js +101 -101
  6. package/src/core/Dataset.js +154 -154
  7. package/src/core/Drawable.js +60 -60
  8. package/src/core/GeoCanvas.js +430 -419
  9. package/src/core/Layer.js +23 -23
  10. package/src/core/Legend.js +108 -108
  11. package/src/core/Map.js +516 -503
  12. package/src/core/MultiResolutionDataset.js +93 -93
  13. package/src/core/Style.js +98 -98
  14. package/src/core/Tooltip.js +1 -0
  15. package/src/dataset/CSVGrid.js +112 -112
  16. package/src/dataset/GeoTIFF.js +122 -122
  17. package/src/dataset/JSGrid.js +55 -55
  18. package/src/dataset/TiledGrid.js +302 -289
  19. package/src/dataset/worker.js +18 -18
  20. package/src/index.js +77 -77
  21. package/src/layer/BackgroundLayer.js +162 -162
  22. package/src/layer/BackgroundLayerImage.js +81 -81
  23. package/src/layer/BackgroundLayerWMS.js +104 -104
  24. package/src/layer/GeoJSONLayer.js +214 -214
  25. package/src/layer/GridLayer.js +148 -148
  26. package/src/layer/LabelLayer.js +194 -194
  27. package/src/legend/ColorCategoryLegend.js +109 -109
  28. package/src/legend/ColorDiscreteLegend.js +100 -100
  29. package/src/legend/ColorLegend.js +115 -115
  30. package/src/legend/OrientationLegend.js +89 -89
  31. package/src/legend/SizeLegend.js +224 -224
  32. package/src/legend/TernaryLegend.js +302 -302
  33. package/src/style/CompositionStyle.js +291 -291
  34. package/src/style/DotDensityStyle.js +133 -133
  35. package/src/style/ImageStyle.js +100 -100
  36. package/src/style/IsoFenceStyle.js +217 -217
  37. package/src/style/JoyPlotStyle.js +127 -127
  38. package/src/style/LegoStyle.js +110 -110
  39. package/src/style/MosaicStyle.js +99 -99
  40. package/src/style/NinjaStarStyle.js +102 -102
  41. package/src/style/PillarStyle.js +207 -207
  42. package/src/style/SegmentStyle.js +105 -105
  43. package/src/style/ShapeColorSizeStyle.js +147 -147
  44. package/src/style/SideCategoryStyle.js +112 -112
  45. package/src/style/SideStyle.js +212 -212
  46. package/src/style/SquareColorCategoryWebGLStyle.js +107 -107
  47. package/src/style/SquareColorWebGLStyle.js +126 -126
  48. package/src/style/StrokeStyle.js +135 -135
  49. package/src/style/TanakaStyle.js +69 -69
  50. package/src/style/TextStyle.js +110 -110
  51. package/src/style/TimeSeriesStyle.js +222 -222
  52. package/src/utils/scale.js +218 -218
  53. package/src/utils/stretching.js +120 -120
  54. package/src/utils/ternary.js +208 -203
  55. package/src/utils/utils.js +58 -58
  56. package/src/utils/webGLUtils.js +72 -72
@@ -1,72 +1,72 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- /**
5
- * @param {string} width
6
- * @param {string} height
7
- * @param {object} opts
8
- * @returns {{canvas:HTMLCanvasElement, gl:WebGLRenderingContext}}
9
- */
10
- export function makeWebGLCanvas(width, height, opts = {}) {
11
- const canvas = document.createElement('canvas')
12
- canvas.setAttribute('width', width)
13
- canvas.setAttribute('height', height)
14
- /** @type {WebGLRenderingContext} */
15
- const gl = canvas.getContext('webgl', opts)
16
- if (!gl) {
17
- throw new Error('Unable to initialize WebGL. Your browser or machine may not support it.')
18
- }
19
- return { canvas: canvas, gl: gl }
20
- }
21
-
22
- /**
23
- * Initialize a shader program, so WebGL knows how to draw our data
24
- *
25
- * @param {WebGLRenderingContext} gl
26
- * @param {...WebGLShader} shaders
27
- * @returns {WebGLProgram}
28
- */
29
- export function initShaderProgram(gl, ...shaders) {
30
- /** @type {WebGLProgram|null} */
31
- const program = gl.createProgram()
32
- if (program == null) throw new Error('Cannot create webGL program')
33
- for (const shader of shaders) gl.attachShader(program, shader)
34
- gl.linkProgram(program)
35
- if (gl.getProgramParameter(program, gl.LINK_STATUS)) return program
36
- throw new Error(gl.getProgramInfoLog(program) || 'Cannot create webGL program (2)')
37
- }
38
-
39
- /**
40
- * Creates a shader of the given type, uploads the source and compiles it.
41
- *
42
- * @param {WebGLRenderingContext} gl
43
- * @param {number} type
44
- * @param {...string} sources
45
- * @returns {WebGLShader}
46
- */
47
- export function createShader(gl, type, ...sources) {
48
- /** @type {WebGLShader|null} */
49
- const shader = gl.createShader(type)
50
- if (shader == null) throw new Error('Cannot create webGL shader')
51
- gl.shaderSource(shader, sources.join('\n'))
52
- gl.compileShader(shader)
53
- if (gl.getShaderParameter(shader, gl.COMPILE_STATUS)) return shader
54
- throw new Error(gl.getShaderInfoLog(shader) || 'Cannot create webGL shader (2)')
55
- }
56
-
57
- /**
58
- * Check if webGL is supported
59
- *
60
- * @returns {boolean}
61
- */
62
- export function checkWebGLSupport() {
63
- try {
64
- const canvas = document.createElement('canvas')
65
- return !!(
66
- !!window.WebGLRenderingContext &&
67
- (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
68
- )
69
- } catch (err) {
70
- return false
71
- }
72
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ /**
5
+ * @param {string} width
6
+ * @param {string} height
7
+ * @param {object} opts
8
+ * @returns {{canvas:HTMLCanvasElement, gl:WebGLRenderingContext}}
9
+ */
10
+ export function makeWebGLCanvas(width, height, opts = {}) {
11
+ const canvas = document.createElement('canvas')
12
+ canvas.setAttribute('width', width)
13
+ canvas.setAttribute('height', height)
14
+ /** @type {WebGLRenderingContext} */
15
+ const gl = canvas.getContext('webgl', opts)
16
+ if (!gl) {
17
+ throw new Error('Unable to initialize WebGL. Your browser or machine may not support it.')
18
+ }
19
+ return { canvas: canvas, gl: gl }
20
+ }
21
+
22
+ /**
23
+ * Initialize a shader program, so WebGL knows how to draw our data
24
+ *
25
+ * @param {WebGLRenderingContext} gl
26
+ * @param {...WebGLShader} shaders
27
+ * @returns {WebGLProgram}
28
+ */
29
+ export function initShaderProgram(gl, ...shaders) {
30
+ /** @type {WebGLProgram|null} */
31
+ const program = gl.createProgram()
32
+ if (program == null) throw new Error('Cannot create webGL program')
33
+ for (const shader of shaders) gl.attachShader(program, shader)
34
+ gl.linkProgram(program)
35
+ if (gl.getProgramParameter(program, gl.LINK_STATUS)) return program
36
+ throw new Error(gl.getProgramInfoLog(program) || 'Cannot create webGL program (2)')
37
+ }
38
+
39
+ /**
40
+ * Creates a shader of the given type, uploads the source and compiles it.
41
+ *
42
+ * @param {WebGLRenderingContext} gl
43
+ * @param {number} type
44
+ * @param {...string} sources
45
+ * @returns {WebGLShader}
46
+ */
47
+ export function createShader(gl, type, ...sources) {
48
+ /** @type {WebGLShader|null} */
49
+ const shader = gl.createShader(type)
50
+ if (shader == null) throw new Error('Cannot create webGL shader')
51
+ gl.shaderSource(shader, sources.join('\n'))
52
+ gl.compileShader(shader)
53
+ if (gl.getShaderParameter(shader, gl.COMPILE_STATUS)) return shader
54
+ throw new Error(gl.getShaderInfoLog(shader) || 'Cannot create webGL shader (2)')
55
+ }
56
+
57
+ /**
58
+ * Check if webGL is supported
59
+ *
60
+ * @returns {boolean}
61
+ */
62
+ export function checkWebGLSupport() {
63
+ try {
64
+ const canvas = document.createElement('canvas')
65
+ return !!(
66
+ !!window.WebGLRenderingContext &&
67
+ (canvas.getContext('webgl') || canvas.getContext('experimental-webgl'))
68
+ )
69
+ } catch (err) {
70
+ return false
71
+ }
72
+ }