eurostat-map 4.4.1 → 4.4.2

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.
@@ -6,6 +6,7 @@ import type { MapInstance as EurostatMap } from './MapInstance'
6
6
  import type { CoastalMarginSettings } from './decoration/CoastalMarginSettings'
7
7
  import type { GridCartogramSettings } from './GridCartogramSettings'
8
8
  import type { DorlingSettings } from './DorlingSettings'
9
+ import type { ScalebarConfig } from './decoration/ScalebarConfig'
9
10
 
10
11
  /**
11
12
  * 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.
@@ -59,7 +60,7 @@ export interface MapConfig {
59
60
  stat?: StatConfig
60
61
 
61
62
  /** Legend configuration. */
62
- legend?: LegendConfig
63
+ legend?: LegendConfig | false
63
64
 
64
65
  /** Tooltip configuration. */
65
66
  tooltip?: TooltipConfig
@@ -90,6 +91,78 @@ export interface MapConfig {
90
91
  /** Fires once the map is built. */
91
92
  onBuild?: (map: EurostatMap) => void
92
93
 
94
+ /** Scalebar configuration. Can be boolean or configuration object. */
95
+ scalebar?: ScalebarConfig | boolean
96
+
97
+ /** Grid cartogram enabled or disabled. */
98
+ gridCartogram?: boolean
99
+
100
+ /** Custom geometry filtering function. */
101
+ filterGeometriesFunction?: (geometry: any) => boolean
102
+
103
+ /** Toggle background map rendering (sea, country boundaries, etc.). */
104
+ backgroundMap?: boolean
105
+
106
+ /** Minimap configuration. */
107
+ minimap?: any
108
+
109
+ /** Show/hide zoom +/- buttons. */
110
+ zoomButtons?: boolean
111
+
112
+ /** Show/hide inset map toggle button. */
113
+ insetsButton?: boolean
114
+
115
+ /** Show/hide placename labels. */
116
+ placenames?: boolean
117
+
118
+ /** Filter function for placename labels. */
119
+ placenamesFilter?: (name: any) => boolean
120
+
121
+ /** Use a separate header section for titles. */
122
+ header?: boolean
123
+
124
+ /** Use a separate footer section for footnotes. */
125
+ footer?: boolean
126
+
127
+ /** Padding between the map and footer in pixels. */
128
+ footerPadding?: number
129
+
130
+ /** Padding between the header and map in pixels. */
131
+ headerPadding?: number
132
+
133
+ /** Position adjustment for map title: [x, y] */
134
+ titlePosition?: [number, number]
135
+
136
+ /** Position adjustment for map subtitle: [x, y] */
137
+ subtitlePosition?: [number, number]
138
+
139
+ /** Position adjustment for footnote text: [x, y] */
140
+ footnotePosition?: [number, number]
141
+
142
+ /** Position adjustment for Eurostat logo: [x, y] */
143
+ logoPosition?: [number, number]
144
+
145
+ /** Position adjustment for ribbon banner: [x, y] */
146
+ ribbonPosition?: [number, number]
147
+
148
+ /** Position adjustment for zoom buttons: [x, y] */
149
+ zoomButtonsPosition?: [number, number]
150
+
151
+ /** Position adjustment for insets button: [x, y] */
152
+ insetsButtonPosition?: [number, number]
153
+
154
+ /** Pointer hover color for NUTS regions. */
155
+ hoverColor?: string
156
+
157
+ /** Base fill color for regions with no statistical data. */
158
+ noDataFillStyle?: string
159
+
160
+ /** Show the link to the remote Eurostat statistical dataset. */
161
+ showSourceLink?: boolean
162
+
163
+ /** Pattern fill configurations. */
164
+ patternFill?: any
165
+
93
166
  /** Allow additional properties for extensibility. */
94
167
  [key: string]: any
95
168
  }
@@ -6,6 +6,7 @@ import type { InsetConfig } from './InsetConfig'
6
6
  import type { CoastalMarginSettings } from './decoration/CoastalMarginSettings'
