# Selection (Maps example)

> WestCoast Charts 1.1.5, release, public Core release, on npm. HTML: https://westcoast-charts.com/gallery/maps/selection/ · Index for agents: https://westcoast-charts.com/llms.txt

Click a country to select it; the event reports it and the api can select from code.

- Chart type: `map` (Map)
- Collection: Maps · Maps
- Raw configuration: https://westcoast-charts.com/gallery-src/maps/selection.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/premium/maps/selection.html

## Setup

```js
import WestCoastCharts from 'west-coast-charts'
import types from 'west-coast-charts/types'
import premium from 'west-coast-charts/premium'
import 'west-coast-charts/maps/world-small-states' // registers the map shapes

WestCoastCharts.use(types).use(premium)
const WestCoastChartsPremium = premium
WestCoastCharts.setLicenseKey(LICENCE_KEY) // paid production licence; localhost evaluation needs no key
```

## Options

```js
const options = {
  "chart": {
    "height": 480,
    "toolbar": {
      "show": false
    },
    "type": "map",
    "events": {
      "dataPointSelection": (e, ctx, o) => {
              const message = (o.selected ? 'selected ' : 'cleared ') + (o.name || o.id) + (o.value !== undefined ? ' (' + o.value + ')' : '')
              const output = ctx.el && ctx.el.ownerDocument && ctx.el.ownerDocument.querySelector('#stage .g-log')
              if (output) output.textContent = message
              else console.log(message)
            }
    }
  },
  "series": [
    {
      "name": "Value",
      "data": [
        {
          "id": "DEU",
          "region": "Europe",
          "value": 54.2
        },
        {
          "id": "FRA",
          "region": "Europe",
          "value": 82.9
        },
        {
          "id": "GBR",
          "region": "Europe",
          "value": 82.6
        },
        {
          "id": "ITA",
          "region": "Europe",
          "value": 75
        },
        {
          "id": "ESP",
          "region": "Europe",
          "value": 73.3
        },
        {
          "id": "NLD",
          "region": "Europe",
          "value": 68.5
        },
        {
          "id": "BEL",
          "region": "Europe",
          "value": 67.9
        },
        {
          "id": "CHE",
          "region": "Europe",
          "value": 50.1
        },
        {
          "id": "AUT",
          "region": "Europe",
          "value": 56.7
        },
        {
          "id": "POL",
          "region": "Europe",
          "value": 75.4
        },
        {
          "id": "SWE",
          "region": "Europe",
          "value": 81.2
        },
        {
          "id": "NOR",
          "region": "Europe",
          "value": 68.5
        },
        {
          "id": "DNK",
          "region": "Europe",
          "value": 57.1
        },
        {
          "id": "FIN",
          "region": "Europe",
          "value": 48
        },
        {
          "id": "IRL",
          "region": "Europe",
          "value": 75.2
        },
        {
          "id": "PRT",
          "region": "Europe",
          "value": 49.2
        },
        {
          "id": "CZE",
          "region": "Europe",
          "value": 55.4
        },
        {
          "id": "HUN",
          "region": "Europe",
          "value": 43.4
        },
        {
          "id": "ROU",
          "region": "Europe",
          "value": 68.3
        },
        {
          "id": "GRC",
          "region": "Europe",
          "value": 64.5
        },
        {
          "id": "SVK",
          "region": "Europe",
          "value": 67
        },
        {
          "id": "BGR",
          "region": "Europe",
          "value": 85.7
        },
        {
          "id": "HRV",
          "region": "Europe",
          "value": 77.3
        },
        {
          "id": "SRB",
          "region": "Europe",
          "value": 81.5
        },
        {
          "id": "SVN",
          "region": "Europe",
          "value": 83.3
        },
        {
          "id": "LTU",
          "region": "Europe",
          "value": 57.1
        },
        {
          "id": "LVA",
          "region": "Europe",
          "value": 60.8
        },
        {
          "id": "EST",
          "region": "Europe",
          "value": 79.7
        },
        {
          "id": "UKR",
          "region": "Europe",
          "value": 67.5
        },
        {
          "id": "BLR",
          "region": "Europe",
          "value": 62.2
        },
        {
          "id": "ISL",
          "region": "Europe",
          "value": 83.4
        },
        {
          "id": "USA",
          "region": "North America",
          "value": 49.2
        },
        {
          "id": "CAN",
          "region": "North America",
          "value": 51.9
        },
        {
          "id": "MEX",
          "region": "North America",
          "value": 48.4
        },
        {
          "id": "GTM",
          "region": "North America",
          "value": 98.2
        },
        {
          "id": "CRI",
          "region": "North America",
          "value": 79.8
        },
        {
          "id": "PAN",
          "region": "North America",
          "value": 69.3
        },
        {
          "id": "CUB",
          "region": "North America",
          "value": 94.3
        },
        {
          "id": "DOM",
          "region": "North America",
          "value": 89.6
        },
        {
          "id": "BRA",
          "region": "South America",
          "value": 32.2
        },
        {
          "id": "ARG",
          "region": "South America",
          "value": 22
        },
        {
          "id": "CHL",
          "region": "South America",
          "value": 28.7
        },
        {
          "id": "COL",
          "region": "South America",
          "value": 40.6
        },
        {
          "id": "PER",
          "region": "South America",
          "value": 25.8
        },
        {
          "id": "URY",
          "region": "South America",
          "value": 31.4
        },
        {
          "id": "ECU",
          "region": "South America",
          "value": 22.4
        },
        {
          "id": "VEN",
          "region": "South America",
          "value": 34.5
        },
        {
          "id": "BOL",
          "region": "South America",
          "value": 22.6
        },
        {
          "id": "PRY",
          "region": "South America",
          "value": 40
        },
        {
          "id": "JPN",
          "region": "Asia",
          "value": 27
        },
        {
          "id": "KOR",
          "region": "Asia",
          "value": 29.4
        },
        {
          "id": "CHN",
          "region": "Asia",
          "value": 21.6
        },
        {
          "id": "IND",
          "region": "Asia",
          "value": 21.7
        },
        {
          "id": "IDN",
          "region": "Asia",
          "value": 41.3
        },
        {
          "id": "SGP",
          "region": "Asia",
          "value": 39.1
        },
        {
          "id": "MYS",
          "region": "Asia",
          "value": 47.1
        },
        {
          "id": "THA",
          "region": "Asia",
          "value": 35.1
        },
        {
          "id": "VNM",
          "region": "Asia",
          "value": 34.9
        },
        {
          "id": "PHL",
          "region": "Asia",
          "value": 22.3
        },
        {
          "id": "ISR",
          "region": "Asia",
          "value": 36.6
        },
        {
          "id": "ARE",
          "region": "Asia",
          "value": 24.6
        },
        {
          "id": "SAU",
          "region": "Asia",
          "value": 32.9
        },
        {
          "id": "TUR",
          "region": "Asia",
          "value": 22.6
        },
        {
          "id": "KAZ",
          "region": "Asia",
          "value": 26.1
        },
        {
          "id": "PAK",
          "region": "Asia",
          "value": 49.1
        },
        {
          "id": "BGD",
          "region": "Asia",
          "value": 38.5
        },
        {
          "id": "LKA",
          "region": "Asia",
          "value": 41.4
        },
        {
          "id": "AUS",
          "region": "Oceania",
          "value": 40.5
        },
        {
          "id": "NZL",
          "region": "Oceania",
          "value": 37.4
        },
        {
          "id": "ZAF",
          "region": "Africa",
          "value": 7.9
        },
        {
          "id": "NGA",
          "region": "Africa",
          "value": 12
        },
        {
          "id": "EGY",
          "region": "Africa",
          "value": 8.6
        },
        {
          "id": "KEN",
          "region": "Africa",
          "value": 14.7
        },
        {
          "id": "MAR",
          "region": "Africa",
          "value": 12.1
        },
        {
          "id": "GHA",
          "region": "Africa",
          "value": 14.1
        },
        {
          "id": "ETH",
          "region": "Africa",
          "value": 8.3
        },
        {
          "id": "TZA",
          "region": "Africa",
          "value": 16.8
        },
        {
          "id": "DZA",
          "region": "Africa",
          "value": 14.2
        },
        {
          "id": "TUN",
          "region": "Africa",
          "value": 7.6
        },
        {
          "id": "SEN",
          "region": "Africa",
          "value": 10.5
        },
        {
          "id": "CIV",
          "region": "Africa",
          "value": 14.8
        },
        {
          "id": "AGO",
          "region": "Africa",
          "value": 15.1
        }
      ]
    }
  ],
  "plotOptions": {
    "map": {
      "map": "world-small-states"
    }
  },
  "theme": {
    "mode": "light",
    "preset": "coastal"
  }
}

const chart = new WestCoastCharts(document.querySelector('#chart'), options)
await chart.render()
```

## Verify

- Text check (Library 1.1.5): load `west-coast-charts/agent/describe` and call `chart.describe({ format: "json" })` for the actual drawn state. The live reader is on this example’s HTML page.
- Command line (Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm, https://westcoast-charts.com/docs/cli/index.md): `wcc chart export maps-selection.json --out maps-selection.svg --with-table` (save the options above as JSON first)
