gridviz 3.0.14 → 3.0.16

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 (55) hide show
  1. package/README.md +127 -128
  2. package/dist/gridviz.js +7959 -7860
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +74 -74
  5. package/src/button/ZoomButtons.js +101 -96
  6. package/src/core/Dataset.js +154 -157
  7. package/src/core/Drawable.js +60 -61
  8. package/src/core/GeoCanvas.js +409 -370
  9. package/src/core/Layer.js +23 -25
  10. package/src/core/Legend.js +108 -110
  11. package/src/core/Map.js +495 -495
  12. package/src/core/MultiResolutionDataset.js +93 -97
  13. package/src/core/Style.js +98 -99
  14. package/src/dataset/CSVGrid.js +112 -112
  15. package/src/dataset/GeoTIFF.js +122 -123
  16. package/src/dataset/JSGrid.js +55 -54
  17. package/src/dataset/TiledGrid.js +289 -288
  18. package/src/dataset/worker.js +18 -0
  19. package/src/index.js +77 -71
  20. package/src/layer/BackgroundLayer.js +162 -158
  21. package/src/layer/BackgroundLayerImage.js +81 -84
  22. package/src/layer/BackgroundLayerWMS.js +104 -108
  23. package/src/layer/GeoJSONLayer.js +214 -220
  24. package/src/layer/GridLayer.js +148 -157
  25. package/src/layer/LabelLayer.js +194 -193
  26. package/src/legend/ColorCategoryLegend.js +109 -110
  27. package/src/legend/ColorDiscreteLegend.js +100 -102
  28. package/src/legend/ColorLegend.js +115 -118
  29. package/src/legend/OrientationLegend.js +89 -91
  30. package/src/legend/SizeLegend.js +224 -224
  31. package/src/legend/TernaryLegend.js +302 -210
  32. package/src/style/CompositionStyle.js +291 -288
  33. package/src/style/DotDensityStyle.js +133 -134
  34. package/src/style/ImageStyle.js +100 -102
  35. package/src/style/IsoFenceStyle.js +217 -203
  36. package/src/style/JoyPlotStyle.js +127 -128
  37. package/src/style/LegoStyle.js +110 -110
  38. package/src/style/MosaicStyle.js +99 -99
  39. package/src/style/NinjaStarStyle.js +102 -102
  40. package/src/style/PillarStyle.js +207 -208
  41. package/src/style/SegmentStyle.js +105 -105
  42. package/src/style/ShapeColorSizeStyle.js +147 -132
  43. package/src/style/SideCategoryStyle.js +112 -114
  44. package/src/style/SideStyle.js +212 -205
  45. package/src/style/SquareColorCategoryWebGLStyle.js +107 -108
  46. package/src/style/SquareColorWebGLStyle.js +126 -126
  47. package/src/style/StrokeStyle.js +135 -136
  48. package/src/style/TanakaStyle.js +69 -68
  49. package/src/style/TextStyle.js +110 -111
  50. package/src/style/TimeSeriesStyle.js +222 -229
  51. package/src/utils/scale.js +218 -228
  52. package/src/utils/stretching.js +120 -133
  53. package/src/utils/ternary.js +203 -203
  54. package/src/utils/utils.js +58 -63
  55. package/src/utils/webGLUtils.js +72 -70
@@ -1,70 +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 !!(!!window.WebGLRenderingContext &&
66
- (canvas.getContext('webgl') || canvas.getContext('experimental-webgl')))
67
- } catch (err) {
68
- return false
69
- }
70
- }
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
+ }