# Traffic by country (Trellis example)

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

100 % stacked device split per country, one shared legend for all panels.

- Chart type: `bar` (Bar)
- Collection: Trellis · Trellis
- Raw configuration: https://westcoast-charts.com/gallery-src/trellis/traffic-by-country.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/trellis/traffic-by-country.html

## Setup

```js
import WestCoastCharts from 'west-coast-charts'
import types from 'west-coast-charts/types'
import trellis from 'west-coast-charts/features/trellis'

WestCoastCharts.use(types).use(trellis)
```

## Options

```js
const options = {
  chart: {
    height: "auto",
    fontFamily: "Inter, Geist, \"IBM Plex Sans\", system-ui, sans-serif",
    type: "bar",
    stacked: true,
    stackType: "100%",
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Mobile",
      country: "Portugal",
      data: [53, 35, 30, 29]
    },
    {
      name: "Desktop",
      country: "Portugal",
      data: [47, 35, 38, 53]
    },
    {
      name: "Tablet",
      country: "Portugal",
      data: [43, 54, 54, 16]
    },
    {
      name: "Mobile",
      country: "Spain",
      data: [32, 50, 20, 40]
    },
    {
      name: "Desktop",
      country: "Spain",
      data: [39, 36, 10, 30]
    },
    {
      name: "Tablet",
      country: "Spain",
      data: [16, 17, 57, 59]
    },
    {
      name: "Mobile",
      country: "France",
      data: [56, 44, 34, 30]
    },
    {
      name: "Desktop",
      country: "France",
      data: [19, 60, 23, 23]
    },
    {
      name: "Tablet",
      country: "France",
      data: [57, 26, 10, 60]
    },
    {
      name: "Mobile",
      country: "Italy",
      data: [42, 50, 45, 15]
    },
    {
      name: "Desktop",
      country: "Italy",
      data: [42, 29, 57, 17]
    },
    {
      name: "Tablet",
      country: "Italy",
      data: [52, 25, 35, 30]
    },
    {
      name: "Mobile",
      country: "Ireland",
      data: [21, 14, 45, 54]
    },
    {
      name: "Desktop",
      country: "Ireland",
      data: [55, 58, 29, 43]
    },
    {
      name: "Tablet",
      country: "Ireland",
      data: [11, 39, 39, 10]
    },
    {
      name: "Mobile",
      country: "Greece",
      data: [44, 40, 42, 27]
    },
    {
      name: "Desktop",
      country: "Greece",
      data: [13, 25, 38, 59]
    },
    {
      name: "Tablet",
      country: "Greece",
      data: [43, 45, 44, 55]
    }
  ],
  xaxis: {
    categories: ["Q1", "Q2", "Q3", "Q4"]
  },
  dataLabels: {
    enabled: false
  },
  trellis: {
    by: "country",
    columns: 3,
    aspectRatio: 1.7,
    legend: "shared"
  },
  title: {
    text: "Sessions by device"
  },
  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 trellis-traffic-by-country.json --out trellis-traffic-by-country.svg --with-table` (save the options above as JSON first)
