gridviz 2.0.37 → 2.0.39

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 (58) hide show
  1. package/README.md +119 -119
  2. package/dist/gridviz.js +33256 -33296
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +78 -78
  5. package/src/App.js +698 -698
  6. package/src/BackgroundLayer.js +182 -182
  7. package/src/BackgroundLayerWMS.js +131 -131
  8. package/src/Dataset.js +76 -76
  9. package/src/DatasetComponent.js +103 -103
  10. package/src/GeoCanvas.js +419 -419
  11. package/src/LabelLayer.js +190 -190
  12. package/src/Layer.js +92 -92
  13. package/src/Legend.js +86 -86
  14. package/src/LineLayer.js +150 -150
  15. package/src/Style.js +114 -114
  16. package/src/Tooltip.js +168 -166
  17. package/src/dataset/COGeo.js +24 -24
  18. package/src/dataset/CSVGrid.js +104 -104
  19. package/src/dataset/GeoTIFF.js +127 -127
  20. package/src/dataset/GridTile.js +41 -41
  21. package/src/dataset/ParquetGrid.js +122 -122
  22. package/src/dataset/TiledGrid.js +296 -296
  23. package/src/index.js +177 -177
  24. package/src/legend/ColorCategoryLegend.js +124 -124
  25. package/src/legend/ColorDiscreteLegend.js +105 -105
  26. package/src/legend/ColorLegend.js +125 -125
  27. package/src/legend/SegmentOrientationLegend.js +87 -87
  28. package/src/legend/SegmentWidthLegend.js +97 -97
  29. package/src/legend/SizeLegend.js +141 -141
  30. package/src/style/CompositionStyle.js +300 -300
  31. package/src/style/ContourStyle.js +54 -54
  32. package/src/style/DotDensityStyle.js +156 -156
  33. package/src/style/JoyPlotStyle.js +135 -135
  34. package/src/style/KernelSmoothingOldStyle.js +221 -221
  35. package/src/style/KernelSmoothingStyle.js +115 -115
  36. package/src/style/KernelSmoothingWGLStyle.js +130 -130
  37. package/src/style/LegoStyle.js +112 -112
  38. package/src/style/MosaicStyle.js +107 -107
  39. package/src/style/NinjaStarStyle.js +124 -124
  40. package/src/style/PillarStyle.js +230 -230
  41. package/src/style/SegmentStyle.js +142 -142
  42. package/src/style/ShapeColorSizeStyle.js +126 -126
  43. package/src/style/SideCatStyle.js +172 -172
  44. package/src/style/SideStyle.js +218 -218
  45. package/src/style/SquareColorCatWGLStyle.js +120 -120
  46. package/src/style/SquareColorWGLStyle.js +146 -146
  47. package/src/style/StrokeStyle.js +131 -131
  48. package/src/style/TanakaStyle.js +160 -160
  49. package/src/style/TextStyle.js +132 -132
  50. package/src/utils/Utils.js +35 -35
  51. package/src/utils/WebGLRectangleColoring.js +106 -106
  52. package/src/utils/WebGLSquareColoring.js +118 -118
  53. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  54. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  55. package/src/utils/WebGLSquareColoringKS.js +153 -153
  56. package/src/utils/stretching.js +131 -131
  57. package/src/utils/webGLUtils.js +71 -71
  58. package/src/utils/zoomUtils.js +142 -142
