gridviz 2.0.45 → 2.0.46

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 (53) hide show
  1. package/README.md +119 -119
  2. package/dist/gridviz.js +6937 -6937
  3. package/package.json +76 -76
  4. package/src/App.js +668 -668
  5. package/src/BackgroundLayer.js +182 -182
  6. package/src/BackgroundLayerWMS.js +131 -131
  7. package/src/Dataset.js +76 -76
  8. package/src/DatasetComponent.js +101 -101
  9. package/src/GeoCanvas.js +420 -420
  10. package/src/LabelLayer.js +190 -190
  11. package/src/Layer.js +92 -92
  12. package/src/Legend.js +86 -86
  13. package/src/LineLayer.js +150 -150
  14. package/src/Style.js +114 -114
  15. package/src/Tooltip.js +172 -172
  16. package/src/dataset/COGeo.js +24 -24
  17. package/src/dataset/CSVGrid.js +104 -104
  18. package/src/dataset/GeoTIFF.js +127 -127
  19. package/src/dataset/GridTile.js +41 -41
  20. package/src/dataset/TiledGrid.js +264 -264
  21. package/src/index.js +177 -176
  22. package/src/legend/ColorCategoryLegend.js +124 -124
  23. package/src/legend/ColorDiscreteLegend.js +103 -103
  24. package/src/legend/ColorLegend.js +124 -124
  25. package/src/legend/SegmentOrientationLegend.js +87 -87
  26. package/src/legend/SegmentWidthLegend.js +97 -97
  27. package/src/legend/SizeLegend.js +141 -141
  28. package/src/style/CompositionStyle.js +300 -300
  29. package/src/style/ContourStyle.js +54 -54
  30. package/src/style/DotDensityStyle.js +156 -156
  31. package/src/style/JoyPlotStyle.js +135 -135
  32. package/src/style/LegoStyle.js +112 -112
  33. package/src/style/MosaicStyle.js +107 -107
  34. package/src/style/NinjaStarStyle.js +124 -124
  35. package/src/style/PillarStyle.js +230 -230
  36. package/src/style/SegmentStyle.js +142 -142
  37. package/src/style/ShapeColorSizeStyle.js +126 -126
  38. package/src/style/SideCatStyle.js +172 -172
  39. package/src/style/SideStyle.js +218 -218
  40. package/src/style/SquareColorCatWGLStyle.js +120 -120
  41. package/src/style/SquareColorWGLStyle.js +146 -146
  42. package/src/style/StrokeStyle.js +131 -131
  43. package/src/style/TanakaStyle.js +160 -160
  44. package/src/style/TextStyle.js +132 -132
  45. package/src/utils/Utils.js +35 -35
  46. package/src/utils/WebGLRectangleColoring.js +106 -106
  47. package/src/utils/WebGLSquareColoring.js +118 -118
  48. package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
  49. package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
  50. package/src/utils/WebGLSquareColoringKS.js +153 -153
  51. package/src/utils/stretching.js +131 -131
  52. package/src/utils/webGLUtils.js +71 -71
  53. package/src/utils/zoomUtils.js +142 -142
