eurostat-map 4.4.4 → 4.5.0
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 +177 -148
- package/build/215.eurostatmap.min.js +1 -1
- package/build/eurostatmap.js +19934 -15872
- package/build/eurostatmap.min.js +2 -2
- package/build/eurostatmap.min.js.map +1 -1
- package/build/package.json +87 -87
- package/build/types/core/GridCartogramSettings.d.ts +33 -0
- package/build/types/core/MapConfig.d.ts +13 -2
- package/build/types/core/MapInstance.d.ts +80 -4
- package/build/types/core/encoding/EncodingConfig.d.ts +31 -0
- package/build/types/core/layer/Layer.d.ts +31 -0
- package/build/types/core/layer/LayerConfig.d.ts +19 -0
- package/build/types/core/layer/LayerRole.d.ts +1 -0
- package/build/types/core/locations.d.ts +44 -16
- package/build/types/core/stat/StatConfig.d.ts +7 -0
- package/build/types/index.d.ts +39 -33
- package/build/types/layers/CategoricalMap.d.ts +21 -0
- package/build/types/layers/CategoricalMapConfig.d.ts +11 -0
- package/build/types/layers/MapType.d.ts +34 -0
- package/build/types/layers/choropleth/BivariateChoroplethConfig.d.ts +27 -0
- package/build/types/layers/choropleth/BivariateChoroplethMap.d.ts +39 -0
- package/build/types/layers/choropleth/ChoroplethConfig.d.ts +39 -0
- package/build/types/layers/choropleth/ChoroplethMap.d.ts +48 -0
- package/build/types/layers/choropleth/TrivariateChoroplethConfig.d.ts +41 -0
- package/build/types/layers/choropleth/TrivariateChoroplethMap.d.ts +18 -0
- package/build/types/layers/choropleth/ValueByAlphaConfig.d.ts +8 -0
- package/build/types/layers/choropleth/ValueByAlphaMap.d.ts +9 -0
- package/build/types/layers/composition/CompositionStatConfig.d.ts +59 -0
- package/build/types/layers/composition/bar/BarMap.d.ts +97 -0
- package/build/types/layers/composition/bar/BarMapConfig.d.ts +76 -0
- package/build/types/layers/composition/coxcomb/CoxcombMap.d.ts +75 -0
- package/build/types/layers/composition/coxcomb/CoxcombMapConfig.d.ts +47 -0
- package/build/types/layers/composition/coxcomb/CoxcombStatConfig.d.ts +13 -0
- package/build/types/layers/composition/pie/PieMap.d.ts +84 -0
- package/build/types/layers/composition/pie/PieMapConfig.d.ts +50 -0
- package/build/types/layers/composition/stripe/StripeMap.d.ts +80 -0
- package/build/types/layers/composition/stripe/StripeMapConfig.d.ts +45 -0
- package/build/types/layers/composition/waffle/WaffleMap.d.ts +124 -0
- package/build/types/layers/composition/waffle/WaffleMapConfig.d.ts +58 -0
- package/build/types/layers/flow/FlowMap.d.ts +218 -0
- package/build/types/layers/flow/FlowMapConfig.d.ts +220 -0
- package/build/types/layers/proportional-symbol/ProportionalSymbolConfig.d.ts +47 -0
- package/build/types/layers/proportional-symbol/ProportionalSymbolMap.d.ts +94 -0
- package/build/types/layers/proportional-symbol/mushroom/MushroomMap.d.ts +67 -0
- package/build/types/layers/proportional-symbol/mushroom/MushroomMapConfig.d.ts +39 -0
- package/build/types/layers/spark/SparkMap.d.ts +56 -0
- package/build/types/layers/spark/SparkMapConfig.d.ts +75 -0
- package/build/types/layers/spark/SparkStatConfig.d.ts +33 -0
- package/build/types/legend/LegendConfig.d.ts +3 -0
- package/build/types/legend/choropleth/BivariateLegendConfig.d.ts +79 -0
- package/build/types/map-types/choropleth/TrivariateChoroplethConfig.d.ts +25 -16
- package/build/types/map-types/choropleth/TrivariateChoroplethMap.d.ts +5 -2
- package/build/types/map-types/composition/CompositionStatConfig.d.ts +7 -0
- package/build/types/map-types/composition/bar/BarMap.d.ts +97 -79
- package/build/types/map-types/composition/bar/BarMapConfig.d.ts +76 -54
- package/build/types/map-types/composition/coxcomb/CoxcombMap.d.ts +29 -0
- package/build/types/map-types/composition/coxcomb/CoxcombMapConfig.d.ts +15 -0
- package/build/types/map-types/composition/pie/PieMap.d.ts +5 -5
- package/build/types/map-types/composition/pie/PieMapConfig.d.ts +2 -0
- package/build/types/map-types/composition/stripe/StripeMap.d.ts +19 -2
- package/build/types/map-types/composition/stripe/StripeMapConfig.d.ts +11 -0
- package/build/types/map-types/composition/waffle/WaffleMap.d.ts +46 -0
- package/build/types/map-types/composition/waffle/WaffleMapConfig.d.ts +24 -10
- package/build/types/map-types/flow/FlowMap.d.ts +121 -0
- package/build/types/map-types/flow/FlowMapConfig.d.ts +62 -0
- package/build/types/map-types/proportional-symbol/ProportionalSymbolConfig.d.ts +30 -0
- package/build/types/map-types/proportional-symbol/ProportionalSymbolMap.d.ts +4 -0
- package/build/types/map-types/proportional-symbol/mushroom/MushroomMap.d.ts +37 -0
- package/build/types/map-types/proportional-symbol/mushroom/MushroomMapConfig.d.ts +19 -0
- package/build/types/map-types/spark/SparkMap.d.ts +4 -0
- package/build/types/map-types/spark/SparkMapConfig.d.ts +32 -0
- package/package.json +6 -3
package/build/package.json
CHANGED
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "eurostat-map",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "Reusable library to quickly create and customise web maps showing Eurostat data directly retrieved from Eurostat database.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"eurostat",
|
|
7
|
-
"statistics",
|
|
8
|
-
"europe",
|
|
9
|
-
"SVG",
|
|
10
|
-
"NUTS",
|
|
11
|
-
"map",
|
|
12
|
-
"D3",
|
|
13
|
-
"cartography",
|
|
14
|
-
"thematic",
|
|
15
|
-
"mapping",
|
|
16
|
-
"eurostat-map",
|
|
17
|
-
"dataviz",
|
|
18
|
-
"data visualization"
|
|
19
|
-
],
|
|
20
|
-
"homepage": "https://github.com/eurostat/eurostat-map",
|
|
21
|
-
"author": "",
|
|
22
|
-
"license": "EUPL-1.2",
|
|
23
|
-
"repository": {
|
|
24
|
-
"type": "git",
|
|
25
|
-
"url": "https://github.com/eurostat/eurostat-map.git"
|
|
26
|
-
},
|
|
27
|
-
"main": "build/eurostatmap.min.js",
|
|
28
|
-
"unpkg": "build/eurostatmap.min.js",
|
|
29
|
-
"module": "build/eurostatmap.js",
|
|
30
|
-
"types": "build/types/index.d.ts",
|
|
31
|
-
"typings": "build/types/index.d.ts",
|
|
32
|
-
"files": [
|
|
33
|
-
"build"
|
|
34
|
-
],
|
|
35
|
-
"scripts": {
|
|
36
|
-
"start": "webpack --config webpack/webpack.config.dev.js",
|
|
37
|
-
"server": "webpack-dev-server --open --watch",
|
|
38
|
-
"build-types": "tsc --project tsconfig.json",
|
|
39
|
-
"build-prod": "npm run build-types && webpack --config webpack/webpack.config.prod.js",
|
|
40
|
-
"build-prod-debug": "webpack --config webpack/webpack.config.debug-size.js",
|
|
41
|
-
"format": "prettier --write .",
|
|
42
|
-
"test": "jest",
|
|
43
|
-
"type-check": "tsc --noEmit"
|
|
44
|
-
},
|
|
45
|
-
"dependencies": {
|
|
46
|
-
"d3-array": "^3.2.4",
|
|
47
|
-
"d3-axis": "^3.0.0",
|
|
48
|
-
"d3-ease": "^3.0.1",
|
|
49
|
-
"d3-fetch": "^3.0.1",
|
|
50
|
-
"d3-force": "^3.0.0",
|
|
51
|
-
"d3-format": "^3.1.0",
|
|
52
|
-
"d3-geo": "^3.1.1",
|
|
53
|
-
"d3-geo-projection": "^3.0.0",
|
|
54
|
-
"d3-interpolate": "^3.0.1",
|
|
55
|
-
"d3-scale": "^4.0.2",
|
|
56
|
-
"d3-scale-chromatic": "^3.1.0",
|
|
57
|
-
"d3-selection": "^3.0.0",
|
|
58
|
-
"d3-shape": "^3.2.0",
|
|
59
|
-
"d3-svg-annotation": "^2.5.1",
|
|
60
|
-
"d3-zoom": "^3.0.0",
|
|
61
|
-
"idb-keyval": "^6.2.2",
|
|
62
|
-
"jsonstat-toolkit": "^1.0.8",
|
|
63
|
-
"proj4": "^2.17.0",
|
|
64
|
-
"simple-statistics": "^7.8.8",
|
|
65
|
-
"topojson-client": "^3.1.0"
|
|
66
|
-
},
|
|
67
|
-
"overrides": {
|
|
68
|
-
"d3-color": "3.1.0"
|
|
69
|
-
},
|
|
70
|
-
"devDependencies": {
|
|
71
|
-
"@babel/core": "^7.22.6",
|
|
72
|
-
"@babel/plugin-transform-runtime": "^7.22.6",
|
|
73
|
-
"@babel/preset-env": "^7.22.6",
|
|
74
|
-
"@babel/runtime": "^7.12.1",
|
|
75
|
-
"babel-loader": "^9.1.2",
|
|
76
|
-
"css-loader": "^7.1.2",
|
|
77
|
-
"prettier": "^3.4.1",
|
|
78
|
-
"style-loader": "^4.0.0",
|
|
79
|
-
"ts-loader": "^9.5.4",
|
|
80
|
-
"typescript": "^5.9.3",
|
|
81
|
-
"webpack": "^5.88.1",
|
|
82
|
-
"webpack-bundle-analyzer": "^4.10.2",
|
|
83
|
-
"webpack-cli": "^5.0.0",
|
|
84
|
-
"webpack-dev-server": "^5.2.2",
|
|
85
|
-
"webpack-livereload-plugin": "^3.0.2"
|
|
86
|
-
}
|
|
87
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "eurostat-map",
|
|
3
|
+
"version": "4.5.0",
|
|
4
|
+
"description": "Reusable library to quickly create and customise web maps showing Eurostat data directly retrieved from Eurostat database.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"eurostat",
|
|
7
|
+
"statistics",
|
|
8
|
+
"europe",
|
|
9
|
+
"SVG",
|
|
10
|
+
"NUTS",
|
|
11
|
+
"map",
|
|
12
|
+
"D3",
|
|
13
|
+
"cartography",
|
|
14
|
+
"thematic",
|
|
15
|
+
"mapping",
|
|
16
|
+
"eurostat-map",
|
|
17
|
+
"dataviz",
|
|
18
|
+
"data visualization"
|
|
19
|
+
],
|
|
20
|
+
"homepage": "https://github.com/eurostat/eurostat-map",
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "EUPL-1.2",
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/eurostat/eurostat-map.git"
|
|
26
|
+
},
|
|
27
|
+
"main": "build/eurostatmap.min.js",
|
|
28
|
+
"unpkg": "build/eurostatmap.min.js",
|
|
29
|
+
"module": "build/eurostatmap.js",
|
|
30
|
+
"types": "build/types/index.d.ts",
|
|
31
|
+
"typings": "build/types/index.d.ts",
|
|
32
|
+
"files": [
|
|
33
|
+
"build"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"start": "webpack --config webpack/webpack.config.dev.js",
|
|
37
|
+
"server": "webpack-dev-server --open --watch",
|
|
38
|
+
"build-types": "tsc --project tsconfig.json",
|
|
39
|
+
"build-prod": "npm run build-types && webpack --config webpack/webpack.config.prod.js",
|
|
40
|
+
"build-prod-debug": "webpack --config webpack/webpack.config.debug-size.js",
|
|
41
|
+
"format": "prettier --write .",
|
|
42
|
+
"test": "jest",
|
|
43
|
+
"type-check": "tsc --noEmit"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"d3-array": "^3.2.4",
|
|
47
|
+
"d3-axis": "^3.0.0",
|
|
48
|
+
"d3-ease": "^3.0.1",
|
|
49
|
+
"d3-fetch": "^3.0.1",
|
|
50
|
+
"d3-force": "^3.0.0",
|
|
51
|
+
"d3-format": "^3.1.0",
|
|
52
|
+
"d3-geo": "^3.1.1",
|
|
53
|
+
"d3-geo-projection": "^3.0.0",
|
|
54
|
+
"d3-interpolate": "^3.0.1",
|
|
55
|
+
"d3-scale": "^4.0.2",
|
|
56
|
+
"d3-scale-chromatic": "^3.1.0",
|
|
57
|
+
"d3-selection": "^3.0.0",
|
|
58
|
+
"d3-shape": "^3.2.0",
|
|
59
|
+
"d3-svg-annotation": "^2.5.1",
|
|
60
|
+
"d3-zoom": "^3.0.0",
|
|
61
|
+
"idb-keyval": "^6.2.2",
|
|
62
|
+
"jsonstat-toolkit": "^1.0.8",
|
|
63
|
+
"proj4": "^2.17.0",
|
|
64
|
+
"simple-statistics": "^7.8.8",
|
|
65
|
+
"topojson-client": "^3.1.0"
|
|
66
|
+
},
|
|
67
|
+
"overrides": {
|
|
68
|
+
"d3-color": "3.1.0"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@babel/core": "^7.22.6",
|
|
72
|
+
"@babel/plugin-transform-runtime": "^7.22.6",
|
|
73
|
+
"@babel/preset-env": "^7.22.6",
|
|
74
|
+
"@babel/runtime": "^7.12.1",
|
|
75
|
+
"babel-loader": "^9.1.2",
|
|
76
|
+
"css-loader": "^7.1.2",
|
|
77
|
+
"prettier": "^3.4.1",
|
|
78
|
+
"style-loader": "^4.0.0",
|
|
79
|
+
"ts-loader": "^9.5.4",
|
|
80
|
+
"typescript": "^5.9.3",
|
|
81
|
+
"webpack": "^5.88.1",
|
|
82
|
+
"webpack-bundle-analyzer": "^4.10.2",
|
|
83
|
+
"webpack-cli": "^5.0.0",
|
|
84
|
+
"webpack-dev-server": "^5.2.2",
|
|
85
|
+
"webpack-livereload-plugin": "^3.0.2"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -12,6 +12,14 @@ export interface GridCartogramMargins {
|
|
|
12
12
|
left: number
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/** Shared chart offset for symbols drawn inside each grid cell. */
|
|
16
|
+
export interface GridCartogramChartOffset {
|
|
17
|
+
/** Horizontal offset in pixels. Positive moves right. */
|
|
18
|
+
x: number
|
|
19
|
+
/** Vertical offset in pixels. Positive moves down. */
|
|
20
|
+
y: number
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
/**
|
|
16
24
|
* Settings for grid cartogram layout and geometry.
|
|
17
25
|
*/
|
|
@@ -22,6 +30,31 @@ export interface GridCartogramSettings {
|
|
|
22
30
|
margins: GridCartogramMargins
|
|
23
31
|
/** Extra spacing between grid cells in pixels. */
|
|
24
32
|
cellPadding: number
|
|
33
|
+
/** Country-label rendering settings for grid cartograms. */
|
|
34
|
+
countryLabelSettings?: {
|
|
35
|
+
/** Show country labels as codes, names, or a custom string. */
|
|
36
|
+
countryLabels?: 'code' | 'name' | ((id: string, name: string | undefined, region?: any) => string)
|
|
37
|
+
/** Base font size for country labels in grid cartograms. */
|
|
38
|
+
countryLabelFontSize?: number
|
|
39
|
+
/** Minimum font size allowed when shrinking labels to avoid overlap. */
|
|
40
|
+
countryLabelMinFontSize?: number
|
|
41
|
+
/** Extra padding subtracted from the available label width before fitting. */
|
|
42
|
+
countryLabelPadding?: { x: number; y: number }
|
|
43
|
+
/** Disable automatic label shrinking/stretching to avoid overlap. @default false */
|
|
44
|
+
countryLabelAvoidOverlap?: boolean
|
|
45
|
+
}
|
|
46
|
+
/** @deprecated Use countryLabelSettings.countryLabels instead. */
|
|
47
|
+
countryLabels?: 'code' | 'name' | ((id: string, name: string | undefined, region?: any) => string)
|
|
48
|
+
/** @deprecated Use countryLabelSettings.countryLabelFontSize instead. */
|
|
49
|
+
countryLabelFontSize?: number
|
|
50
|
+
/** @deprecated Use countryLabelSettings.countryLabelMinFontSize instead. */
|
|
51
|
+
countryLabelMinFontSize?: number
|
|
52
|
+
/** @deprecated Use countryLabelSettings.countryLabelPadding instead. */
|
|
53
|
+
countryLabelPadding?: { x: number; y: number }
|
|
54
|
+
/** @deprecated Use countryLabelSettings.countryLabelAvoidOverlap instead. */
|
|
55
|
+
countryLabelAvoidOverlap?: boolean
|
|
56
|
+
/** Shared chart offset in grid cells for chart-based map types. */
|
|
57
|
+
chartOffset: GridCartogramChartOffset
|
|
25
58
|
/**
|
|
26
59
|
* Custom grid layout CSV string.
|
|
27
60
|
* If undefined, the built-in layout for the selected shape is used.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { StatConfig } from './stat/StatConfig'
|
|
2
|
+
import type { CompositionStatConfig } from '../layers/composition/CompositionStatConfig'
|
|
2
3
|
import type { LegendConfig } from '../legend/LegendConfig'
|
|
3
4
|
import type { TooltipConfig } from './TooltipConfig'
|
|
4
5
|
import type { InsetConfig } from './InsetConfig'
|
|
@@ -7,6 +8,7 @@ import type { CoastalMarginSettings } from './decoration/CoastalMarginSettings'
|
|
|
7
8
|
import type { GridCartogramSettings } from './GridCartogramSettings'
|
|
8
9
|
import type { DorlingSettings } from './DorlingSettings'
|
|
9
10
|
import type { ScalebarConfig } from './decoration/ScalebarConfig'
|
|
11
|
+
import type { EncodingConfig } from './encoding/EncodingConfig'
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Base configuration for all map types. Each specific map type will extend this with its own properties, but these are the common ones that apply to all maps.
|
|
@@ -56,8 +58,17 @@ export interface MapConfig {
|
|
|
56
58
|
/** Data source text. */
|
|
57
59
|
source?: string
|
|
58
60
|
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Statistical data configuration.
|
|
63
|
+
*
|
|
64
|
+
* Preferred for multi-dataset maps:
|
|
65
|
+
* - set named datasets via `stat` dictionary
|
|
66
|
+
* - bind channels via `encoding`
|
|
67
|
+
*/
|
|
68
|
+
stat?: StatConfig | CompositionStatConfig | Record<string, StatConfig | CompositionStatConfig>
|
|
69
|
+
|
|
70
|
+
/** Optional visual encoding configuration by channel (size, color, fill, composition, etc.). */
|
|
71
|
+
encoding?: Record<string, EncodingConfig>
|
|
61
72
|
|
|
62
73
|
/** Legend configuration. */
|
|
63
74
|
legend?: LegendConfig | false
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { StatConfig } from './stat/StatConfig'
|
|
2
2
|
import type { StatData } from './stat/StatData'
|
|
3
|
+
import type { Layer } from './layer/Layer'
|
|
4
|
+
import type { LayerConfig } from './layer/LayerConfig'
|
|
5
|
+
import type { CompositionStatConfig } from '../layers/composition/CompositionStatConfig'
|
|
3
6
|
import type { LegendConfig } from '../legend/LegendConfig'
|
|
4
7
|
import type { TooltipConfig } from './TooltipConfig'
|
|
5
8
|
import type { InsetConfig } from './InsetConfig'
|
|
@@ -7,6 +10,8 @@ import type { CoastalMarginSettings } from './decoration/CoastalMarginSettings'
|
|
|
7
10
|
import type { GridCartogramSettings } from './GridCartogramSettings'
|
|
8
11
|
import type { DorlingSettings } from './DorlingSettings'
|
|
9
12
|
import type { ScalebarConfig } from './decoration/ScalebarConfig'
|
|
13
|
+
import type { EncodingConfig } from './encoding/EncodingConfig'
|
|
14
|
+
import type { LocationConfig } from './locations'
|
|
10
15
|
|
|
11
16
|
/**
|
|
12
17
|
* A eurostat-map instance. Created by eurostatmap.map() and extended
|
|
@@ -117,10 +122,50 @@ export interface MapInstance {
|
|
|
117
122
|
* - `map.stat('v1', config)` → sets the stat config for key 'v1'
|
|
118
123
|
* @example map.stat({ eurostatDatasetCode: 'demo_r_d3dens', filters: { TIME: '2024' } })
|
|
119
124
|
*/
|
|
120
|
-
stat(): StatConfig
|
|
121
|
-
stat(config: StatConfig): this
|
|
122
|
-
stat(key: string): StatConfig
|
|
123
|
-
stat(key: string, config: StatConfig): this
|
|
125
|
+
stat(): StatConfig | CompositionStatConfig | undefined
|
|
126
|
+
stat(config: StatConfig | CompositionStatConfig): this
|
|
127
|
+
stat(key: string): StatConfig | CompositionStatConfig | undefined
|
|
128
|
+
stat(key: string, config: StatConfig | CompositionStatConfig): this
|
|
129
|
+
/**
|
|
130
|
+
* Legacy compatibility overload for composition channels.
|
|
131
|
+
* Preferred: pass category fields directly inside config.
|
|
132
|
+
*/
|
|
133
|
+
stat(
|
|
134
|
+
key: string,
|
|
135
|
+
config: StatConfig | CompositionStatConfig,
|
|
136
|
+
categoryParameter: string,
|
|
137
|
+
categoryCodes?: string[],
|
|
138
|
+
categoryLabels?: string[],
|
|
139
|
+
categoryColors?: string[],
|
|
140
|
+
totalCode?: string
|
|
141
|
+
): this
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Get or set visual encodings that map named stats to visual variables.
|
|
145
|
+
* @example map.encoding('size', { stat: 'population', scale: 'sqrt', range: [4, 30] })
|
|
146
|
+
*/
|
|
147
|
+
encoding(): Record<string, EncodingConfig>
|
|
148
|
+
encoding(channel: string): EncodingConfig | undefined
|
|
149
|
+
encoding(channel: string, config: EncodingConfig): this
|
|
150
|
+
encoding(configs: Record<string, EncodingConfig>): this
|
|
151
|
+
|
|
152
|
+
/** Returns the stat name for an encoding channel, or fallback when unset. */
|
|
153
|
+
getEncodingStat(channel: string, fallback?: string): string | undefined
|
|
154
|
+
|
|
155
|
+
/** Returns stat names for an encoding channel (`stats` or single `stat`). */
|
|
156
|
+
getEncodingStats(channel: string, fallback?: string[]): string[] | undefined
|
|
157
|
+
|
|
158
|
+
/** Returns the concrete statData key for a channel/category combination. */
|
|
159
|
+
getEncodingStatKey(channel: string, categoryCode?: string, fallbackStat?: string): string | undefined
|
|
160
|
+
|
|
161
|
+
/** Returns the StatData source bound to a channel/category. */
|
|
162
|
+
getEncodingStatData(channel: string, categoryCode?: string, fallbackStat?: string): StatData | undefined
|
|
163
|
+
|
|
164
|
+
/** Returns a region value through encoding lookup. */
|
|
165
|
+
getEncodingValue(channel: string, regionId: string, categoryCode?: string, fallbackStat?: string): number | string | undefined
|
|
166
|
+
|
|
167
|
+
/** Returns unit text through encoding lookup. */
|
|
168
|
+
getEncodingUnitText(channel: string, categoryCode?: string, fallbackStat?: string): string
|
|
124
169
|
|
|
125
170
|
/**
|
|
126
171
|
* Get or set the StatData instance for a given key.
|
|
@@ -246,6 +291,22 @@ export interface MapInstance {
|
|
|
246
291
|
svg(): any
|
|
247
292
|
svg(s: any): this
|
|
248
293
|
|
|
294
|
+
/** Add or replace a custom point location marker. */
|
|
295
|
+
addLocation(config: LocationConfig): this
|
|
296
|
+
|
|
297
|
+
/** Remove a custom point location marker by id. */
|
|
298
|
+
removeLocation(id: string): this
|
|
299
|
+
|
|
300
|
+
/** Remove all custom point location markers. */
|
|
301
|
+
clearLocations(): this
|
|
302
|
+
|
|
303
|
+
/** Get or replace all custom point location markers. */
|
|
304
|
+
locations(): LocationConfig[]
|
|
305
|
+
locations(configs: LocationConfig[] | null | undefined): this
|
|
306
|
+
|
|
307
|
+
/** Redraw custom point location markers. */
|
|
308
|
+
updateLocations(): this
|
|
309
|
+
|
|
249
310
|
/** Custom geometry filtering function. */
|
|
250
311
|
filterGeometriesFunction(): ((geometry: any) => boolean) | undefined
|
|
251
312
|
filterGeometriesFunction(fn: (geometry: any) => boolean): this
|
|
@@ -445,6 +506,21 @@ export interface MapInstance {
|
|
|
445
506
|
/** Returns region centroids as an array of projected coordinate pairs. */
|
|
446
507
|
regionCentroids(): Array<{ id: string; x: number; y: number }>
|
|
447
508
|
|
|
509
|
+
/** Ordered thematic layer stack (bottom → top). */
|
|
510
|
+
layers_: Layer[]
|
|
511
|
+
activeLayerIndex_: number
|
|
512
|
+
|
|
513
|
+
activeLayer(): Layer
|
|
514
|
+
layer(ref?: number | string): Layer | undefined
|
|
515
|
+
layers(): Layer[]
|
|
516
|
+
layers(configs: LayerConfig[]): this
|
|
517
|
+
addLayer(type: string, config?: LayerConfig): Layer
|
|
518
|
+
addLayer(config: LayerConfig): Layer
|
|
519
|
+
removeLayer(ref: number | string): this
|
|
520
|
+
activeLayerIndex(): number
|
|
521
|
+
activeLayerIndex(i: number): this
|
|
522
|
+
updateAllLayers(): this
|
|
523
|
+
|
|
448
524
|
/** Allow additional map-type-specific properties and methods. */
|
|
449
525
|
[key: string]: any
|
|
450
526
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for mapping a named stat dataset to a visual channel.
|
|
3
|
+
*/
|
|
4
|
+
export interface EncodingConfig {
|
|
5
|
+
/** Name of a dataset registered with map.stat(name, config). */
|
|
6
|
+
stat?: string
|
|
7
|
+
/** Names of datasets for multi-stat encodings such as bivariate color. */
|
|
8
|
+
stats?: string[]
|
|
9
|
+
/** Whether the encoding is based on raw values or category codes. */
|
|
10
|
+
by?: 'value' | 'category'
|
|
11
|
+
/** Encoding type. */
|
|
12
|
+
type?: 'linear' | 'sqrt' | 'threshold' | 'quantile' | 'categorical' | 'bivariate' | 'trivariate'
|
|
13
|
+
/** Scale type. */
|
|
14
|
+
scale?: 'linear' | 'sqrt' | 'quantile' | 'threshold'
|
|
15
|
+
/** Numeric or color output range. */
|
|
16
|
+
range?: [number, number] | string[]
|
|
17
|
+
/** Explicit encoded values, for example category colors. */
|
|
18
|
+
values?: Record<string, string | number> | Array<string | number>
|
|
19
|
+
/** Labels keyed by category code or value. */
|
|
20
|
+
labels?: Record<string, string> | string[]
|
|
21
|
+
/** Category codes when using array-based values or labels. */
|
|
22
|
+
categoryCodes?: string[]
|
|
23
|
+
/** Number of classes for classified encodings. */
|
|
24
|
+
classes?: number
|
|
25
|
+
/** Threshold values for threshold encodings. */
|
|
26
|
+
thresholds?: number[]
|
|
27
|
+
/** Color scheme name or function. */
|
|
28
|
+
scheme?: string | Function
|
|
29
|
+
/** Optional unit override for this encoding. */
|
|
30
|
+
unitText?: string
|
|
31
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { MapInstance } from '../MapInstance'
|
|
2
|
+
import type { EncodingConfig } from '../encoding/EncodingConfig'
|
|
3
|
+
import type { StatData } from '../stat/StatData'
|
|
4
|
+
import type { LayerRole } from './LayerRole'
|
|
5
|
+
|
|
6
|
+
export interface Layer {
|
|
7
|
+
map: MapInstance
|
|
8
|
+
isLayer: true
|
|
9
|
+
id: string
|
|
10
|
+
type: string
|
|
11
|
+
role: LayerRole
|
|
12
|
+
|
|
13
|
+
encodings_: Record<string, EncodingConfig>
|
|
14
|
+
|
|
15
|
+
encoding(): Record<string, EncodingConfig>
|
|
16
|
+
encoding(channel: string): EncodingConfig | undefined
|
|
17
|
+
encoding(channel: string, config: EncodingConfig): Layer
|
|
18
|
+
encoding(map: Record<string, EncodingConfig>): Layer
|
|
19
|
+
|
|
20
|
+
getEncodingStat(channel: string, fallback?: string): string | undefined
|
|
21
|
+
getEncodingStats(channel: string, fallback?: string[]): string[] | undefined
|
|
22
|
+
getEncodingStatKey(channel: string, categoryCode?: string, fallbackStat?: string): string
|
|
23
|
+
getEncodingStatData(channel: string, categoryCode?: string, fallbackStat?: string): StatData
|
|
24
|
+
getEncodingValue(channel: string, regionId: string, categoryCode?: string, fallbackStat?: string): number | string | undefined
|
|
25
|
+
getEncodingUnitText(channel: string, categoryCode?: string, fallbackStat?: string): string
|
|
26
|
+
|
|
27
|
+
updateClassification(): Layer
|
|
28
|
+
updateStyle(): Layer
|
|
29
|
+
getLegendConstructor(): (map: MapInstance, config?: any) => any
|
|
30
|
+
group(): any // d3 selection
|
|
31
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { MapType } from '../../layers/MapType'
|
|
2
|
+
import type { EncodingConfig } from '../encoding/EncodingConfig'
|
|
3
|
+
import type { LegendConfig } from '../../legend/LegendConfig'
|
|
4
|
+
import type { LayerRole } from './LayerRole'
|
|
5
|
+
|
|
6
|
+
export interface LayerConfig {
|
|
7
|
+
/** Stable id; auto-generated if omitted. */
|
|
8
|
+
id?: string
|
|
9
|
+
/** Layer type (same identifiers as map types). */
|
|
10
|
+
type: MapType
|
|
11
|
+
/** Explicit role; defaults from the type. */
|
|
12
|
+
role?: LayerRole
|
|
13
|
+
/** Keyed visual encodings: fill, size, color, stroke, … */
|
|
14
|
+
encoding?: Record<string, EncodingConfig>
|
|
15
|
+
/** Per-layer legend config. */
|
|
16
|
+
legend?: LegendConfig
|
|
17
|
+
/** Type-specific settings are also accepted. */
|
|
18
|
+
[key: string]: any
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type LayerRole = 'base' | 'overlay'
|
|
@@ -6,11 +6,37 @@ import type { MapInstance } from './MapInstance'
|
|
|
6
6
|
export const LOCATION_SHAPES: {
|
|
7
7
|
CIRCLE: 'circle'
|
|
8
8
|
SQUARE: 'square'
|
|
9
|
+
PIN: 'pin'
|
|
9
10
|
DIAMOND: 'diamond'
|
|
10
|
-
TRIANGLE: 'triangle'
|
|
11
11
|
STAR: 'star'
|
|
12
12
|
CROSS: 'cross'
|
|
13
|
-
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Available location marker shapes
|
|
17
|
+
*/
|
|
18
|
+
export type LocationShape = 'circle' | 'square' | 'pin' | 'diamond' | 'cross' | 'star'
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Text label style for a location marker
|
|
22
|
+
*/
|
|
23
|
+
export interface LocationLabelStyle {
|
|
24
|
+
/** CSS font size. @default '12px' */
|
|
25
|
+
fontSize?: string
|
|
26
|
+
/** CSS font family. @default 'inherit' */
|
|
27
|
+
fontFamily?: string
|
|
28
|
+
/** CSS font weight. @default 'normal' */
|
|
29
|
+
fontWeight?: string | number
|
|
30
|
+
/** Text fill color. @default '#222' */
|
|
31
|
+
fill?: string
|
|
32
|
+
/** Text opacity. @default 1 */
|
|
33
|
+
opacity?: number
|
|
34
|
+
/** Label halo color. @default '#fff' */
|
|
35
|
+
haloColor?: string
|
|
36
|
+
/** Label halo width in pixels. @default 3 */
|
|
37
|
+
haloWidth?: number
|
|
38
|
+
/** SVG text-anchor value. @default 'start' */
|
|
39
|
+
textAnchor?: 'start' | 'middle' | 'end'
|
|
14
40
|
}
|
|
15
41
|
|
|
16
42
|
/**
|
|
@@ -19,26 +45,28 @@ export const LOCATION_SHAPES: {
|
|
|
19
45
|
export interface LocationConfig {
|
|
20
46
|
/** Unique identifier for the location */
|
|
21
47
|
id?: string
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
|
|
48
|
+
/** Geographic X coordinate (longitude / easting) */
|
|
49
|
+
x: number
|
|
50
|
+
/** Geographic Y coordinate (latitude / northing) */
|
|
51
|
+
y: number
|
|
26
52
|
/** Label text to display */
|
|
27
53
|
label?: string
|
|
28
54
|
/** Marker shape. @default 'circle' */
|
|
29
|
-
shape?:
|
|
30
|
-
/** Marker
|
|
31
|
-
|
|
32
|
-
/** Fill color. @default '#
|
|
33
|
-
|
|
55
|
+
shape?: LocationShape
|
|
56
|
+
/** Marker radius in pixels. @default 6 */
|
|
57
|
+
radius?: number
|
|
58
|
+
/** Fill color. @default '#e84040' */
|
|
59
|
+
fill?: string
|
|
60
|
+
/** Fill opacity. @default 1 */
|
|
61
|
+
opacity?: number
|
|
34
62
|
/** Stroke color. @default '#fff' */
|
|
35
63
|
stroke?: string
|
|
36
|
-
/** Stroke width in pixels. @default 1 */
|
|
64
|
+
/** Stroke width in pixels. @default 1.5 */
|
|
37
65
|
strokeWidth?: number
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
|
|
66
|
+
/** Label offset from projected point in pixels. @default [7, -6] */
|
|
67
|
+
labelOffset?: [number, number]
|
|
68
|
+
/** Label text style overrides */
|
|
69
|
+
labelStyle?: LocationLabelStyle
|
|
42
70
|
}
|
|
43
71
|
|
|
44
72
|
/**
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for a statistical data source.
|
|
3
3
|
* Pass this to map.stat() or as the config argument to statData().
|
|
4
|
+
*
|
|
5
|
+
* Preferred for multi-channel maps: register named datasets with
|
|
6
|
+
* `map.stat('datasetName', config)` and map them with `map.encoding(...)`.
|
|
4
7
|
*/
|
|
5
8
|
export interface StatConfig {
|
|
9
|
+
/** Custom data keyed by region ID. Use instead of a remote data source. */
|
|
10
|
+
customData?: Record<string, number | string | { value: number | string; status?: string }>
|
|
6
11
|
/** Eurostat dataset code. e.g. 'demo_r_d3dens' */
|
|
7
12
|
eurostatDatasetCode?: string
|
|
8
13
|
/**
|
|
@@ -20,6 +25,8 @@ export interface StatConfig {
|
|
|
20
25
|
valueCol?: string
|
|
21
26
|
/** Unit of measure label shown in tooltips. e.g. 'people/km²' */
|
|
22
27
|
unitText?: string
|
|
28
|
+
/** Optional preprocessing hook called with (regionId, value) before transform. Return null/undefined/false to filter out the region. */
|
|
29
|
+
preprocess?: (regionId: string, value: any) => any
|
|
23
30
|
/** Optional transform function applied to raw values after data loads. e.g. v => v * 1000 */
|
|
24
31
|
transform?: (value: number) => number
|
|
25
32
|
/** Dataset label/name from the Eurostat API response. */
|