# Population pyramid (negatives) (Bar example)

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

Two-sided bars around zero with absolute labels.

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

## Setup

```js
import WestCoastCharts from 'west-coast-charts'
```

## Options

```js
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)
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 bar-bar-with-negative.json --out bar-bar-with-negative.svg --with-table` (save the options above as JSON first)
