gridviz 2.1.9 → 2.1.11

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 (57) hide show
  1. package/README.md +125 -125
  2. package/dist/gridviz.js +8036 -8024
  3. package/dist/gridviz.min.js +1 -1
  4. package/package.json +77 -77
  5. package/src/App.js +705 -705
  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 +113 -101
  10. package/src/GeoCanvas.js +420 -420
  11. package/src/LabelLayer.js +190 -190
  12. package/src/Layer.js +103 -103
  13. package/src/Legend.js +86 -86
  14. package/src/LineLayer.js +150 -150
  15. package/src/Style.js +129 -129
  16. package/src/Tooltip.js +180 -180
  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/LGrid.js +54 -54
  22. package/src/dataset/TiledGrid.js +264 -264
  23. package/src/index.js +71 -71
  24. package/src/legend/ColorCategoryLegend.js +124 -124
  25. package/src/legend/ColorDiscreteLegend.js +103 -103
  26. package/src/legend/ColorLegend.js +124 -124
  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/IsoFenceStyle.js +262 -262
  34. package/src/style/JoyPlotStyle.js +135 -135
  35. package/src/style/LegoStyle.js +112 -112
  36. package/src/style/MosaicStyle.js +107 -107
  37. package/src/style/NinjaStarStyle.js +125 -125
  38. package/src/style/PillarStyle.js +230 -230
  39. package/src/style/SegmentStyle.js +142 -142
  40. package/src/style/ShapeColorSizeStyle.js +126 -126
  41. package/src/style/SideCatStyle.js +172 -172
  42. package/src/style/SideStyle.js +216 -216
  43. package/src/style/SquareColorCatWGLStyle.js +120 -120
  44. package/src/style/SquareColorWGLStyle.js +146 -146
  45. package/src/style/StrokeStyle.js +131 -131
  46. package/src/style/TanakaStyle.js +160 -160
  47. package/src/style/TextStyle.js +132 -132
  48. package/src/style/TimeSeriesStyle.js +250 -250
  49. package/src/utils/Utils.js +35 -35
  50. package/src/utils/WebGLRectangleColoring.js +106 -106
  51. package/src/utils/WebGLSquareColoring.js +118 -118
  52. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  53. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  54. package/src/utils/WebGLSquareColoringKS.js +153 -153
  55. package/src/utils/stretching.js +131 -131
  56. package/src/utils/webGLUtils.js +71 -71
  57. package/src/utils/zoomUtils.js +142 -142
