gridviz 2.0.41 → 2.0.43
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 +119 -119
- package/dist/gridviz.js +7490 -7499
- package/dist/gridviz.min.js +1 -1
- package/package.json +76 -76
- package/src/App.js +642 -642
- package/src/BackgroundLayer.js +182 -182
- package/src/BackgroundLayerWMS.js +131 -131
- package/src/Dataset.js +76 -76
- package/src/DatasetComponent.js +101 -101
- package/src/GeoCanvas.js +420 -419
- package/src/LabelLayer.js +190 -190
- package/src/Layer.js +92 -92
- package/src/Legend.js +86 -86
- package/src/LineLayer.js +150 -150
- package/src/Style.js +114 -114
- package/src/Tooltip.js +168 -168
- package/src/dataset/COGeo.js +24 -24
- package/src/dataset/CSVGrid.js +104 -104
- package/src/dataset/GeoTIFF.js +127 -127
- package/src/dataset/GridTile.js +41 -41
- package/src/dataset/TiledGrid.js +264 -264
- package/src/index.js +176 -176
- package/src/legend/ColorCategoryLegend.js +124 -124
- package/src/legend/ColorDiscreteLegend.js +103 -105
- package/src/legend/ColorLegend.js +124 -125
- package/src/legend/SegmentOrientationLegend.js +87 -87
- package/src/legend/SegmentWidthLegend.js +97 -97
- package/src/legend/SizeLegend.js +141 -141
- package/src/style/CompositionStyle.js +300 -300
- package/src/style/ContourStyle.js +54 -54
- package/src/style/DotDensityStyle.js +156 -156
- package/src/style/JoyPlotStyle.js +135 -135
- package/src/style/LegoStyle.js +112 -112
- package/src/style/MosaicStyle.js +107 -107
- package/src/style/NinjaStarStyle.js +124 -124
- package/src/style/PillarStyle.js +230 -230
- package/src/style/SegmentStyle.js +142 -142
- package/src/style/ShapeColorSizeStyle.js +126 -126
- package/src/style/SideCatStyle.js +172 -172
- package/src/style/SideStyle.js +218 -218
- package/src/style/SquareColorCatWGLStyle.js +120 -120
- package/src/style/SquareColorWGLStyle.js +146 -146
- package/src/style/StrokeStyle.js +131 -131
- package/src/style/TanakaStyle.js +160 -160
- package/src/style/TextStyle.js +132 -132
- package/src/utils/Utils.js +35 -35
- package/src/utils/WebGLRectangleColoring.js +106 -106
- package/src/utils/WebGLSquareColoring.js +118 -118
- package/src/utils/WebGLSquareColoringAdvanced.js +230 -230
- package/src/utils/WebGLSquareColoringCatAdvanced.js +133 -133
- package/src/utils/WebGLSquareColoringKS.js +153 -153
- package/src/utils/stretching.js +131 -131
- package/src/utils/webGLUtils.js +71 -71
- package/src/utils/zoomUtils.js +142 -142
package/src/index.js
CHANGED
|
@@ -1,176 +1,176 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
// the application
|
|
5
|
-
export { App } from './App.js'
|
|
6
|
-
export { GeoCanvas } from './GeoCanvas.js'
|
|
7
|
-
export { Style } from './Style.js'
|
|
8
|
-
export { Layer } from './Layer.js'
|
|
9
|
-
export { Dataset } from './Dataset.js'
|
|
10
|
-
export { DatasetComponent } from './DatasetComponent.js'
|
|
11
|
-
|
|
12
|
-
// export dataset types
|
|
13
|
-
export { TiledGrid } from './dataset/TiledGrid.js'
|
|
14
|
-
export { CSVGrid } from './dataset/CSVGrid.js'
|
|
15
|
-
//export { GeoTIFF } from "./dataset/GeoTIFF"
|
|
16
|
-
|
|
17
|
-
// export styles
|
|
18
|
-
export { ShapeColorSizeStyle } from './style/ShapeColorSizeStyle.js'
|
|
19
|
-
export { StrokeStyle } from './style/StrokeStyle.js'
|
|
20
|
-
export { JoyPlotStyle } from './style/JoyPlotStyle.js'
|
|
21
|
-
export { CompositionStyle } from './style/CompositionStyle.js'
|
|
22
|
-
export { SegmentStyle } from './style/SegmentStyle.js'
|
|
23
|
-
export { TextStyle } from './style/TextStyle.js'
|
|
24
|
-
export { PillarStyle } from './style/PillarStyle.js'
|
|
25
|
-
export { SideStyle } from './style/SideStyle.js'
|
|
26
|
-
export { ContourStyle } from './style/ContourStyle.js'
|
|
27
|
-
export { SideCatStyle } from './style/SideCatStyle.js'
|
|
28
|
-
export { DotDensityStyle } from './style/DotDensityStyle.js'
|
|
29
|
-
export { TanakaStyle } from './style/TanakaStyle.js'
|
|
30
|
-
export { LegoStyle } from './style/LegoStyle.js'
|
|
31
|
-
export { SquareColorWGLStyle } from './style/SquareColorWGLStyle.js'
|
|
32
|
-
export { SquareColorCatWGLStyle } from './style/SquareColorCatWGLStyle.js'
|
|
33
|
-
export { MosaicStyle } from './style/MosaicStyle.js'
|
|
34
|
-
export { NinjaStarStyle } from './style/NinjaStarStyle.js'
|
|
35
|
-
|
|
36
|
-
// export additional layers
|
|
37
|
-
export { BackgroundLayer } from './BackgroundLayer.js'
|
|
38
|
-
export { BackgroundLayerWMS } from './BackgroundLayerWMS.js'
|
|
39
|
-
export { LabelLayer } from './LabelLayer.js'
|
|
40
|
-
export { LineLayer as BoundaryLayer } from './LineLayer.js'
|
|
41
|
-
|
|
42
|
-
// export legends
|
|
43
|
-
export { ColorLegend } from './legend/ColorLegend.js'
|
|
44
|
-
export { ColorDiscreteLegend } from './legend/ColorDiscreteLegend.js'
|
|
45
|
-
export { ColorCategoryLegend } from './legend/ColorCategoryLegend.js'
|
|
46
|
-
export { SizeLegend } from './legend/SizeLegend.js'
|
|
47
|
-
export { SegmentWidthLegend } from './legend/SegmentWidthLegend.js'
|
|
48
|
-
export { SegmentOrientationLegend } from './legend/SegmentOrientationLegend.js'
|
|
49
|
-
|
|
50
|
-
// export { goToStraight, zoomTo } from "./utils/zoomUtils"
|
|
51
|
-
export * from './utils/stretching.js'
|
|
52
|
-
|
|
53
|
-
export { getClass } from './utils/Utils.js'
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
import { GeoCanvas } from './GeoCanvas.js'
|
|
59
|
-
import { geoAzimuthalEqualArea } from 'd3-geo'
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Returns label layer from Eurostat, for ETRS89-LAEA grids.
|
|
63
|
-
* From Euronym data: https://github.com/eurostat/euronym
|
|
64
|
-
*
|
|
65
|
-
* @returns {object}
|
|
66
|
-
*/
|
|
67
|
-
export const getEuronymeLabelLayer = function (cc = 'EUR', res = 50, opts) {
|
|
68
|
-
opts = opts || {}
|
|
69
|
-
const ex = opts.ex || 1.2
|
|
70
|
-
const fontFamily = opts.fontFamily || 'Arial'
|
|
71
|
-
const exSize = opts.exSize || 1
|
|
72
|
-
opts.style =
|
|
73
|
-
opts.style ||
|
|
74
|
-
((lb, zf) => {
|
|
75
|
-
if (lb.rs < ex * zf) return
|
|
76
|
-
if (lb.r1 < ex * zf) return exSize + 'em ' + fontFamily
|
|
77
|
-
return exSize * 1.5 + 'em ' + fontFamily
|
|
78
|
-
})
|
|
79
|
-
//ETRS89-LAEA projection
|
|
80
|
-
opts.proj =
|
|
81
|
-
opts.proj ||
|
|
82
|
-
geoAzimuthalEqualArea()
|
|
83
|
-
.rotate([-10, -52])
|
|
84
|
-
.reflectX(false)
|
|
85
|
-
.reflectY(true)
|
|
86
|
-
.scale(6378137)
|
|
87
|
-
.translate([4321000, 3210000])
|
|
88
|
-
opts.preprocess = (lb) => {
|
|
89
|
-
//exclude countries
|
|
90
|
-
//if(opts.ccOut && lb.cc && opts.ccOut.includes(lb.cc)) return false;
|
|
91
|
-
if (opts.ccIn && lb.cc && !(opts.ccIn.indexOf(lb.cc) >= 0)) return false
|
|
92
|
-
|
|
93
|
-
//project from geo coordinates to ETRS89-LAEA
|
|
94
|
-
const p = opts.proj([lb.lon, lb.lat])
|
|
95
|
-
lb.x = p[0]
|
|
96
|
-
lb.y = p[1]
|
|
97
|
-
delete lb.lon
|
|
98
|
-
delete lb.lat
|
|
99
|
-
}
|
|
100
|
-
opts.baseURL = opts.baseURL || 'https://raw.githubusercontent.com/eurostat/euronym/main/pub/v2/UTF/'
|
|
101
|
-
opts.url = opts.baseURL + res + '/' + cc + '.csv'
|
|
102
|
-
return opts
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* @returns {object}
|
|
107
|
-
*/
|
|
108
|
-
export const getEurostatBoundariesLayer = function (opts) {
|
|
109
|
-
opts = opts || {}
|
|
110
|
-
const nutsYear = opts.nutsYear || '2021'
|
|
111
|
-
const crs = opts.crs || '3035'
|
|
112
|
-
const scale = opts.scale || '03M'
|
|
113
|
-
const nutsLevel = opts.nutsLevel || '3'
|
|
114
|
-
const col = opts.col || '#888'
|
|
115
|
-
const colKosovo = opts.colKosovo || '#bcbcbc'
|
|
116
|
-
const showOth = opts.showOth == undefined ? true : opts.showOth
|
|
117
|
-
|
|
118
|
-
opts.color =
|
|
119
|
-
opts.color ||
|
|
120
|
-
((f, zf) => {
|
|
121
|
-
const p = f.properties
|
|
122
|
-
if (!showOth /*&& p.co == "F"*/ && p.eu != 'T' && p.cc != 'T' && p.efta != 'T' && p.oth === 'T')
|
|
123
|
-
return
|
|
124
|
-
if (p.id >= 100000) return colKosovo
|
|
125
|
-
if (p.co === 'T') return col
|
|
126
|
-
if (zf < 400) return col
|
|
127
|
-
else if (zf < 1000) return p.lvl >= 3 ? '' : col
|
|
128
|
-
else if (zf < 2000) return p.lvl >= 2 ? '' : col
|
|
129
|
-
else return p.lvl >= 1 ? '' : col
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
opts.width =
|
|
133
|
-
opts.width ||
|
|
134
|
-
((f, zf) => {
|
|
135
|
-
const p = f.properties
|
|
136
|
-
if (p.co === 'T') return 0.5
|
|
137
|
-
if (zf < 400) return p.lvl == 3 ? 2.2 : p.lvl == 2 ? 2.2 : p.lvl == 1 ? 2.2 : 4
|
|
138
|
-
else if (zf < 1000) return p.lvl == 2 ? 1.8 : p.lvl == 1 ? 1.8 : 2.5
|
|
139
|
-
else if (zf < 2000) return p.lvl == 1 ? 1.8 : 2.5
|
|
140
|
-
else return 1.2
|
|
141
|
-
})
|
|
142
|
-
|
|
143
|
-
opts.lineDash =
|
|
144
|
-
opts.lineDash ||
|
|
145
|
-
((f, zf) => {
|
|
146
|
-
const p = f.properties
|
|
147
|
-
if (p.co === 'T') return []
|
|
148
|
-
if (zf < 400)
|
|
149
|
-
return p.lvl == 3
|
|
150
|
-
? [2 * zf, 2 * zf]
|
|
151
|
-
: p.lvl == 2
|
|
152
|
-
? [5 * zf, 2 * zf]
|
|
153
|
-
: p.lvl == 1
|
|
154
|
-
? [5 * zf, 2 * zf]
|
|
155
|
-
: [10 * zf, 3 * zf]
|
|
156
|
-
else if (zf < 1000)
|
|
157
|
-
return p.lvl == 2 ? [5 * zf, 2 * zf] : p.lvl == 1 ? [5 * zf, 2 * zf] : [10 * zf, 3 * zf]
|
|
158
|
-
else if (zf < 2000) return p.lvl == 1 ? [5 * zf, 2 * zf] : [10 * zf, 3 * zf]
|
|
159
|
-
else return [10 * zf, 3 * zf]
|
|
160
|
-
})
|
|
161
|
-
|
|
162
|
-
opts.baseURL = opts.baseURL || 'https://raw.githubusercontent.com/eurostat/Nuts2json/master/pub/v2/'
|
|
163
|
-
opts.url = opts.baseURL + nutsYear + '/' + crs + '/' + scale + '/nutsbn_' + nutsLevel + '.json'
|
|
164
|
-
return opts
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export const getParameterByName = GeoCanvas.getParameterByName
|
|
168
|
-
|
|
169
|
-
// set default d3 locale
|
|
170
|
-
import { formatDefaultLocale } from 'd3-format'
|
|
171
|
-
formatDefaultLocale({
|
|
172
|
-
decimal: '.',
|
|
173
|
-
thousands: ' ',
|
|
174
|
-
grouping: [3],
|
|
175
|
-
currency: ['', '€'],
|
|
176
|
-
})
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
// the application
|
|
5
|
+
export { App } from './App.js'
|
|
6
|
+
export { GeoCanvas } from './GeoCanvas.js'
|
|
7
|
+
export { Style } from './Style.js'
|
|
8
|
+
export { Layer } from './Layer.js'
|
|
9
|
+
export { Dataset } from './Dataset.js'
|
|
10
|
+
export { DatasetComponent } from './DatasetComponent.js'
|
|
11
|
+
|
|
12
|
+
// export dataset types
|
|
13
|
+
export { TiledGrid } from './dataset/TiledGrid.js'
|
|
14
|
+
export { CSVGrid } from './dataset/CSVGrid.js'
|
|
15
|
+
//export { GeoTIFF } from "./dataset/GeoTIFF"
|
|
16
|
+
|
|
17
|
+
// export styles
|
|
18
|
+
export { ShapeColorSizeStyle } from './style/ShapeColorSizeStyle.js'
|
|
19
|
+
export { StrokeStyle } from './style/StrokeStyle.js'
|
|
20
|
+
export { JoyPlotStyle } from './style/JoyPlotStyle.js'
|
|
21
|
+
export { CompositionStyle } from './style/CompositionStyle.js'
|
|
22
|
+
export { SegmentStyle } from './style/SegmentStyle.js'
|
|
23
|
+
export { TextStyle } from './style/TextStyle.js'
|
|
24
|
+
export { PillarStyle } from './style/PillarStyle.js'
|
|
25
|
+
export { SideStyle } from './style/SideStyle.js'
|
|
26
|
+
export { ContourStyle } from './style/ContourStyle.js'
|
|
27
|
+
export { SideCatStyle } from './style/SideCatStyle.js'
|
|
28
|
+
export { DotDensityStyle } from './style/DotDensityStyle.js'
|
|
29
|
+
export { TanakaStyle } from './style/TanakaStyle.js'
|
|
30
|
+
export { LegoStyle } from './style/LegoStyle.js'
|
|
31
|
+
export { SquareColorWGLStyle } from './style/SquareColorWGLStyle.js'
|
|
32
|
+
export { SquareColorCatWGLStyle } from './style/SquareColorCatWGLStyle.js'
|
|
33
|
+
export { MosaicStyle } from './style/MosaicStyle.js'
|
|
34
|
+
export { NinjaStarStyle } from './style/NinjaStarStyle.js'
|
|
35
|
+
|
|
36
|
+
// export additional layers
|
|
37
|
+
export { BackgroundLayer } from './BackgroundLayer.js'
|
|
38
|
+
export { BackgroundLayerWMS } from './BackgroundLayerWMS.js'
|
|
39
|
+
export { LabelLayer } from './LabelLayer.js'
|
|
40
|
+
export { LineLayer as BoundaryLayer } from './LineLayer.js'
|
|
41
|
+
|
|
42
|
+
// export legends
|
|
43
|
+
export { ColorLegend } from './legend/ColorLegend.js'
|
|
44
|
+
export { ColorDiscreteLegend } from './legend/ColorDiscreteLegend.js'
|
|
45
|
+
export { ColorCategoryLegend } from './legend/ColorCategoryLegend.js'
|
|
46
|
+
export { SizeLegend } from './legend/SizeLegend.js'
|
|
47
|
+
export { SegmentWidthLegend } from './legend/SegmentWidthLegend.js'
|
|
48
|
+
export { SegmentOrientationLegend } from './legend/SegmentOrientationLegend.js'
|
|
49
|
+
|
|
50
|
+
// export { goToStraight, zoomTo } from "./utils/zoomUtils"
|
|
51
|
+
export * from './utils/stretching.js'
|
|
52
|
+
|
|
53
|
+
export { getClass } from './utils/Utils.js'
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
import { GeoCanvas } from './GeoCanvas.js'
|
|
59
|
+
import { geoAzimuthalEqualArea } from 'd3-geo'
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Returns label layer from Eurostat, for ETRS89-LAEA grids.
|
|
63
|
+
* From Euronym data: https://github.com/eurostat/euronym
|
|
64
|
+
*
|
|
65
|
+
* @returns {object}
|
|
66
|
+
*/
|
|
67
|
+
export const getEuronymeLabelLayer = function (cc = 'EUR', res = 50, opts) {
|
|
68
|
+
opts = opts || {}
|
|
69
|
+
const ex = opts.ex || 1.2
|
|
70
|
+
const fontFamily = opts.fontFamily || 'Arial'
|
|
71
|
+
const exSize = opts.exSize || 1
|
|
72
|
+
opts.style =
|
|
73
|
+
opts.style ||
|
|
74
|
+
((lb, zf) => {
|
|
75
|
+
if (lb.rs < ex * zf) return
|
|
76
|
+
if (lb.r1 < ex * zf) return exSize + 'em ' + fontFamily
|
|
77
|
+
return exSize * 1.5 + 'em ' + fontFamily
|
|
78
|
+
})
|
|
79
|
+
//ETRS89-LAEA projection
|
|
80
|
+
opts.proj =
|
|
81
|
+
opts.proj ||
|
|
82
|
+
geoAzimuthalEqualArea()
|
|
83
|
+
.rotate([-10, -52])
|
|
84
|
+
.reflectX(false)
|
|
85
|
+
.reflectY(true)
|
|
86
|
+
.scale(6378137)
|
|
87
|
+
.translate([4321000, 3210000])
|
|
88
|
+
opts.preprocess = (lb) => {
|
|
89
|
+
//exclude countries
|
|
90
|
+
//if(opts.ccOut && lb.cc && opts.ccOut.includes(lb.cc)) return false;
|
|
91
|
+
if (opts.ccIn && lb.cc && !(opts.ccIn.indexOf(lb.cc) >= 0)) return false
|
|
92
|
+
|
|
93
|
+
//project from geo coordinates to ETRS89-LAEA
|
|
94
|
+
const p = opts.proj([lb.lon, lb.lat])
|
|
95
|
+
lb.x = p[0]
|
|
96
|
+
lb.y = p[1]
|
|
97
|
+
delete lb.lon
|
|
98
|
+
delete lb.lat
|
|
99
|
+
}
|
|
100
|
+
opts.baseURL = opts.baseURL || 'https://raw.githubusercontent.com/eurostat/euronym/main/pub/v2/UTF/'
|
|
101
|
+
opts.url = opts.baseURL + res + '/' + cc + '.csv'
|
|
102
|
+
return opts
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @returns {object}
|
|
107
|
+
*/
|
|
108
|
+
export const getEurostatBoundariesLayer = function (opts) {
|
|
109
|
+
opts = opts || {}
|
|
110
|
+
const nutsYear = opts.nutsYear || '2021'
|
|
111
|
+
const crs = opts.crs || '3035'
|
|
112
|
+
const scale = opts.scale || '03M'
|
|
113
|
+
const nutsLevel = opts.nutsLevel || '3'
|
|
114
|
+
const col = opts.col || '#888'
|
|
115
|
+
const colKosovo = opts.colKosovo || '#bcbcbc'
|
|
116
|
+
const showOth = opts.showOth == undefined ? true : opts.showOth
|
|
117
|
+
|
|
118
|
+
opts.color =
|
|
119
|
+
opts.color ||
|
|
120
|
+
((f, zf) => {
|
|
121
|
+
const p = f.properties
|
|
122
|
+
if (!showOth /*&& p.co == "F"*/ && p.eu != 'T' && p.cc != 'T' && p.efta != 'T' && p.oth === 'T')
|
|
123
|
+
return
|
|
124
|
+
if (p.id >= 100000) return colKosovo
|
|
125
|
+
if (p.co === 'T') return col
|
|
126
|
+
if (zf < 400) return col
|
|
127
|
+
else if (zf < 1000) return p.lvl >= 3 ? '' : col
|
|
128
|
+
else if (zf < 2000) return p.lvl >= 2 ? '' : col
|
|
129
|
+
else return p.lvl >= 1 ? '' : col
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
opts.width =
|
|
133
|
+
opts.width ||
|
|
134
|
+
((f, zf) => {
|
|
135
|
+
const p = f.properties
|
|
136
|
+
if (p.co === 'T') return 0.5
|
|
137
|
+
if (zf < 400) return p.lvl == 3 ? 2.2 : p.lvl == 2 ? 2.2 : p.lvl == 1 ? 2.2 : 4
|
|
138
|
+
else if (zf < 1000) return p.lvl == 2 ? 1.8 : p.lvl == 1 ? 1.8 : 2.5
|
|
139
|
+
else if (zf < 2000) return p.lvl == 1 ? 1.8 : 2.5
|
|
140
|
+
else return 1.2
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
opts.lineDash =
|
|
144
|
+
opts.lineDash ||
|
|
145
|
+
((f, zf) => {
|
|
146
|
+
const p = f.properties
|
|
147
|
+
if (p.co === 'T') return []
|
|
148
|
+
if (zf < 400)
|
|
149
|
+
return p.lvl == 3
|
|
150
|
+
? [2 * zf, 2 * zf]
|
|
151
|
+
: p.lvl == 2
|
|
152
|
+
? [5 * zf, 2 * zf]
|
|
153
|
+
: p.lvl == 1
|
|
154
|
+
? [5 * zf, 2 * zf]
|
|
155
|
+
: [10 * zf, 3 * zf]
|
|
156
|
+
else if (zf < 1000)
|
|
157
|
+
return p.lvl == 2 ? [5 * zf, 2 * zf] : p.lvl == 1 ? [5 * zf, 2 * zf] : [10 * zf, 3 * zf]
|
|
158
|
+
else if (zf < 2000) return p.lvl == 1 ? [5 * zf, 2 * zf] : [10 * zf, 3 * zf]
|
|
159
|
+
else return [10 * zf, 3 * zf]
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
opts.baseURL = opts.baseURL || 'https://raw.githubusercontent.com/eurostat/Nuts2json/master/pub/v2/'
|
|
163
|
+
opts.url = opts.baseURL + nutsYear + '/' + crs + '/' + scale + '/nutsbn_' + nutsLevel + '.json'
|
|
164
|
+
return opts
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export const getParameterByName = GeoCanvas.getParameterByName
|
|
168
|
+
|
|
169
|
+
// set default d3 locale
|
|
170
|
+
import { formatDefaultLocale } from 'd3-format'
|
|
171
|
+
formatDefaultLocale({
|
|
172
|
+
decimal: '.',
|
|
173
|
+
thousands: ' ',
|
|
174
|
+
grouping: [3],
|
|
175
|
+
currency: ['', '€'],
|
|
176
|
+
})
|
|
@@ -1,124 +1,124 @@
|
|
|
1
|
-
//@ts-check
|
|
2
|
-
'use strict'
|
|
3
|
-
|
|
4
|
-
import { Legend } from '../Legend.js'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* A legend element for color categrories.
|
|
8
|
-
*
|
|
9
|
-
* @author Joseph Davies, Julien Gaffuri
|
|
10
|
-
*/
|
|
11
|
-
export class ColorCategoryLegend extends Legend {
|
|
12
|
-
/** @param {Object} opts */
|
|
13
|
-
constructor(opts) {
|
|
14
|
-
super(opts)
|
|
15
|
-
opts = opts || {}
|
|
16
|
-
|
|
17
|
-
//col/categories array, in display order
|
|
18
|
-
/**
|
|
19
|
-
* @private
|
|
20
|
-
* @type {Array.<Array.<string>>} */
|
|
21
|
-
this.colCat = opts.colCat || [['gray', '-']]
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* @private
|
|
25
|
-
* @type {import("../Style").Shape} */
|
|
26
|
-
this.shape = opts.shape || 'circle'
|
|
27
|
-
this.dimension = opts.dimension || { r: 8 }
|
|
28
|
-
this.strokeColor = opts.strokeColor || 'gray'
|
|
29
|
-
this.strokeWidth = opts.strokeWidth || 1
|
|
30
|
-
|
|
31
|
-
this.title = opts.title
|
|
32
|
-
this.titleFontSize = opts.titleFontSize || '0.8em'
|
|
33
|
-
this.titleFontWeight = opts.titleFontWeight || 'bold'
|
|
34
|
-
|
|
35
|
-
//label
|
|
36
|
-
this.labelFontSize = opts.labelFontSize || '0.8em'
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* @param {{ style: import("../Style").Style, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
|
|
41
|
-
*/
|
|
42
|
-
update(opts) {
|
|
43
|
-
//clear
|
|
44
|
-
this.div.selectAll('*').remove()
|
|
45
|
-
|
|
46
|
-
//build
|
|
47
|
-
|
|
48
|
-
//title
|
|
49
|
-
if (this.title)
|
|
50
|
-
this.div
|
|
51
|
-
.append('div')
|
|
52
|
-
.style('font-size', this.titleFontSize)
|
|
53
|
-
.style('font-weight', this.titleFontWeight)
|
|
54
|
-
.style('margin-bottom', '7px')
|
|
55
|
-
.text(this.title)
|
|
56
|
-
|
|
57
|
-
//categories
|
|
58
|
-
const nb = this.colCat.length
|
|
59
|
-
if (nb == 0) return
|
|
60
|
-
|
|
61
|
-
for (let i = 0; i < nb; i++) {
|
|
62
|
-
const cat = this.colCat[i]
|
|
63
|
-
|
|
64
|
-
//make div for category
|
|
65
|
-
const d = this.div.append('div')
|
|
66
|
-
//to enable vertical centering
|
|
67
|
-
//.style("position", "relative")
|
|
68
|
-
|
|
69
|
-
const sw = this.strokeWidth
|
|
70
|
-
|
|
71
|
-
//draw graphic element: box / circle
|
|
72
|
-
if (this.shape === 'square') {
|
|
73
|
-
const h = this.dimension.h || 15
|
|
74
|
-
const w = this.dimension.w || 20
|
|
75
|
-
d.append('div')
|
|
76
|
-
.style('display', 'inline')
|
|
77
|
-
|
|
78
|
-
.append('svg')
|
|
79
|
-
.attr('width', w + 2 * sw)
|
|
80
|
-
.attr('height', h + 2 * sw)
|
|
81
|
-
|
|
82
|
-
.append('rect')
|
|
83
|
-
.attr('x', sw)
|
|
84
|
-
.attr('y', sw)
|
|
85
|
-
.attr('width', w)
|
|
86
|
-
.attr('height', h)
|
|
87
|
-
.style('fill', cat[0])
|
|
88
|
-
.style('stroke', this.strokeColor)
|
|
89
|
-
.style('stroke-width', this.strokeWidth)
|
|
90
|
-
} else if (this.shape === 'circle') {
|
|
91
|
-
const r = this.dimension.r || 8
|
|
92
|
-
const h = 2 * r + 2 * sw
|
|
93
|
-
d.append('div')
|
|
94
|
-
.style('display', 'inline')
|
|
95
|
-
|
|
96
|
-
.append('svg')
|
|
97
|
-
.attr('width', h)
|
|
98
|
-
.attr('height', h)
|
|
99
|
-
|
|
100
|
-
.append('circle')
|
|
101
|
-
.attr('cx', r + sw)
|
|
102
|
-
.attr('cy', r + sw)
|
|
103
|
-
.attr('r', r)
|
|
104
|
-
.style('fill', cat[0])
|
|
105
|
-
.style('stroke', this.strokeColor)
|
|
106
|
-
.style('stroke-width', this.strokeWidth)
|
|
107
|
-
} else {
|
|
108
|
-
throw new Error('Unexpected shape:' + this.shape)
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//write label text
|
|
112
|
-
d.append('div')
|
|
113
|
-
//show on right of graphic
|
|
114
|
-
.style('display', 'inline')
|
|
115
|
-
|
|
116
|
-
//center vertically
|
|
117
|
-
//.style("position", "absolute").style("top", "0").style("bottom", "0")
|
|
118
|
-
|
|
119
|
-
.style('padding-left', '5px')
|
|
120
|
-
.style('font-size', this.labelFontSize)
|
|
121
|
-
.text(cat[1])
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|
|
1
|
+
//@ts-check
|
|
2
|
+
'use strict'
|
|
3
|
+
|
|
4
|
+
import { Legend } from '../Legend.js'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A legend element for color categrories.
|
|
8
|
+
*
|
|
9
|
+
* @author Joseph Davies, Julien Gaffuri
|
|
10
|
+
*/
|
|
11
|
+
export class ColorCategoryLegend extends Legend {
|
|
12
|
+
/** @param {Object} opts */
|
|
13
|
+
constructor(opts) {
|
|
14
|
+
super(opts)
|
|
15
|
+
opts = opts || {}
|
|
16
|
+
|
|
17
|
+
//col/categories array, in display order
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
* @type {Array.<Array.<string>>} */
|
|
21
|
+
this.colCat = opts.colCat || [['gray', '-']]
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* @private
|
|
25
|
+
* @type {import("../Style").Shape} */
|
|
26
|
+
this.shape = opts.shape || 'circle'
|
|
27
|
+
this.dimension = opts.dimension || { r: 8 }
|
|
28
|
+
this.strokeColor = opts.strokeColor || 'gray'
|
|
29
|
+
this.strokeWidth = opts.strokeWidth || 1
|
|
30
|
+
|
|
31
|
+
this.title = opts.title
|
|
32
|
+
this.titleFontSize = opts.titleFontSize || '0.8em'
|
|
33
|
+
this.titleFontWeight = opts.titleFontWeight || 'bold'
|
|
34
|
+
|
|
35
|
+
//label
|
|
36
|
+
this.labelFontSize = opts.labelFontSize || '0.8em'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @param {{ style: import("../Style").Style, r: number, zf: number, sSize: import("../Style").Stat, sColor: import("../Style").Stat }} opts
|
|
41
|
+
*/
|
|
42
|
+
update(opts) {
|
|
43
|
+
//clear
|
|
44
|
+
this.div.selectAll('*').remove()
|
|
45
|
+
|
|
46
|
+
//build
|
|
47
|
+
|
|
48
|
+
//title
|
|
49
|
+
if (this.title)
|
|
50
|
+
this.div
|
|
51
|
+
.append('div')
|
|
52
|
+
.style('font-size', this.titleFontSize)
|
|
53
|
+
.style('font-weight', this.titleFontWeight)
|
|
54
|
+
.style('margin-bottom', '7px')
|
|
55
|
+
.text(this.title)
|
|
56
|
+
|
|
57
|
+
//categories
|
|
58
|
+
const nb = this.colCat.length
|
|
59
|
+
if (nb == 0) return
|
|
60
|
+
|
|
61
|
+
for (let i = 0; i < nb; i++) {
|
|
62
|
+
const cat = this.colCat[i]
|
|
63
|
+
|
|
64
|
+
//make div for category
|
|
65
|
+
const d = this.div.append('div')
|
|
66
|
+
//to enable vertical centering
|
|
67
|
+
//.style("position", "relative")
|
|
68
|
+
|
|
69
|
+
const sw = this.strokeWidth
|
|
70
|
+
|
|
71
|
+
//draw graphic element: box / circle
|
|
72
|
+
if (this.shape === 'square') {
|
|
73
|
+
const h = this.dimension.h || 15
|
|
74
|
+
const w = this.dimension.w || 20
|
|
75
|
+
d.append('div')
|
|
76
|
+
.style('display', 'inline')
|
|
77
|
+
|
|
78
|
+
.append('svg')
|
|
79
|
+
.attr('width', w + 2 * sw)
|
|
80
|
+
.attr('height', h + 2 * sw)
|
|
81
|
+
|
|
82
|
+
.append('rect')
|
|
83
|
+
.attr('x', sw)
|
|
84
|
+
.attr('y', sw)
|
|
85
|
+
.attr('width', w)
|
|
86
|
+
.attr('height', h)
|
|
87
|
+
.style('fill', cat[0])
|
|
88
|
+
.style('stroke', this.strokeColor)
|
|
89
|
+
.style('stroke-width', this.strokeWidth)
|
|
90
|
+
} else if (this.shape === 'circle') {
|
|
91
|
+
const r = this.dimension.r || 8
|
|
92
|
+
const h = 2 * r + 2 * sw
|
|
93
|
+
d.append('div')
|
|
94
|
+
.style('display', 'inline')
|
|
95
|
+
|
|
96
|
+
.append('svg')
|
|
97
|
+
.attr('width', h)
|
|
98
|
+
.attr('height', h)
|
|
99
|
+
|
|
100
|
+
.append('circle')
|
|
101
|
+
.attr('cx', r + sw)
|
|
102
|
+
.attr('cy', r + sw)
|
|
103
|
+
.attr('r', r)
|
|
104
|
+
.style('fill', cat[0])
|
|
105
|
+
.style('stroke', this.strokeColor)
|
|
106
|
+
.style('stroke-width', this.strokeWidth)
|
|
107
|
+
} else {
|
|
108
|
+
throw new Error('Unexpected shape:' + this.shape)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
//write label text
|
|
112
|
+
d.append('div')
|
|
113
|
+
//show on right of graphic
|
|
114
|
+
.style('display', 'inline')
|
|
115
|
+
|
|
116
|
+
//center vertically
|
|
117
|
+
//.style("position", "absolute").style("top", "0").style("bottom", "0")
|
|
118
|
+
|
|
119
|
+
.style('padding-left', '5px')
|
|
120
|
+
.style('font-size', this.labelFontSize)
|
|
121
|
+
.text(cat[1])
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|