eurostat-map
    Preparing search index...

    Interface LabelsConfig

    Configuration for map labels (country names, statistical values, etc.)

    interface LabelsConfig {
        labels?: Label[];
        values?: boolean;
        halos?: boolean;
        shadows?: boolean;
        backgrounds?: boolean;
        backgroundFill?: string;
        statLabelTextColor?: string;
        countryLabelTextColor?: string;
        countryCodeLabelTextColor?: string;
        seaLabelTextColor?: string;
        backgroundPadding?: number | { x?: number; y?: number };
        backgroundShape?: "circle" | "rect";
        backgroundBorderRadius?: number;
        scaleOnZoom?: boolean;
        preventOverlap?: boolean;
        valuesFormatter?: (value: number) => string;
        statLabelsFilterFunction?: (region: any, map: any) => boolean;
        statLabelsPositions?: Record<string, { x: number; y: number }>;
        processValueLabelCentroids?: (
            region: any,
            centroid: [number, number],
        ) => [number, number];
    }
    Index
    labels?: Label[]

    Array of label objects with text and coordinates. Use eurostatmap.getDefaultLabels() to get predefined geographic labels.

    values?: boolean

    Show statistical values as labels on regions.

    false
    
    halos?: boolean

    Apply halo/shadow effect around labels for better readability.

    false
    
    shadows?: boolean

    Legacy alias for halos.

    Use halos instead

    backgrounds?: boolean

    Apply solid background rectangles behind labels. Takes precedence over halos when both are set.

    false
    
    backgroundFill?: string

    Fill color for label background rectangles (CSS color string). Only applies when backgrounds is true.

    '#ffffff'
    
    'white'
    
    '#B19122'
    
    'rgba(255, 255, 255, 0.9)'
    
    statLabelTextColor?: string

    Fill/stroke color for statistical value label text only (the labels shown when values is enabled, and the value labels inside proportional symbols). Does not affect geographic labels (country names, country codes, seas) - see countryLabelTextColor, countryCodeLabelTextColor and seaLabelTextColor for those.

    '#111111'
    
    countryLabelTextColor?: string

    Fill/stroke color for country name labels (class: 'countries').

    '#111111'
    
    countryCodeLabelTextColor?: string

    Fill/stroke color for country code labels (class: 'cc').

    '#000000'
    
    seaLabelTextColor?: string

    Fill/stroke color for sea/ocean labels (class: 'seas').

    '#2a58b3'
    
    backgroundPadding?: number | { x?: number; y?: number }

    Padding between statistical label text and its background edge, in pixels. A number applies equal padding on both axes; an object controls each axis.

    { x: 5, y: 2 }
    
    backgroundShape?: "circle" | "rect"

    Background shape used for statistical value labels.

    'rect'
    
    backgroundBorderRadius?: number

    Corner radius in pixels when backgroundShape is 'rect'.

    0
    
    scaleOnZoom?: boolean

    Scale labels when zooming in/out.

    true
    
    preventOverlap?: boolean

    Nudge geographic labels (country names/codes/seas) apart using a force-collision simulation so neighbouring labels don't overlap. Does not affect statistical value labels, which are positioned at region centroids.

    false
    
    valuesFormatter?: (value: number) => string

    Custom formatter function for statistical value labels.

    (value) => value.toFixed(1) + '%'
    
    statLabelsFilterFunction?: (region: any, map: any) => boolean

    Filter function to show/hide statistical value labels for specific regions.

    Type Declaration

      • (region: any, map: any): boolean
      • Parameters

        • region: any

          GeoJSON feature object

        • map: any

          Map instance

        Returns boolean

        true to show label, false to hide

    statLabelsPositions?: Record<string, { x: number; y: number }>

    Override default centroid positions for statistical value labels. Keys are region IDs (e.g., 'DE', 'FR01'), values are {x, y} coordinates.

    processValueLabelCentroids?: (
        region: any,
        centroid: [number, number],
    ) => [number, number]

    Function to adjust calculated centroids for value labels.

    Type Declaration

      • (region: any, centroid: [number, number]): [number, number]
      • Parameters

        • region: any

          GeoJSON feature object

        • centroid: [number, number]

          Calculated centroid [x, y]

        Returns [number, number]

        Adjusted centroid [x, y]

    (region, centroid) => [centroid[0] + 10, centroid[1] - 10]