@@ -1,141 +1,141 @@
1
- //@ts-check
2
- 'use strict'
3
-
4
- import { Legend } from '../Legend.js'
5
- import { format } from 'd3-format'
6
-
7
- /**
8
- * A legend element for proportional symbols.
9
- *
10
- * @author Joseph Davies, Julien Gaffuri
11
- */
12
- export class SizeLegend extends Legend {
13
- /** @param {Object} opts */
14
- constructor(opts) {
15
- super(opts)
16
- opts = opts || {}
17
-
18
- //exageration
19
- this.exaggerationFactor = opts.exaggerationFactor || 0.8
20
-
21
- //if value is to be forced
22
- this.value = opts.value || undefined
23
-
24
- //title
25
- this.title = opts.title
26
- this.titleFontSize = opts.titleFontSize || '0.8em'
27
- this.titleFontWeight = opts.titleFontWeight || 'bold'
28
-
29
- //symbol
30
- /**
31
- * @private
32
- * @type {import("../Style").Shape} */
33
- this.shape = opts.shape || 'circle'
34
- this.fillColor = opts.fillColor || 'none'
35
- this.strokeColor = opts.strokeColor || 'gray'
36
- this.strokeWidth = opts.strokeWidth || 1
37
-
38
- //label
39
- this.labelFontSize = opts.labelFontSize || '0.8em'
40
- this.labelUnitText = opts.labelUnitText || ''
41
- this.labelFormat = opts.labelFormat || ',.2r'
42
-
43
- //
44
- //this.div.style("text-align", "center")
45
- }
46
-
47
- /**
48
- * @param {{ style: import("../style/ShapeColorSizeStyle").ShapeColorSizeStyle, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
49
- */
50
- update(opts) {
51
- //could happen when data is still loading
52
- if (!opts.sSize) return
53
-
54
- //clear
55
- this.div.selectAll('*').remove()
56
-
57
- //get value
58
- let value = this.value
59
- if (value == undefined) {
60
- //compute 'nice value
61
-
62
- //get max value
63
- const value_ = opts.sSize.max * this.exaggerationFactor
64
-
65
- //take 'nice' value (power of ten, or multiple)
66
- let pow10 = Math.log10(value_)
67
- pow10 = Math.floor(pow10)
68
- value = Math.pow(10, pow10)
69
- if (value * 8 <= value_) value *= 8
70
- else if (value * 6 <= value_) value *= 6
71
- else if (value * 5 <= value_) value *= 5
72
- else if (value * 4 <= value_) value *= 4
73
- else if (value * 2.5 <= value_) value *= 2.5
74
- else if (value * 2 <= value_) value *= 2
75
- }
76
-
77
- if (!value) return
78
-
79
- const d = this.div.append('div')
80
- //to enable vertical centering
81
- //.style("position", "relative")
82
-
83
- //title
84
- if (this.title) {
85
- d.append('div')
86
- .attr('class', 'title')
87
- .style('font-size', this.titleFontSize)
88
- .style('font-weight', this.titleFontWeight)
89
- .text(this.title)
90
- }
91
-
92
- //compute size of symbol, in pix
93
- const size = opts.style.size(value, opts.r, opts.sSize, opts.zf) / opts.zf
94
-
95
- const svg = d
96
- .append('svg')
97
- .attr('width', size + this.strokeWidth + 2)
98
- .attr('height', size + this.strokeWidth + 2)
99
- .style('', 'inline-block')
100
-
101
- if (this.shape === 'square') {
102
- svg.append('rect')
103
- .attr('x', 0)
104
- .attr('y', 0)
105
- .attr('width', size)
106
- .attr('height', size)
107
- .style('fill', this.fillColor)
108
- .style('stroke', this.strokeColor)
109
- .style('stroke-width', this.strokeWidth)
110
- //TODO test
111
- } else if (this.shape === 'circle') {
112
- // <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
113
- const r = (size + this.strokeWidth) * 0.5
114
- svg.append('circle')
115
- .attr('cx', r + 1)
116
- .attr('cy', r + 1)
117
- .attr('r', r)
118
- .style('fill', this.fillColor)
119
- .style('stroke', this.strokeColor)
120
- .style('stroke-width', this.strokeWidth)
121
- } else if (this.shape === 'donut') {
122
- //TODO
123
- } else if (this.shape === 'diamond') {
124
- //TODO
125
- } else {
126
- throw new Error('Unexpected shape:' + this.shape)
127
- }
128
-
129
- const valueT = format(this.labelFormat)(value)
130
- d.append('div')
131
- //show on right of graphic
132
- .style('display', 'inline')
133
-
134
- //center vertically
135
- //.style("position", "absolute").style("top", "0").style("bottom", "0")
136
-
137
- .style('padding-left', '5px')
138
- .style('font-size', this.labelFontSize)
139
- .text(valueT + (this.labelUnitText ? ' ' : '') + this.labelUnitText)
140
- }
141
- }
1
+ //@ts-check
2
+ 'use strict'
3
+
4
+ import { Legend } from '../Legend.js'
5
+ import { format } from 'd3-format'
6
+
7
+ /**
8
+ * A legend element for proportional symbols.
9
+ *
10
+ * @author Joseph Davies, Julien Gaffuri
11
+ */
12
+ export class SizeLegend extends Legend {
13
+ /** @param {Object} opts */
14
+ constructor(opts) {
15
+ super(opts)
16
+ opts = opts || {}
17
+
18
+ //exageration
19
+ this.exaggerationFactor = opts.exaggerationFactor || 0.8
20
+
21
+ //if value is to be forced
22
+ this.value = opts.value || undefined
23
+
24
+ //title
25
+ this.title = opts.title
26
+ this.titleFontSize = opts.titleFontSize || '0.8em'
27
+ this.titleFontWeight = opts.titleFontWeight || 'bold'
28
+
29
+ //symbol
30
+ /**
31
+ * @private
32
+ * @type {import("../Style").Shape} */
33
+ this.shape = opts.shape || 'circle'
34
+ this.fillColor = opts.fillColor || 'none'
35
+ this.strokeColor = opts.strokeColor || 'gray'
36
+ this.strokeWidth = opts.strokeWidth || 1
37
+
38
+ //label
39
+ this.labelFontSize = opts.labelFontSize || '0.8em'
40
+ this.labelUnitText = opts.labelUnitText || ''
41
+ this.labelFormat = opts.labelFormat || ',.2r'
42
+
43
+ //
44
+ //this.div.style("text-align", "center")
45
+ }
46
+
47
+ /**
48
+ * @param {{ style: import("../style/ShapeColorSizeStyle").ShapeColorSizeStyle, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
49
+ */
50
+ update(opts) {
51
+ //could happen when data is still loading
52
+ if (!opts.sSize) return
53
+
54
+ //clear
55
+ this.div.selectAll('*').remove()
56
+
57
+ //get value
58
+ let value = this.value
59
+ if (value == undefined) {
60
+ //compute 'nice value
61
+
62
+ //get max value
63
+ const value_ = opts.sSize.max * this.exaggerationFactor
64
+
65
+ //take 'nice' value (power of ten, or multiple)
66
+ let pow10 = Math.log10(value_)
67
+ pow10 = Math.floor(pow10)
68
+ value = Math.pow(10, pow10)
69
+ if (value * 8 <= value_) value *= 8
70
+ else if (value * 6 <= value_) value *= 6
71
+ else if (value * 5 <= value_) value *= 5
72
+ else if (value * 4 <= value_) value *= 4
73
+ else if (value * 2.5 <= value_) value *= 2.5
74
+ else if (value * 2 <= value_) value *= 2
75
+ }
76
+
77
+ if (!value) return
78
+
79
+ const d = this.div.append('div')
80
+ //to enable vertical centering
81
+ //.style("position", "relative")
82
+
83
+ //title
84
+ if (this.title) {
85
+ d.append('div')
86
+ .attr('class', 'title')
87
+ .style('font-size', this.titleFontSize)
88
+ .style('font-weight', this.titleFontWeight)
89
+ .text(this.title)
90
+ }
91
+
92
+ //compute size of symbol, in pix
93
+ const size = opts.style.size(value, opts.r, opts.sSize, opts.zf) / opts.zf
94
+
95
+ const svg = d
96
+ .append('svg')
97
+ .attr('width', size + this.strokeWidth + 2)
98
+ .attr('height', size + this.strokeWidth + 2)
99
+ .style('', 'inline-block')
100
+
101
+ if (this.shape === 'square') {
102
+ svg.append('rect')
103
+ .attr('x', 0)
104
+ .attr('y', 0)
105
+ .attr('width', size)
106
+ .attr('height', size)
107
+ .style('fill', this.fillColor)
108
+ .style('stroke', this.strokeColor)
109
+ .style('stroke-width', this.strokeWidth)
110
+ //TODO test
111
+ } else if (this.shape === 'circle') {
112
+ // <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
113
+ const r = (size + this.strokeWidth) * 0.5
114
+ svg.append('circle')
115
+ .attr('cx', r + 1)
116
+ .attr('cy', r + 1)
117
+ .attr('r', r)
118
+ .style('fill', this.fillColor)
119
+ .style('stroke', this.strokeColor)
120
+ .style('stroke-width', this.strokeWidth)
121
+ } else if (this.shape === 'donut') {
122
+ //TODO
123
+ } else if (this.shape === 'diamond') {
124
+ //TODO
125
+ } else {
126
+ throw new Error('Unexpected shape:' + this.shape)
127
+ }
128
+
129
+ const valueT = format(this.labelFormat)(value)
130
+ d.append('div')
131
+ //show on right of graphic
132
+ .style('display', 'inline')
133
+
134
+ //center vertically
135
+ //.style("position", "absolute").style("top", "0").style("bottom", "0")
136
+
137
+ .style('padding-left', '5px')
138
+ .style('font-size', this.labelFontSize)
139
+ .text(valueT + (this.labelUnitText ? ' ' : '') + this.labelUnitText)
140
+ }
141
+ }