# IoT device health (Trellis example)

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

Battery per device; panel() turns a panel red and the header flags it when it ends below 70 %.

- Chart type: `area` (Area)
- Collection: Trellis · Trellis
- Raw configuration: https://westcoast-charts.com/gallery-src/trellis/iot-device-health.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/trellis/iot-device-health.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: "area",
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Battery %",
      device: "Sensor 01",
      data: [82, 79, 82, 85, 82, 80, 78, 77, 75, 74, 76, 76, 77, 78, 79, 77, 77, 75, 77, 79, 79, 81, 79, 82]
    },
    {
      name: "Battery %",
      device: "Sensor 02",
      data: [78, 80, 77, 75, 73, 74, 76, 77, 75, 76, 74, 76, 75, 75, 77, 75, 76, 76, 74, 74, 73, 72, 72, 72]
    },
    {
      name: "Battery %",
      device: "Sensor 03",
      data: [78, 78, 78, 76, 79, 79, 81, 84, 87, 87, 88, 88, 89, 87, 85, 84, 84, 81, 82, 82, 83, 85, 85, 87]
    },
    {
      name: "Battery %",
      device: "Sensor 04",
      data: [78, 77, 75, 78, 78, 80, 80, 81, 84, 85, 85, 86, 84, 83, 83, 81, 81, 78, 77, 75, 75, 77, 78, 81]
    },
    {
      name: "Battery %",
      device: "Sensor 05",
      data: [81, 83, 81, 81, 78, 80, 82, 80, 81, 83, 81, 83, 84, 86, 84, 86, 85, 84, 83, 84, 83, 80, 82, 82]
    },
    {
      name: "Battery %",
      device: "Sensor 06",
      data: [80, 83, 82, 83, 80, 82, 82, 84, 81, 81, 81, 84, 87, 85, 83, 86, 89, 88, 87, 88, 89, 92, 89, 89]
    },
    {
      name: "Battery %",
      device: "Sensor 07",
      data: [81, 79, 78, 79, 81, 83, 83, 83, 82, 84, 84, 85, 84, 82, 83, 83, 81, 84, 82, 80, 78, 80, 78, 79]
    },
    {
      name: "Battery %",
      device: "Sensor 08",
      data: [79, 80, 78, 79, 77, 76, 77, 78, 76, 78, 77, 77, 76, 79, 80, 80, 83, 86, 85, 83, 83, 80, 83, 84]
    }
  ],
  yaxis: {
    min: 0,
    max: 100,
    tickAmount: 2
  },
  xaxis: {
    labels: {
      show: false
    }
  },
  stroke: {
    width: 1.5
  },
  fill: {
    opacity: 0.15
  },
  dataLabels: {
    enabled: false
  },
  trellis: {
    by: "device",
    columns: 4,
    aspectRatio: 1.6,
    legend: "none",
    header: {
      formatter: (k) => k + (({"Sensor 01":false,"Sensor 02":false,"Sensor 03":false,"Sensor 04":false,"Sensor 05":false,"Sensor 06":false,"Sensor 07":false,"Sensor 08":false})[k] ? '  ⚠ low' : '')
    },
    panel: (k) => ({ colors: [({"Sensor 01":false,"Sensor 02":false,"Sensor 03":false,"Sensor 04":false,"Sensor 05":false,"Sensor 06":false,"Sensor 07":false,"Sensor 08":false})[k] ? '#dc2626' : '#0d9488'] })
  },
  title: {
    text: "Battery, last 24 h"
  },
  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-iot-device-health.json --out trellis-iot-device-health.svg --with-table` (save the options above as JSON first)