@@ -1,135 +1,135 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Style } from '../Style.js'
5
-
6
- /**
7
- *
8
- * @author Julien Gaffuri
9
- */
10
- export class JoyPlotStyle extends Style {
11
- /** @param {object} opts */
12
- constructor(opts) {
13
- super(opts)
14
- opts = opts || {}
15
-
16
- /** The cell column where to get the value to represent.
17
- * @type {string} */
18
- this.heightCol = opts.heightCol
19
-
20
- /** A function returning the height of a cell.
21
- * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
22
- this.height = opts.height || ((v) => Math.sqrt(v))
23
-
24
- /**
25
- * @type {function(number,{min:number, max:number},number,number):string} */
26
- this.lineColor = opts.lineColor || ((y, ys, r, zf) => '#BBB')
27
- /**
28
- * @type {function(number,{min:number, max:number},number,number):number} */
29
- this.lineWidth = opts.lineWidth || ((y, ys, r, zf) => zf)
30
- /**
31
- * @type {function(number,{min:number, max:number},number,number):string} */
32
- this.fillColor = opts.fillColor || ((y, ys, r, zf) => '#c08c5968')
33
- }
34
-
35
- /**
36
- * Draw cells as squares depending on their value.
37
- *
38
- * @param {Array.<import("../Dataset").Cell>} cells
39
- * @param {number} r
40
- * @param {import("../GeoCanvas").GeoCanvas} cg
41
- * */
42
- draw(cells, r, cg) {
43
- //filter
44
- if (this.filter) cells = cells.filter(this.filter)
45
-
46
- cg.ctx.lineJoin = 'round'
47
-
48
- //zoom factor
49
- const zf = cg.getZf()
50
-
51
- //compute statistics
52
- const stat = Style.getStatistics(cells, (c) => c[this.heightCol], true)
53
-
54
- //index cells by y and x
55
- /** @type {object} */
56
- const ind = {}
57
- for (const cell of cells) {
58
- let row = ind[cell.y]
59
- if (!row) {
60
- row = {}
61
- ind[cell.y] = row
62
- }
63
- row[cell.x] = this.height(cell[this.heightCol], r, stat, zf)
64
- }
65
-
66
- //compute extent
67
- const e = cg.extGeo
68
- if (!e) return
69
- const xMin = Math.floor(e.xMin / r) * r
70
- const xMax = Math.floor(e.xMax / r) * r
71
- const yMin = Math.floor(e.yMin / r) * r
72
- const yMax = Math.floor(e.yMax / r) * r
73
-
74
- /** @type {{min:number, max:number}} */
75
- const ys = { min: yMin, max: yMax }
76
-
77
- //draw in geo coordinates
78
- cg.setCanvasTransform()
79
-
80
- //draw lines, row by row, stating from the top
81
- for (let y = yMax; y >= yMin; y -= r) {
82
- //get row
83
- const row = ind[y]
84
-
85
- //no row
86
- if (!row) continue
87
-
88
- //place first point
89
- cg.ctx.beginPath()
90
- cg.ctx.moveTo(xMin - r / 2, y)
91
-
92
- //store the previous height
93
- /** @type {number|undefined} */
94
- let hG_
95
-
96
- //go through the line cells
97
- for (let x = xMin; x <= xMax; x += r) {
98
- //get column value
99
- /** @type {number} */
100
- let hG = row[x]
101
- if (!hG) hG = 0
102
-
103
- if (hG || hG_) {
104
- //draw line only when at least one of both values is non-null
105
- //TODO test bezierCurveTo
106
- cg.ctx.lineTo(x + r / 2, y + hG)
107
- } else {
108
- //else move the point
109
- cg.ctx.moveTo(x + r / 2, y)
110
- }
111
- //store the previous value
112
- hG_ = hG
113
- }
114
-
115
- //last point
116
- if (hG_) cg.ctx.lineTo(xMax + r / 2, y)
117
-
118
- //draw fill
119
- const fc = this.fillColor(y, ys, r, zf)
120
- if (fc && fc != 'none') {
121
- cg.ctx.fillStyle = fc
122
- cg.ctx.fill()
123
- }
124
-
125
- //draw line
126
- const lc = this.lineColor(y, ys, r, zf)
127
- const lw = this.lineWidth(y, ys, r, zf)
128
- if (lc && lc != 'none' && lw > 0) {
129
- cg.ctx.strokeStyle = lc
130
- cg.ctx.lineWidth = lw
131
- cg.ctx.stroke()
132
- }
133
- }
134
- }
135
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Style } from '../Style.js'
5
+
6
+ /**
7
+ *
8
+ * @author Julien Gaffuri
9
+ */
10
+ export class JoyPlotStyle extends Style {
11
+ /** @param {object} opts */
12
+ constructor(opts) {
13
+ super(opts)
14
+ opts = opts || {}
15
+
16
+ /** The cell column where to get the value to represent.
17
+ * @type {string} */
18
+ this.heightCol = opts.heightCol
19
+
20
+ /** A function returning the height of a cell.
21
+ * @type {function(number,number,import("../Style").Stat|undefined,number):number} */
22
+ this.height = opts.height || ((v) => Math.sqrt(v))
23
+
24
+ /**
25
+ * @type {function(number,{min:number, max:number},number,number):string} */
26
+ this.lineColor = opts.lineColor || ((y, ys, r, zf) => '#BBB')
27
+ /**
28
+ * @type {function(number,{min:number, max:number},number,number):number} */
29
+ this.lineWidth = opts.lineWidth || ((y, ys, r, zf) => zf)
30
+ /**
31
+ * @type {function(number,{min:number, max:number},number,number):string} */
32
+ this.fillColor = opts.fillColor || ((y, ys, r, zf) => '#c08c5968')
33
+ }
34
+
35
+ /**
36
+ * Draw cells as squares depending on their value.
37
+ *
38
+ * @param {Array.<import("../Dataset").Cell>} cells
39
+ * @param {number} r
40
+ * @param {import("../GeoCanvas").GeoCanvas} cg
41
+ * */
42
+ draw(cells, r, cg) {
43
+ //filter
44
+ if (this.filter) cells = cells.filter(this.filter)
45
+
46
+ cg.ctx.lineJoin = 'round'
47
+
48
+ //zoom factor
49
+ const zf = cg.getZf()
50
+
51
+ //compute statistics
52
+ const stat = Style.getStatistics(cells, (c) => c[this.heightCol], true)
53
+
54
+ //index cells by y and x
55
+ /** @type {object} */
56
+ const ind = {}
57
+ for (const cell of cells) {
58
+ let row = ind[cell.y]
59
+ if (!row) {
60
+ row = {}
61
+ ind[cell.y] = row
62
+ }
63
+ row[cell.x] = this.height(cell[this.heightCol], r, stat, zf)
64
+ }
65
+
66
+ //compute extent
67
+ const e = cg.extGeo
68
+ if (!e) return
69
+ const xMin = Math.floor(e.xMin / r) * r
70
+ const xMax = Math.floor(e.xMax / r) * r
71
+ const yMin = Math.floor(e.yMin / r) * r
72
+ const yMax = Math.floor(e.yMax / r) * r
73
+
74
+ /** @type {{min:number, max:number}} */
75
+ const ys = { min: yMin, max: yMax }
76
+
77
+ //draw in geo coordinates
78
+ cg.setCanvasTransform()
79
+
80
+ //draw lines, row by row, stating from the top
81
+ for (let y = yMax; y >= yMin; y -= r) {
82
+ //get row
83
+ const row = ind[y]
84
+
85
+ //no row
86
+ if (!row) continue
87
+
88
+ //place first point
89
+ cg.ctx.beginPath()
90
+ cg.ctx.moveTo(xMin - r / 2, y)
91
+
92
+ //store the previous height
93
+ /** @type {number|undefined} */
94
+ let hG_
95
+
96
+ //go through the line cells
97
+ for (let x = xMin; x <= xMax; x += r) {
98
+ //get column value
99
+ /** @type {number} */
100
+ let hG = row[x]
101
+ if (!hG) hG = 0
102
+
103
+ if (hG || hG_) {
104
+ //draw line only when at least one of both values is non-null
105
+ //TODO test bezierCurveTo
106
+ cg.ctx.lineTo(x + r / 2, y + hG)
107
+ } else {
108
+ //else move the point
109
+ cg.ctx.moveTo(x + r / 2, y)
110
+ }
111
+ //store the previous value
112
+ hG_ = hG
113
+ }
114
+
115
+ //last point
116
+ if (hG_) cg.ctx.lineTo(xMax + r / 2, y)
117
+
118
+ //draw fill
119
+ const fc = this.fillColor(y, ys, r, zf)
120
+ if (fc && fc != 'none') {
121
+ cg.ctx.fillStyle = fc
122
+ cg.ctx.fill()
123
+ }
124
+
125
+ //draw line
126
+ const lc = this.lineColor(y, ys, r, zf)
127
+ const lw = this.lineWidth(y, ys, r, zf)
128
+ if (lc && lc != 'none' && lw > 0) {
129
+ cg.ctx.strokeStyle = lc
130
+ cg.ctx.lineWidth = lw
131
+ cg.ctx.stroke()
132
+ }
133
+ }
134
+ }
135
+ }