Population pyramid (negatives)

Two-sided bars around zero with absolute labels.

Chart type
Bar bar
Tier
Free Core
Collection
Bar
Render
Live, site theme
View .md Agent setup
LIVE/bar/bar-with-negative5 of 12 in Bar

Configuration

Raw Standalone
const options = {
  chart: {
    height: 380,
    fontFamily: "Inter, Geist, \"IBM Plex Sans\", system-ui, sans-serif",
    type: "bar",
    stacked: true,
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Men",
      data: [-2.1, -2.2, -3.1, -3.9, -4.7, -5, -5.9, -6.5, -7.6]
    },
    {
      name: "Women",
      data: [2.5, 2.7, 3.6, 4.1, 4.2, 5.1, 5.5, 6.2, 7.1]
    }
  ],
  xaxis: {
    categories: ["85+", "75–84", "65–74", "55–64", "45–54", "35–44", "25–34", "15–24", "0–14"],
    labels: {
      formatter: (v) => Math.abs(Math.round(v)) + '%'
    }
  },
  yaxis: {
    min: -8,
    max: 8
  },
  tooltip: {
    y: {
      formatter: (v) => Math.abs(v) + '%'
    }
  },
  plotOptions: {
    bar: {
      horizontal: true,
      barHeight: "82%"
    }
  },
  dataLabels: {
    enabled: false
  },
  grid: {
    xaxis: {
      lines: {
        show: false
      }
    }
  },
  title: {
    text: "Population by age (share)"
  },
  theme: {
    mode: "light",
    preset: "coastal"
  }
}

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