Traffic by country
100 % stacked device split per country, one shared legend for all panels.
Open the chart without page chrome ↗
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)
chart.render()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)
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() Waiting for the chart.
Open Data & agent view to read this chart through chart.describe().
Read from the running library through its optional agent/describe module. Text, table and JSON share the same snapshot. Demo data only.
$ wcc chart export trellis-traffic-by-country.json --out trellis-traffic-by-country.svg --with-table Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm. Save a JSON spec first and check the loaded runtime and supported modules before rendering. Command reference
Loading /gallery/trellis/traffic-by-country/index.md …