Skip to content

Air quality index ​

An index on its coloured bands, and the pollutants that make it. Good for cities, schools, health apps: is the air good today, and why not.

The smallest code that works. change the code, then press Run

In your framework

import { Chart } from 'nervure/react';
import 'nervure/themes';

const spec = {
  type: 'airquality',
  value: 102,
  pollutants: [
    { name: 'PM2.5', index: 74, value: 14.1, unit: 'µg/m³' },
    { name: 'PM10', index: 51, value: 19.6, unit: 'µg/m³' },
    { name: 'O₃', index: 21, value: 56.6, unit: 'ppb' },
    { name: 'NO₂', index: 40, value: 14.4, unit: 'ppb' },
  ],
};

export default function Example() {
  return <Chart spec={spec} style={{ height: 340 }} />;
}

Or import this chart alone: what each import weighs.

Options

Beside the fields shared by every chart (title, format, heading, export…), type airquality takes:

/** An air quality index on its bands, with the pollutants that make it. */
interface AirQualitySpec extends Base {
  type: 'airquality';
  /** The index. */
  value: number;
  /** Bands of the index: upper bound, name and colour. The United States bands (0 to 500) by default. */
  bands?: { to: number; name: string; color?: string }[];
  /** Pollutants: their sub-index on the same scale, their concentration in the tooltip. */
  pollutants?: { name: string; index: number; value?: number; unit?: string }[];
}

Style it

  • Colours: theme.palette, chart.setColor(name, colour), or --nervure-palette in your CSS. More
  • Marks: [data-series="name"], parts: [data-part="axes"], legend, series. What you change is kept in exports.
  • Movement: animation: false draws at once. More
  • Files: chart.download('png'), svg, csv. More

Close to it