gridviz 3.0.19 → 3.0.21
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.
- package/README.md +128 -128
- package/dist/gridviz.js +7875 -7857
- package/dist/gridviz.min.js +1 -1
- package/package.json +74 -74
- package/src/button/ZoomButtons.js +101 -101
- package/src/core/Dataset.js +154 -154
- package/src/core/Drawable.js +78 -60
- package/src/core/GeoCanvas.js +430 -430
- package/src/core/Layer.js +23 -23
- package/src/core/Legend.js +108 -108
- package/src/core/Map.js +516 -516
- package/src/core/MultiResolutionDataset.js +93 -93
- package/src/core/Style.js +98 -98
- package/src/dataset/CSVGrid.js +112 -112
- package/src/dataset/GeoTIFF.js +122 -122
- package/src/dataset/JSGrid.js +55 -55
- package/src/dataset/TiledGrid.js +302 -302
- package/src/dataset/worker.js +18 -18
- package/src/index.js +77 -77
- package/src/layer/BackgroundLayer.js +162 -162
- package/src/layer/BackgroundLayerImage.js +81 -81
- package/src/layer/BackgroundLayerWMS.js +104 -104
- package/src/layer/GeoJSONLayer.js +214 -214
- package/src/layer/GridLayer.js +148 -148
- package/src/layer/LabelLayer.js +194 -194
- package/src/legend/ColorCategoryLegend.js +109 -109
- package/src/legend/ColorDiscreteLegend.js +100 -100
- package/src/legend/ColorLegend.js +115 -115
- package/src/legend/OrientationLegend.js +89 -89
- package/src/legend/SizeLegend.js +224 -224
- package/src/legend/TernaryLegend.js +302 -302
- package/src/style/CompositionStyle.js +291 -291
- package/src/style/DotDensityStyle.js +133 -133
- package/src/style/ImageStyle.js +100 -100
- package/src/style/IsoFenceStyle.js +217 -217
- package/src/style/JoyPlotStyle.js +127 -127
- package/src/style/LegoStyle.js +110 -110
- package/src/style/MosaicStyle.js +99 -99
- package/src/style/NinjaStarStyle.js +102 -102
- package/src/style/PillarStyle.js +207 -207
- package/src/style/SegmentStyle.js +105 -105
- package/src/style/ShapeColorSizeStyle.js +147 -147
- package/src/style/SideCategoryStyle.js +112 -112
- package/src/style/SideStyle.js +212 -212
- package/src/style/SquareColorCategoryWebGLStyle.js +107 -107
- package/src/style/SquareColorWebGLStyle.js +126 -126
- package/src/style/StrokeStyle.js +135 -135
- package/src/style/TanakaStyle.js +69 -69
- package/src/style/TextStyle.js +110 -110
- package/src/style/TimeSeriesStyle.js +222 -222
- package/src/utils/scale.js +218 -218
- package/src/utils/stretching.js +120 -120
- package/src/utils/ternary.js +208 -208
- package/src/utils/utils.js +58 -58
- package/src/utils/webGLUtils.js +72 -72
package/src/core/Layer.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { Drawable } from './Drawable.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* @module core
|
|
8
|
-
* @abstract
|
|
9
|
-
* @author Joseph Davies, Julien Gaffuri
|
|
10
|
-
*/
|
|
11
|
-
export class Layer extends Drawable {
|
|
12
|
-
/**
|
|
13
|
-
* Draw layer.
|
|
14
|
-
*
|
|
15
|
-
* @param {import("./GeoCanvas").GeoCanvas} geoCanvas The canvas where to draw the layer.
|
|
16
|
-
* @param {object} legend
|
|
17
|
-
* @returns {void}
|
|
18
|
-
* @abstract
|
|
19
|
-
*/
|
|
20
|
-
draw(geoCanvas, legend = undefined) {
|
|
21
|
-
throw new Error('Method draw not implemented.')
|
|
22
|
-
}
|
|
23
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { Drawable } from './Drawable.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @module core
|
|
8
|
+
* @abstract
|
|
9
|
+
* @author Joseph Davies, Julien Gaffuri
|
|
10
|
+
*/
|
|
11
|
+
export class Layer extends Drawable {
|
|
12
|
+
/**
|
|
13
|
+
* Draw layer.
|
|
14
|
+
*
|
|
15
|
+
* @param {import("./GeoCanvas").GeoCanvas} geoCanvas The canvas where to draw the layer.
|
|
16
|
+
* @param {object} legend
|
|
17
|
+
* @returns {void}
|
|
18
|
+
* @abstract
|
|
19
|
+
*/
|
|
20
|
+
draw(geoCanvas, legend = undefined) {
|
|
21
|
+
throw new Error('Method draw not implemented.')
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/core/Legend.js
CHANGED
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { select } from 'd3-selection'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A legend container.
|
|
8
|
-
*
|
|
9
|
-
* @module core
|
|
10
|
-
* @author Joseph Davies, Julien Gaffuri
|
|
11
|
-
*/
|
|
12
|
-
export class Legend {
|
|
13
|
-
/**
|
|
14
|
-
* @param {Object} opts
|
|
15
|
-
*/
|
|
16
|
-
constructor(opts) {
|
|
17
|
-
opts = opts || {}
|
|
18
|
-
|
|
19
|
-
/** @type {string} */
|
|
20
|
-
this.id = opts.id
|
|
21
|
-
|
|
22
|
-
//TODO stop using it. Use style method below instead.
|
|
23
|
-
|
|
24
|
-
/** @type {number} @deprecated */
|
|
25
|
-
this.top = opts.top
|
|
26
|
-
/** @type {number} @deprecated */
|
|
27
|
-
this.bottom = opts.bottom
|
|
28
|
-
/** @type {number} @deprecated */
|
|
29
|
-
this.left = opts.left
|
|
30
|
-
/** @type {number} @deprecated */
|
|
31
|
-
this.right = opts.right
|
|
32
|
-
/** @type {string} @deprecated */
|
|
33
|
-
this.background = opts.background || 'none'
|
|
34
|
-
/** @type {string} @deprecated */
|
|
35
|
-
this.padding = opts.padding || '5px'
|
|
36
|
-
/** @type {string} @deprecated */
|
|
37
|
-
this.border = opts.border || '0px'
|
|
38
|
-
/** @type {string} @deprecated */
|
|
39
|
-
this['border-radius'] = opts['border-radius'] || 'none'
|
|
40
|
-
/** @type {string} @deprecated */
|
|
41
|
-
this['box-shadow'] = opts['box-shadow'] || 'none'
|
|
42
|
-
/** @type {string} @deprecated */
|
|
43
|
-
this['font-family'] = opts['font-family'] || 'Helvetica, Arial, sans-serif'
|
|
44
|
-
/** @type {string} @deprecated */
|
|
45
|
-
//this.width = opts.width
|
|
46
|
-
/** @type {string} @deprecated */
|
|
47
|
-
//this.height = opts.height
|
|
48
|
-
|
|
49
|
-
//the div element
|
|
50
|
-
if (this.id) this.div = select('#' + this.id)
|
|
51
|
-
|
|
52
|
-
if (!this.div || this.div.empty()) {
|
|
53
|
-
this.div = select(document.createElement('div'))
|
|
54
|
-
if (this.id) this.div.attr('id', this.id)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//set style
|
|
58
|
-
this.div.style('background', this.background)
|
|
59
|
-
this.div.style('padding', this.padding)
|
|
60
|
-
this.div.style('border', this.border)
|
|
61
|
-
this.div.style('border-radius', this['border-radius'])
|
|
62
|
-
this.div.style('box-shadow', this['box-shadow'])
|
|
63
|
-
this.div.style('font-family', this['font-family'])
|
|
64
|
-
|
|
65
|
-
//if (this.width) this.div.style('width', this.width)
|
|
66
|
-
//if (this.height) this.div.style('height', this.height)
|
|
67
|
-
|
|
68
|
-
//title
|
|
69
|
-
this.title = opts.title
|
|
70
|
-
this.titleFontSize = opts.titleFontSize || '0.8em'
|
|
71
|
-
this.titleFontWeight = opts.titleFontWeight || 'bold'
|
|
72
|
-
|
|
73
|
-
//label
|
|
74
|
-
this.labelFontSize = opts.labelFontSize || '0.8em'
|
|
75
|
-
this.labelUnitText = opts.labelUnitText || ''
|
|
76
|
-
this.labelFormat = opts.labelFormat
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
makeTitle() {
|
|
80
|
-
if (!this.title) return
|
|
81
|
-
this.div
|
|
82
|
-
.append('div')
|
|
83
|
-
.style('font-size', this.titleFontSize)
|
|
84
|
-
.style('font-weight', this.titleFontWeight)
|
|
85
|
-
.style('margin-bottom', '7px')
|
|
86
|
-
.text(this.title)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Apply a style to the legend div.
|
|
91
|
-
* @param {string} k
|
|
92
|
-
* @param {string} v
|
|
93
|
-
* @returns {this|string}
|
|
94
|
-
*/
|
|
95
|
-
style(k, v) {
|
|
96
|
-
if (arguments.length == 1) return this.div.style(k)
|
|
97
|
-
this.div.style(k, v)
|
|
98
|
-
return this
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @param {Object} opts
|
|
103
|
-
* @abstract
|
|
104
|
-
*/
|
|
105
|
-
update(opts = {}) {
|
|
106
|
-
console.error('Legend update not implemented yet.')
|
|
107
|
-
}
|
|
108
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { select } from 'd3-selection'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A legend container.
|
|
8
|
+
*
|
|
9
|
+
* @module core
|
|
10
|
+
* @author Joseph Davies, Julien Gaffuri
|
|
11
|
+
*/
|
|
12
|
+
export class Legend {
|
|
13
|
+
/**
|
|
14
|
+
* @param {Object} opts
|
|
15
|
+
*/
|
|
16
|
+
constructor(opts) {
|
|
17
|
+
opts = opts || {}
|
|
18
|
+
|
|
19
|
+
/** @type {string} */
|
|
20
|
+
this.id = opts.id
|
|
21
|
+
|
|
22
|
+
//TODO stop using it. Use style method below instead.
|
|
23
|
+
|
|
24
|
+
/** @type {number} @deprecated */
|
|
25
|
+
this.top = opts.top
|
|
26
|
+
/** @type {number} @deprecated */
|
|
27
|
+
this.bottom = opts.bottom
|
|
28
|
+
/** @type {number} @deprecated */
|
|
29
|
+
this.left = opts.left
|
|
30
|
+
/** @type {number} @deprecated */
|
|
31
|
+
this.right = opts.right
|
|
32
|
+
/** @type {string} @deprecated */
|
|
33
|
+
this.background = opts.background || 'none'
|
|
34
|
+
/** @type {string} @deprecated */
|
|
35
|
+
this.padding = opts.padding || '5px'
|
|
36
|
+
/** @type {string} @deprecated */
|
|
37
|
+
this.border = opts.border || '0px'
|
|
38
|
+
/** @type {string} @deprecated */
|
|
39
|
+
this['border-radius'] = opts['border-radius'] || 'none'
|
|
40
|
+
/** @type {string} @deprecated */
|
|
41
|
+
this['box-shadow'] = opts['box-shadow'] || 'none'
|
|
42
|
+
/** @type {string} @deprecated */
|
|
43
|
+
this['font-family'] = opts['font-family'] || 'Helvetica, Arial, sans-serif'
|
|
44
|
+
/** @type {string} @deprecated */
|
|
45
|
+
//this.width = opts.width
|
|
46
|
+
/** @type {string} @deprecated */
|
|
47
|
+
//this.height = opts.height
|
|
48
|
+
|
|
49
|
+
//the div element
|
|
50
|
+
if (this.id) this.div = select('#' + this.id)
|
|
51
|
+
|
|
52
|
+
if (!this.div || this.div.empty()) {
|
|
53
|
+
this.div = select(document.createElement('div'))
|
|
54
|
+
if (this.id) this.div.attr('id', this.id)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
//set style
|
|
58
|
+
this.div.style('background', this.background)
|
|
59
|
+
this.div.style('padding', this.padding)
|
|
60
|
+
this.div.style('border', this.border)
|
|
61
|
+
this.div.style('border-radius', this['border-radius'])
|
|
62
|
+
this.div.style('box-shadow', this['box-shadow'])
|
|
63
|
+
this.div.style('font-family', this['font-family'])
|
|
64
|
+
|
|
65
|
+
//if (this.width) this.div.style('width', this.width)
|
|
66
|
+
//if (this.height) this.div.style('height', this.height)
|
|
67
|
+
|
|
68
|
+
//title
|
|
69
|
+
this.title = opts.title
|
|
70
|
+
this.titleFontSize = opts.titleFontSize || '0.8em'
|
|
71
|
+
this.titleFontWeight = opts.titleFontWeight || 'bold'
|
|
72
|
+
|
|
73
|
+
//label
|
|
74
|
+
this.labelFontSize = opts.labelFontSize || '0.8em'
|
|
75
|
+
this.labelUnitText = opts.labelUnitText || ''
|
|
76
|
+
this.labelFormat = opts.labelFormat
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
makeTitle() {
|
|
80
|
+
if (!this.title) return
|
|
81
|
+
this.div
|
|
82
|
+
.append('div')
|
|
83
|
+
.style('font-size', this.titleFontSize)
|
|
84
|
+
.style('font-weight', this.titleFontWeight)
|
|
85
|
+
.style('margin-bottom', '7px')
|
|
86
|
+
.text(this.title)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Apply a style to the legend div.
|
|
91
|
+
* @param {string} k
|
|
92
|
+
* @param {string} v
|
|
93
|
+
* @returns {this|string}
|
|
94
|
+
*/
|
|
95
|
+
style(k, v) {
|
|
96
|
+
if (arguments.length == 1) return this.div.style(k)
|
|
97
|
+
this.div.style(k, v)
|
|
98
|
+
return this
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @param {Object} opts
|
|
103
|
+
* @abstract
|
|
104
|
+
*/
|
|
105
|
+
update(opts = {}) {
|
|
106
|
+
console.error('Legend update not implemented yet.')
|
|
107
|
+
}
|
|
108
|
+
}
|