eurostat-map 4.7.1 → 4.8.1

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eurostat-map",
3
- "version": "4.7.1",
3
+ "version": "4.8.1",
4
4
  "description": "Reusable library to quickly create and customise web maps showing Eurostat data directly retrieved from Eurostat database.",
5
5
  "keywords": [
6
6
  "eurostat",
@@ -12,6 +12,7 @@ import type { DorlingSettings } from './DorlingSettings'
12
12
  import type { ScalebarConfig } from './decoration/ScalebarConfig'
13
13
  import type { EncodingConfig } from './encoding/EncodingConfig'
14
14
  import type { LocationConfig } from './locations'
15
+ import type { LabelsConfig } from './decoration/LabelsConfig'
15
16
 
16
17
  /**
17
18
  * A eurostat-map instance. Created by eurostatmap.map() and extended
@@ -229,15 +230,20 @@ export interface MapInstance {
229
230
  /** Insets. */
230
231
 
231
232
  /**
232
- * Inset map configurations. Pass 'default' for the standard
233
- * eurostat overseas territory insets. Passing true is an alias for 'default'.
234
- * Pass false to disable.
233
+ * Inset map configurations. Pass a named preset string, or a custom array, or false to
234
+ * disable. Passing true is an alias for 'default'.
235
+ * - 'default': simple grid layout of overseas territories.
236
+ * - 'image': Malta, Liechtenstein and EU/EFTA overseas/remote territories, hand-tuned
237
+ * layout with connecting decoration (background box, separator lines, blur gradients).
238
+ * - 'eu': simple grid layout of EU overseas/outermost territories, no decoration.
239
+ * - 'euEfta': like 'eu', plus Liechtenstein and Svalbard, no decoration.
235
240
  * @example map.insets('default')
241
+ * @example map.insets('image')
236
242
  * @example map.insets(true)
237
243
  * @example map.insets([{ geo: 'MT' }, { geo: 'LI' }])
238
244
  */
239
- insets(): InsetConfig[] | 'default' | false
240
- insets(config: InsetConfig[] | 'default' | true | false): this
245
+ insets(): InsetConfig[] | 'default' | 'image' | 'eu' | 'euEfta' | false
246
+ insets(config: InsetConfig[] | 'default' | 'image' | 'eu' | 'euEfta' | true | false): this
241
247
 
242
248
  /** Decoration. */
243
249
 
@@ -257,9 +263,12 @@ export interface MapInstance {
257
263
  placenames(): boolean
258
264
  placenames(show: boolean): this
259
265
 
260
- /** Geographic label configuration. See docs/reference.md#labelling */
261
- labels(): object | undefined
262
- labels(config: object): this
266
+ /**
267
+ * Get or set label configuration for country names, statistical values, etc.
268
+ * @example map.labels({ values: true, backgrounds: true, backgroundFill: '#B19122' })
269
+ */
270
+ labels(): LabelsConfig | undefined
271
+ labels(config: LabelsConfig): this
263
272
 
264
273
  /** Annotation configuration for d3-svg-annotation. */
265
274
  annotations(): any
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Configuration for map labels (country names, statistical values, etc.)
3
+ */
4
+ export interface LabelsConfig {
5
+ /**
6
+ * Array of label objects with text and coordinates.
7
+ * Use eurostatmap.getDefaultLabels() to get predefined geographic labels.
8
+ */
9
+ labels?: Array<{
10
+ text: string
11
+ x: number
12
+ y: number
13
+ class?: string
14
+ size?: number
15
+ rotate?: number
16
+ letterSpacing?: number
17
+ cc?: string
18
+ }>
19
+
20
+ /**
21
+ * Show statistical values as labels on regions.
22
+ * @default false
23
+ */
24
+ values?: boolean
25
+
26
+ /**
27
+ * Apply halo/shadow effect around labels for better readability.
28
+ * @default false
29
+ */
30
+ halos?: boolean
31
+
32
+ /**
33
+ * Legacy alias for halos.
34
+ * @deprecated Use halos instead
35
+ */
36
+ shadows?: boolean
37
+
38
+ /**
39
+ * Apply solid background rectangles behind labels.
40
+ * Takes precedence over halos when both are set.
41
+ * @default false
42
+ */
43
+ backgrounds?: boolean
44
+
45
+ /**
46
+ * Fill color for label background rectangles (CSS color string).
47
+ * Only applies when backgrounds is true.
48
+ * @default '#ffffff'
49
+ * @example 'white'
50
+ * @example '#B19122'
51
+ * @example 'rgba(255, 255, 255, 0.9)'
52
+ */
53
+ backgroundFill?: string
54
+
55
+ /**
56
+ * Scale labels when zooming in/out.
57
+ * @default true
58
+ */
59
+ scaleOnZoom?: boolean
60
+
61
+ /**
62
+ * Custom formatter function for statistical value labels.
63
+ * @example (value) => value.toFixed(1) + '%'
64
+ */
65
+ valuesFormatter?: (value: number) => string
66
+
67
+ /**
68
+ * Filter function to show/hide statistical value labels for specific regions.
69
+ * @param region - GeoJSON feature object
70
+ * @param map - Map instance
71
+ * @returns true to show label, false to hide
72
+ */
73
+ statLabelsFilterFunction?: (region: any, map: any) => boolean
74
+
75
+ /**
76
+ * Override default centroid positions for statistical value labels.
77
+ * Keys are region IDs (e.g., 'DE', 'FR01'), values are {x, y} coordinates.
78
+ */
79
+ statLabelsPositions?: Record<string, { x: number; y: number }>
80
+
81
+ /**
82
+ * Function to adjust calculated centroids for value labels.
83
+ * @param region - GeoJSON feature object
84
+ * @param centroid - Calculated centroid [x, y]
85
+ * @returns Adjusted centroid [x, y]
86
+ * @example (region, centroid) => [centroid[0] + 10, centroid[1] - 10]
87
+ */
88
+ processValueLabelCentroids?: (region: any, centroid: [number, number]) => [number, number]
89
+ }
@@ -1,138 +1,135 @@
1
- import { LegendConfig } from '../LegendConfig'
2
-
3
- /**
4
- * Configuration for bivariate choropleth map legends.
5
- * Displays a 2D grid showing the relationship between two variables,
6
- * with color squares representing different class combinations.
7
- */
8
- export interface BivariateLegendConfig extends LegendConfig {
9
- /** Size of the legend square grid in pixels. @default 100 */
10
- squareSize?: number
11
-
12
- /** Rotation angle of the legend in degrees. @default 0 */
13
- rotation?: number
14
-
15
- /** Label for the first variable (y-axis). @default 'Variable 1' */
16
- label1?: string
17
-
18
- /** Label for the second variable (x-axis). @default 'Variable 2' */
19
- label2?: string
20
-
21
- /** Break points for the first variable. Auto-calculated if undefined. */
22
- breaks1?: number[]
23
-
24
- /** Break points for the second variable. Auto-calculated if undefined. */
25
- breaks2?: number[]
26
-
27
- /** Whether to show break labels on the axes. @default false */
28
- showBreaks?: boolean
29
-
30
- /** Length of axis tick marks in pixels. @default 5 */
31
- tickLength?: number
32
-
33
- /** Offset adjustments for y-axis labels. @default { x: 0, y: 0 } */
34
- yAxisLabelsOffset?: { x: number; y: number }
35
-
36
- /** Offset adjustments for x-axis labels. @default { x: 0, y: 0 } */
37
- xAxisLabelsOffset?: { x: number; y: number }
38
-
39
- /** Offset adjustments for y-axis title. @default { x: 0, y: 0 } */
40
- yAxisTitleOffset?: { x: number; y: number }
41
-
42
- /** Offset adjustments for x-axis title. @default { x: 0, y: 0 } */
43
- xAxisTitleOffset?: { x: number; y: number }
44
-
45
- /** Extra vertical offset for the "no data" legend item in pixels. @default 30 */
46
- noDataYOffset?: number
47
-
48
- /** Whether to show arrows at the end of the axes. @default true */
49
- axisArrows?: boolean
50
-
51
- /** Height of axis arrows in pixels. @default 15 */
52
- arrowHeight?: number
53
-
54
- /** Width of axis arrows in pixels. @default 14 */
55
- arrowWidth?: number
56
-
57
- /** Padding between arrow and axis label in pixels. @default 10 */
58
- arrowPadding?: number
59
-
60
- /**
61
- * Labels displayed at low/high ends of each axis.
62
- * @default { x: { low: 'Low', high: 'High' }, y: { low: 'Low', high: 'High' } }
63
- */
64
- axisExtremes?: {
65
- x?: { low?: string; high?: string }
66
- y?: { low?: string; high?: string }
67
- }
68
-
69
- /** Whether to show low/high endpoint labels on both axes. @default true */
70
- showAxisExtremes?: boolean
71
-
72
- /**
73
- * Optional text annotations for each corner of the bivariate square.
74
- * Add text for any combination of topRight, bottomRight, bottomLeft, topLeft.
75
- * Supports line breaks using '<br>'/'<br/>' or '\\n'.
76
- */
77
- annotations?: {
78
- topRight?: string
79
- bottomRight?: string
80
- bottomLeft?: string
81
- topLeft?: string
82
- }
83
-
84
- /**
85
- * Length of corner annotation callout lines in pixels.
86
- * Can be a single number for all corners, or per-corner values.
87
- * @default 18
88
- */
89
- annotationLineLength?:
90
- | number
91
- | {
92
- topRight?: number
93
- bottomRight?: number
94
- bottomLeft?: number
95
- topLeft?: number
96
- }
97
-
98
- /**
99
- * Annotation text offsets in pixels.
100
- * Use global `{ x, y }` or per-corner values.
101
- * @default auto (based on corner direction)
102
- */
103
- annotationOffsets?:
104
- | { x?: number; y?: number }
105
- | {
106
- topRight?: { x?: number; y?: number }
107
- bottomRight?: { x?: number; y?: number }
108
- bottomLeft?: { x?: number; y?: number }
109
- topLeft?: { x?: number; y?: number }
110
- }
111
-
112
- /**
113
- * Extra offset applied to the leader-line endpoint where it meets the annotation label.
114
- * Use global `{ x, y }` or per-corner values.
115
- * @default { x: 0, y: 0 }
116
- */
117
- annotationLineEndOffset?:
118
- | { x?: number; y?: number }
119
- | {
120
- topRight?: { x?: number; y?: number }
121
- bottomRight?: { x?: number; y?: number }
122
- bottomLeft?: { x?: number; y?: number }
123
- topLeft?: { x?: number; y?: number }
124
- }
125
-
126
- /**
127
- * @deprecated Use annotationOffsets instead.
128
- * Radial padding between corner annotation callout line end and text in pixels.
129
- */
130
- annotationPadding?:
131
- | number
132
- | {
133
- topRight?: number
134
- bottomRight?: number
135
- bottomLeft?: number
136
- topLeft?: number
137
- }
138
- }
1
+ import { LegendConfig } from '../LegendConfig'
2
+
3
+ /**
4
+ * Configuration for bivariate choropleth map legends.
5
+ * Displays a 2D grid showing the relationship between two variables,
6
+ * with color squares representing different class combinations.
7
+ */
8
+ export interface BivariateLegendConfig extends LegendConfig {
9
+ /** Size of the legend square grid in pixels. @default 100 */
10
+ squareSize?: number
11
+
12
+ /** Rotation angle of the legend in degrees. @default 0 */
13
+ rotation?: number
14
+
15
+ /** Label for the first variable (x-axis). Supports `\\n` and `<br>` line breaks. @default 'Variable 1' */
16
+ label1?: string
17
+
18
+ /** Label for the second variable (y-axis). Supports `\\n` and `<br>` line breaks. @default 'Variable 2' */
19
+ label2?: string
20
+
21
+ /** Break labels for the first variable. Omit to hide first-axis break labels. */
22
+ breaks1?: Array<number | string>
23
+
24
+ /** Break labels for the second variable. Omit to hide second-axis break labels. */
25
+ breaks2?: Array<number | string>
26
+
27
+ /** Length of axis tick marks in pixels. @default 5 */
28
+ tickLength?: number
29
+
30
+ /** Offset adjustments for y-axis labels. @default { x: 0, y: 0 } */
31
+ yAxisLabelsOffset?: { x: number; y: number }
32
+
33
+ /** Offset adjustments for x-axis labels. @default { x: 0, y: 0 } */
34
+ xAxisLabelsOffset?: { x: number; y: number }
35
+
36
+ /** Offset adjustments for y-axis title. @default { x: 0, y: 0 } */
37
+ yAxisTitleOffset?: { x: number; y: number }
38
+
39
+ /** Offset adjustments for x-axis title. @default { x: 0, y: 0 } */
40
+ xAxisTitleOffset?: { x: number; y: number }
41
+
42
+ /** Extra vertical offset for the "no data" legend item in pixels. @default 30 */
43
+ noDataYOffset?: number
44
+
45
+ /** Whether to show arrows at the end of both axes, or for each axis independently. @default true */
46
+ axisArrows?: boolean | { x?: boolean; y?: boolean }
47
+
48
+ /** Height of axis arrows in pixels. @default 15 */
49
+ arrowHeight?: number
50
+
51
+ /** Width of axis arrows in pixels. @default 14 */
52
+ arrowWidth?: number
53
+
54
+ /** Padding between arrow and axis label in pixels. @default 10 */
55
+ arrowPadding?: number
56
+
57
+ /**
58
+ * Labels displayed at low/high ends of each axis.
59
+ * @default { x: { low: 'Low', high: 'High' }, y: { low: 'Low', high: 'High' } }
60
+ */
61
+ axisExtremes?: {
62
+ x?: { low?: string; high?: string }
63
+ y?: { low?: string; high?: string }
64
+ }
65
+
66
+ /** Whether to show low/high endpoint labels on both axes, or for each axis independently. @default true */
67
+ showAxisExtremes?: boolean | { x?: boolean; y?: boolean }
68
+
69
+ /**
70
+ * Optional text annotations for each corner of the bivariate square.
71
+ * Add text for any combination of topRight, bottomRight, bottomLeft, topLeft.
72
+ * Supports line breaks using '<br>'/'<br/>' or '\\n'.
73
+ */
74
+ annotations?: {
75
+ topRight?: string
76
+ bottomRight?: string
77
+ bottomLeft?: string
78
+ topLeft?: string
79
+ }
80
+
81
+ /**
82
+ * Length of corner annotation callout lines in pixels.
83
+ * Can be a single number for all corners, or per-corner values.
84
+ * @default 18
85
+ */
86
+ annotationLineLength?:
87
+ | number
88
+ | {
89
+ topRight?: number
90
+ bottomRight?: number
91
+ bottomLeft?: number
92
+ topLeft?: number
93
+ }
94
+
95
+ /**
96
+ * Annotation text offsets in pixels.
97
+ * Use global `{ x, y }` or per-corner values.
98
+ * @default auto (based on corner direction)
99
+ */
100
+ annotationOffsets?:
101
+ | { x?: number; y?: number }
102
+ | {
103
+ topRight?: { x?: number; y?: number }
104
+ bottomRight?: { x?: number; y?: number }
105
+ bottomLeft?: { x?: number; y?: number }
106
+ topLeft?: { x?: number; y?: number }
107
+ }
108
+
109
+ /**
110
+ * Extra offset applied to the leader-line endpoint where it meets the annotation label.
111
+ * Use global `{ x, y }` or per-corner values.
112
+ * @default { x: 0, y: 0 }
113
+ */
114
+ annotationLineEndOffset?:
115
+ | { x?: number; y?: number }
116
+ | {
117
+ topRight?: { x?: number; y?: number }
118
+ bottomRight?: { x?: number; y?: number }
119
+ bottomLeft?: { x?: number; y?: number }
120
+ topLeft?: { x?: number; y?: number }
121
+ }
122
+
123
+ /**
124
+ * @deprecated Use annotationOffsets instead.
125
+ * Radial padding between corner annotation callout line end and text in pixels.
126
+ */
127
+ annotationPadding?:
128
+ | number
129
+ | {
130
+ topRight?: number
131
+ bottomRight?: number
132
+ bottomLeft?: number
133
+ topLeft?: number
134
+ }
135
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eurostat-map",
3
- "version": "4.7.1",
3
+ "version": "4.8.1",
4
4
  "description": "Reusable library to quickly create and customise web maps showing Eurostat data directly retrieved from Eurostat database.",
5
5
  "keywords": [
6
6
  "cartography",