@@ -1,97 +1,97 @@
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 segment width.
9
- *
10
- * @author Joseph Davies, Julien Gaffuri
11
- */
12
- export class SegmentWidthLegend extends Legend {
13
- /** @param {Object} opts */
14
- constructor(opts) {
15
- super(opts)
16
- opts = opts || {}
17
-
18
- //title
19
- this.title = opts.title
20
- this.titleFontSize = opts.titleFontSize || '0.8em'
21
- this.titleFontWeight = opts.titleFontWeight || 'bold'
22
-
23
- //exageration
24
- this.exaggerationFactor = opts.exaggerationFactor || 0.5
25
-
26
- //color
27
- this.color = opts.color || 'gray'
28
- //orientation
29
- this.orientation = opts.orientation || 0
30
-
31
- //label
32
- this.labelFontSize = opts.labelFontSize || '0.8em'
33
- this.labelUnitText = opts.labelUnitText || ''
34
- }
35
-
36
- /**
37
- * @param {{ style: import("../style/SegmentStyle").SegmentStyle, r: number, zf: number, sColor: import("../Style").Stat, sLength: import("../Style").Stat, sWidth: import("../Style").Stat }} opts
38
- */
39
- update(opts) {
40
- //could happen when data is still loading
41
- if (!opts.sWidth) return
42
-
43
- //clear
44
- this.div.selectAll('*').remove()
45
-
46
- const d = this.div.append('div')
47
-
48
- //title
49
- if (this.title) {
50
- d.append('div')
51
- .attr('class', 'title')
52
- .style('font-size', this.titleFontSize)
53
- .style('font-weight', this.titleFontWeight)
54
- .text(this.title)
55
- }
56
-
57
- //get max value
58
- const value_ = opts.sWidth.max * this.exaggerationFactor
59
-
60
- //take 'nice' value (power of ten, or multiple)
61
- let pow10 = Math.log10(value_)
62
- pow10 = Math.floor(pow10)
63
- let value = Math.pow(10, pow10)
64
- if (value * 8 <= value_) value *= 8
65
- else if (value * 6 <= value_) value *= 6
66
- else if (value * 5 <= value_) value *= 5
67
- else if (value * 4 <= value_) value *= 4
68
- else if (value * 2.5 <= value_) value *= 2.5
69
- else if (value * 2 <= value_) value *= 2
70
-
71
- //compute segment width and length, in pix
72
- const sWidth = opts.style.width(value, opts.r, opts.sWidth, opts.zf) / opts.zf
73
- const sLength = (1 * opts.r) / opts.zf
74
-
75
- //TODO use orientation
76
-
77
- const svg = d.append('svg').attr('width', sLength).attr('height', sWidth).style('', 'inline-block')
78
-
79
- //<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
80
- svg.append('line')
81
- .attr('x1', 0)
82
- .attr('y1', sWidth / 2)
83
- .attr('x2', sLength)
84
- .attr('y2', sWidth / 2)
85
- .style('stroke', this.color)
86
- .style('stroke-width', sWidth)
87
-
88
- const valueT = format(',.2r')(value)
89
- d.append('div')
90
- //show on right of graphic
91
- .style('display', 'inline')
92
- .style('padding-left', '5px')
93
- .style('font-size', this.labelFontSize)
94
- //.style("font-weight", "bold")
95
- .text(valueT + (this.labelUnitText ? ' ' : '') + this.labelUnitText)
96
- }
97
- }
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 segment width.
9
+ *
10
+ * @author Joseph Davies, Julien Gaffuri
11
+ */
12
+ export class SegmentWidthLegend extends Legend {
13
+ /** @param {Object} opts */
14
+ constructor(opts) {
15
+ super(opts)
16
+ opts = opts || {}
17
+
18
+ //title
19
+ this.title = opts.title
20
+ this.titleFontSize = opts.titleFontSize || '0.8em'
21
+ this.titleFontWeight = opts.titleFontWeight || 'bold'
22
+
23
+ //exageration
24
+ this.exaggerationFactor = opts.exaggerationFactor || 0.5
25
+
26
+ //color
27
+ this.color = opts.color || 'gray'
28
+ //orientation
29
+ this.orientation = opts.orientation || 0
30
+
31
+ //label
32
+ this.labelFontSize = opts.labelFontSize || '0.8em'
33
+ this.labelUnitText = opts.labelUnitText || ''
34
+ }
35
+
36
+ /**
37
+ * @param {{ style: import("../style/SegmentStyle").SegmentStyle, r: number, zf: number, sColor: import("../Style").Stat, sLength: import("../Style").Stat, sWidth: import("../Style").Stat }} opts
38
+ */
39
+ update(opts) {
40
+ //could happen when data is still loading
41
+ if (!opts.sWidth) return
42
+
43
+ //clear
44
+ this.div.selectAll('*').remove()
45
+
46
+ const d = this.div.append('div')
47
+
48
+ //title
49
+ if (this.title) {
50
+ d.append('div')
51
+ .attr('class', 'title')
52
+ .style('font-size', this.titleFontSize)
53
+ .style('font-weight', this.titleFontWeight)
54
+ .text(this.title)
55
+ }
56
+
57
+ //get max value
58
+ const value_ = opts.sWidth.max * this.exaggerationFactor
59
+
60
+ //take 'nice' value (power of ten, or multiple)
61
+ let pow10 = Math.log10(value_)
62
+ pow10 = Math.floor(pow10)
63
+ let value = Math.pow(10, pow10)
64
+ if (value * 8 <= value_) value *= 8
65
+ else if (value * 6 <= value_) value *= 6
66
+ else if (value * 5 <= value_) value *= 5
67
+ else if (value * 4 <= value_) value *= 4
68
+ else if (value * 2.5 <= value_) value *= 2.5
69
+ else if (value * 2 <= value_) value *= 2
70
+
71
+ //compute segment width and length, in pix
72
+ const sWidth = opts.style.width(value, opts.r, opts.sWidth, opts.zf) / opts.zf
73
+ const sLength = (1 * opts.r) / opts.zf
74
+
75
+ //TODO use orientation
76
+
77
+ const svg = d.append('svg').attr('width', sLength).attr('height', sWidth).style('', 'inline-block')
78
+
79
+ //<line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
80
+ svg.append('line')
81
+ .attr('x1', 0)
82
+ .attr('y1', sWidth / 2)
83
+ .attr('x2', sLength)
84
+ .attr('y2', sWidth / 2)
85
+ .style('stroke', this.color)
86
+ .style('stroke-width', sWidth)
87
+
88
+ const valueT = format(',.2r')(value)
89
+ d.append('div')
90
+ //show on right of graphic
91
+ .style('display', 'inline')
92
+ .style('padding-left', '5px')
93
+ .style('font-size', this.labelFontSize)
94
+ //.style("font-weight", "bold")
95
+ .text(valueT + (this.labelUnitText ? ' ' : '') + this.labelUnitText)
96
+ }
97
+ }
@@ -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
+ }