Skip to content

Weather forecast ​

Days or hours with a drawn sky, the highs and lows, and the chance of rain. Good for forecasts, and the weather of an event or a trip.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'weather',
  data: [
    { label: 'Mon', icon: 'partly', max: 18, min: 13, rain: 6 },
    { label: 'Tue', icon: 'partly', max: 16, min: 6, rain: 1 },
    { label: 'Wed', icon: 'storm', max: 16, min: 12, rain: 71 },
    { label: 'Thu', icon: 'partly', max: 14, min: 9, rain: 22 },
    { label: 'Fri', icon: 'sun', max: 12, min: 5, rain: 18 },
    { label: 'Sat', icon: 'rain', max: 13, min: 4, rain: 62 },
    { label: 'Sun', icon: 'cloud', max: 13, min: 6, rain: 26 },
  ],
};

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 weather takes:

/** Days or hours of a forecast: sky, temperatures and the chance of rain. */
interface WeatherSpec extends Base {
  type: 'weather';
  data: { label: string; icon: WeatherIcon; max: number; min?: number; rain?: number }[];
  /** After each temperature: ° by default. */
  unit?: string;
}

type WeatherIcon = 'sun' | 'partly' | 'cloud' | 'rain' | 'snow' | 'storm' | 'fog';

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