7
7
  import type { GridCartogramSettings } from './GridCartogramSettings'
8
8
  import type { DorlingSettings } from './DorlingSettings'
9
+ import type { ScalebarConfig } from './decoration/ScalebarConfig'
9
10
 
10
11
  /**
11
12
  * A eurostat-map instance. Created by eurostatmap.map() and extended
@@ -221,6 +222,10 @@ export interface MapInstance {
221
222
  stamp(): object | undefined
222
223
  stamp(config: { x: number; y: number; text: string; size?: number }): this
223
224
 
225
+ /** Scalebar configuration. */
226
+ scalebar(): ScalebarConfig | null
227
+ scalebar(config: ScalebarConfig | boolean): this
228
+
224
229
  /** Scalebar visibility. */
225
230
  showScalebar(): boolean
226
231
  showScalebar(show: boolean): this
@@ -237,6 +242,94 @@ export interface MapInstance {
237
242
  showEstatRibbon(): boolean
238
243
  showEstatRibbon(show: boolean): this
239
244
 
245
+ /** Returns the D3 selection of the SVG element. */
246
+ svg(): any
247
+ svg(s: any): this
248
+
249
+ /** Custom geometry filtering function. */
250
+ filterGeometriesFunction(): ((geometry: any) => boolean) | undefined
251
+ filterGeometriesFunction(fn: (geometry: any) => boolean): this
252
+
253
+ /** Grid cartogram enabled or disabled. */
254
+ gridCartogram(): boolean
255
+ gridCartogram(enable: boolean): this
256
+
257
+ /** Toggle background map rendering (sea, country boundaries, etc.). */
258
+ backgroundMap(): boolean
259
+ backgroundMap(show: boolean): this
260
+
261
+ /** Minimap configuration. */
262
+ minimap(): any
263
+ minimap(config: any): this
264
+
265
+ /** Show/hide inset map toggle button. */
266
+ insetsButton(): boolean
267
+ insetsButton(show: boolean): this
268
+
269
+ /** Filter function for placename labels. */
270
+ placenamesFilter(): ((name: any) => boolean) | undefined
271
+ placenamesFilter(fn: (name: any) => boolean): this
272
+
273
+ /** Use a separate header section for titles. */
274
+ header(): boolean
275
+ header(show: boolean): this
276
+
277
+ /** Use a separate footer section for footnotes. */
278
+ footer(): boolean
279
+ footer(show: boolean): this
280
+
281
+ /** Padding between the map and footer in pixels. */
282
+ footerPadding(): number | undefined
283
+ footerPadding(padding: number): this
284
+
285
+ /** Padding between the header and map in pixels. */
286
+ headerPadding(): number | undefined
287
+ headerPadding(padding: number): this
288
+
289
+ /** Position adjustment for map title: [x, y] */
290
+ titlePosition(): [number, number] | undefined
291
+ titlePosition(pos: [number, number]): this
292
+
293
+ /** Position adjustment for map subtitle: [x, y] */
294
+ subtitlePosition(): [number, number] | undefined
295
+ subtitlePosition(pos: [number, number]): this
296
+
297
+ /** Position adjustment for footnote text: [x, y] */
298
+ footnotePosition(): [number, number] | undefined
299
+ footnotePosition(pos: [number, number]): this
300
+
301
+ /** Position adjustment for Eurostat logo: [x, y] */
302
+ logoPosition(): [number, number] | undefined
303
+ logoPosition(pos: [number, number]): this
304
+
305
+ /** Position adjustment for ribbon banner: [x, y] */
306
+ ribbonPosition(): [number, number] | undefined
307
+ ribbonPosition(pos: [number, number]): this
308
+
309
+ /** Position adjustment for zoom buttons: [x, y] */
310
+ zoomButtonsPosition(): [number, number] | undefined
311
+ zoomButtonsPosition(pos: [number, number]): this
312
+
313
+ /** Position adjustment for insets button: [x, y] */
314
+ insetsButtonPosition(): [number, number] | undefined
315
+ insetsButtonPosition(pos: [number, number]): this
316
+
317
+ /** Pointer hover color for NUTS regions. */
318
+ hoverColor(): string
319
+ hoverColor(color: string): this
320
+
321
+ /** Base fill color for regions with no statistical data. */
322
+ noDataFillStyle(): string
323
+ noDataFillStyle(style: string): this
324
+
325
+ /** Show the link to the remote Eurostat statistical dataset. */
326
+ showSourceLink(): boolean
327
+ showSourceLink(show: boolean): this
328
+
329
+ /** Pattern fill configurations. */
330
+ patternFill(): any
331
+ patternFill(config: any): this
332
+
240
333
  /** Dorling. */
241
334
 
242
335
  /** Enable Dorling cartogram layout for proportional symbol maps. */
@@ -71,8 +71,10 @@ export type { MushroomLegendConfig } from './legend/MushroomLegendConfig'
71
71
  export type { PatternFillLegendConfig } from './legend/PatternFillLegendConfig'
72
72
 
73
73
  // Choropleth legend types
74
+ export type { ChoroplethLegendConfig } from './legend/choropleth/ChoroplethLegendConfig'
74
75
  export type { BivariateLegendConfig } from './legend/choropleth/BivariateLegendConfig'
75
76
  export type { HistogramLegendConfig } from './legend/choropleth/HistogramLegendConfig'
77
+ export type { TrivariateLegendConfig } from './legend/choropleth/TrivariateLegendConfig'
76
78
 
77
79
  // Composition legend types
78
80
  export type { BarChartLegendConfig } from './legend/composition/BarChartLegendConfig'
@@ -204,7 +206,7 @@ export function getFillPatternDefinitionFunction(opts?: FillPatternOptions): (sv
204
206
  /**
205
207
  * Get default labels for the map
206
208
  */
207
- export function getDefaultLabels(): { [key: string]: string }
209
+ export function getDefaultLabels(): { [key: string]: any }
208
210
 
209
211
  /**
210
212
  * Project coordinates from map pixel space to geographic coordinates
@@ -238,8 +240,6 @@ declare const eurostatmap: {
238
240
  map: typeof map
239
241
  /** Get fill pattern definition function. */
240
242
  getFillPatternDefinitionFunction: typeof getFillPatternDefinitionFunction
241
- /** Get fill pattern definition fun. */
242
- getFillPatternDefinitionFun: typeof getFillPatternDefinitionFun
243
243
  /** Get default labels. */
244
244
  getDefaultLabels: typeof getDefaultLabels
245
245
  /** Project from map. */
@@ -13,12 +13,18 @@ export interface LegendConfig {
13
13
 
14
14
  /** Legend title text. */
15
15
  title?: string
16
+ /** Legend subtitle text. */
17
+ subtitle?: string
16
18
  /** Legend title font size in pixels. */
17
19
  titleFontSize?: number
18
20
 
19
21
  /** Box styling. */
20
22
  /** Inner spacing around legend content. */
21
23
  boxPadding?: number
24
+ /** Background opacity of the legend box. */
25
+ boxOpacity?: number
26
+ /** Padding between the title block and legend body. */
27
+ titlePadding?: number
22
28
 
23
29
  /** Shape styling (for proportional symbol legends). */
24
30
  /** Symbol swatch width in pixels. */
@@ -27,25 +33,36 @@ export interface LegendConfig {
27
33
  shapeHeight?: number
28
34
  /** Horizontal gap between shape and label. */
29
35
  shapePadding?: number
36
+ /** Length of separator lines in discrete legends. */
37
+ sepLineLength?: number
30
38
 
31
39
  /** Label styling. */
32
40
  /** Label font size in pixels. */
33
41
  labelFontSize?: number
34
- /** Pixel offset applied to labels. */
35
- labelOffset?: number
42
+ /** Pixel offsets applied to labels. */
43
+ labelOffsets?: { x: number; y: number }
44
+ /** Custom formatter for legend labels. */
45
+ labelFormatter?: ((value: number, index?: number) => string) | null
46
+ /** Number of decimal places for auto-formatted labels. */
47
+ decimals?: number
36
48
 
37
49
  /** Legend layout direction. */
38
50
  orientation?: 'vertical' | 'horizontal'
39
51
  /** Sort legend entries in ascending order when true. */
40
52
  ascending?: boolean
41
-
42
- /** Manual legend cell definitions. */
43
- cells?: any[]
44
-
45
53
  /** Whether to display the no-data legend item. */
46
54
  noData?: boolean
47
55
  /** Label used for no-data legend item. */
48
56
  noDataText?: string
57
+ /** Vertical gap before the no-data swatch in pixels. */
58
+ noDataPadding?: number
59
+ /** Width of the no-data swatch in pixels. */
60
+ noDataShapeWidth?: number
61
+ /** Height of the no-data swatch in pixels. */
62
+ noDataShapeHeight?: number
49
63
 
50
- [key: string]: any
64
+ /** Whether to show dataset min/max labels when supported. */
65
+ maxMin?: boolean
66
+ /** Text affixes for min/max labels as [minSuffix, maxSuffix]. */
67
+ maxMinLabels?: [string, string]
51
68
  }
@@ -0,0 +1,80 @@
1
+ import type { LegendConfig } from '../LegendConfig'
2
+ import type { HistogramLegendConfig } from './HistogramLegendConfig'
3
+
4
+ /**
5
+ * Configuration for choropleth map legends.
6
+ * Supports discrete, continuous, diverging, and histogram legend variants.
7
+ */
8
+ export interface ChoroplethLegendConfig extends LegendConfig {
9
+ /** Padding between the legend title and the legend body in pixels. @default 5 */
10
+ titlePadding?: number
11
+
12
+ /** Label style for discrete legends. @default 'thresholds' */
13
+ labelType?: 'thresholds' | 'ranges'
14
+
15
+ /** Length of the separator line in pixels for discrete legends. @default shapeWidth */
16
+ sepLineLength?: number
17
+
18
+ /** Length of threshold tick marks in pixels. @default 4 */
19
+ tickLength?: number
20
+
21
+ /** Number of decimal places for auto-formatted labels. Auto-detected when undefined. */
22
+ decimals?: number
23
+
24
+ /** Offset adjustments for labels. @default { x: 3, y: 0 } */
25
+ labelOffsets?: { x: number; y: number }
26
+
27
+ /** Custom formatter for legend labels. */
28
+ labelFormatter?: ((value: number, classIndex?: number) => string) | null
29
+
30
+ /** User-defined labels for classes in discrete legends. */
31
+ labels?: string[] | null
32
+
33
+ /** Histogram legend configuration. Set to null/undefined to disable histogram mode. */
34
+ histogram?: Partial<HistogramLegendConfig> | null
35
+
36
+ /** Label shown at the divergence point for diverging legends. */
37
+ pointOfDivergenceLabel?: string
38
+
39
+ /** Class index/value position used for diverging legends. */
40
+ pointOfDivergence?: number
41
+
42
+ /** Extra padding around the divergence marker in pixels. @default 7 */
43
+ pointOfDivergencePadding?: number
44
+
45
+ /** Explicit diverging guide line length in pixels. */
46
+ divergingLineLength?: number
47
+
48
+ /** Explicit diverging arrow length in pixels. */
49
+ divergingArrowLength?: number
50
+
51
+ /** Label shown at the low end of continuous legends. @default 'Low' */
52
+ lowLabel?: string
53
+
54
+ /** Label shown at the high end of continuous legends. @default 'High' */
55
+ highLabel?: string
56
+
57
+ /** Number of ticks to show on continuous legends. Use 0 to disable. @default 0 */
58
+ ticks?: number
59
+
60
+ /** Explicit tick values for continuous legends. */
61
+ tickValues?: number[]
62
+
63
+ /** Explicit tick labels for continuous legends. */
64
+ tickLabels?: Array<string | number>
65
+
66
+ /** Pixel tolerance used when hovering continuous legends to highlight nearby regions. @default 10 */
67
+ highlightTolerance?: number
68
+
69
+ /** Whether to show dataset min/max labels where supported. @default true */
70
+ maxMin?: boolean
71
+
72
+ /** Text affixes for min/max labels as [minSuffix, maxSuffix]. @default ['', ''] */
73
+ maxMinLabels?: [string, string]
74
+
75
+ /** Length of min/max tick marks in pixels. Defaults to tickLength when omitted. */
76
+ maxMinTickLength?: number
77
+
78
+ /** Whether to append region names to min/max labels. */
79
+ maxMinRegionLabels?: boolean
80
+ }
@@ -1,9 +1,13 @@
1
1
  import type { MapConfig } from '../../core/MapConfig'
2
+ import type { BivariateLegendConfig } from '../../legend/choropleth/BivariateLegendConfig'
2
3
 
3
4
  /**
4
5
  * Configuration for bivariate choropleth maps.
5
6
  */
6
7
  export interface BivariateChoroplethConfig extends MapConfig {
8
+ /** Bivariate choropleth legend configuration. */
9
+ legend?: BivariateLegendConfig | false
10
+
7
11
  /** Number of classes. */
8
12
  numberOfClasses?: number
9
13
  /** Breaks1. */
@@ -1,9 +1,13 @@
1
1
  import { MapConfig } from '../../core/MapConfig'
2
+ import type { ChoroplethLegendConfig } from '../../legend/choropleth/ChoroplethLegendConfig'
2
3
 
3
4
  /**
4
5
  * Configuration specific to choropleth maps
5
6
  */
6
7
  export interface ChoroplethConfig extends MapConfig {
8
+ /** Choropleth legend configuration. */
9
+ legend?: ChoroplethLegendConfig | false
10
+
7
11
  /** Classification. */
8
12
  numberOfClasses?: number
9
13
  /** Classification method. */
@@ -1,9 +1,13 @@
1
1
  import type { MapConfig } from '../../core/MapConfig'
2
+ import type { TrivariateLegendConfig } from '../../legend/choropleth/TrivariateLegendConfig'
2
3
 
3
4
  /**
4
5
  * Configuration for trivariate choropleth maps.
5
6
  */
6
7
  export interface TrivariateChoroplethConfig extends MapConfig {
8
+ /** Trivariate choropleth legend configuration. */
9
+ legend?: TrivariateLegendConfig | false
10
+
7
11
  /** Ternary codes. */
8
12
  ternaryCodes?: [string, string, string]
9
13
  /** No data fill style. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eurostat-map",
3
- "version": "4.4.1",
3
+ "version": "4.4.2",
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",
@@ -39,9 +39,11 @@
39
39
  "build-prod-debug": "webpack --config webpack/webpack.config.debug-size.js",
40
40
  "format": "prettier --write .",
41
41
  "copy-types": "copyfiles -u 2 \"src/types/**/*.d.ts\" build/types",
42
- "type-check": "tsc --noEmit && tsc --noEmit test/typescript-test.ts",
42
+ "check:types:legend-config-sync": "node test/scripts/check-legend-config-sync.js",
43
+ "type-check": "npm run check:types:legend-config-sync && tsc --noEmit && tsc --noEmit test/typescript-test.ts",
43
44
  "docs:api": "typedoc --options typedoc.json",
44
- "docs": "npm run docs:api"
45
+ "docs": "npm run docs:api",
46
+ "generate-previews": "node examples/scripts/generate-previews.js"
45
47
  },
46
48
  "dependencies": {
47
49
  "d3-array": "^3.2.4",
@@ -75,6 +77,7 @@
75
77
  "babel-loader": "^9.1.2",
76
78
  "copyfiles": "^2.4.1",
77
79
  "css-loader": "^7.1.2",
80
+ "playwright": "^1.60.0",
78
81
  "prettier": "^3.4.1",
79
82
  "style-loader": "^4.0.0",
80
83
  "ts-loader": "^9.5.4",