Meteogram
Temperature, rain and wind on one time axis: a line, bars and an arrow for each step. Good for forecasts for a place over a few days, the way weather services draw them.
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: 'meteogram',
data: [
{ label: 'Mon 00h', temperature: 7.8, rain: 0, wind: 14, gust: 21, direction: 202 },
{ label: 'Mon 03h', temperature: 6.2, rain: 0, wind: 14, gust: 22, direction: 185 },
{ label: 'Mon 06h', temperature: 8.1, rain: 0, wind: 10, gust: 24, direction: 179 },
{ label: 'Mon 09h', temperature: 12.5, rain: 0, wind: 13, gust: 22, direction: 219 },
{ label: 'Mon 12h', temperature: 16.8, rain: 0, wind: 7, gust: 21, direction: 209 },
{ label: 'Mon 15h', temperature: 18.8, rain: 0, wind: 19, gust: 30, direction: 217 },
{ label: 'Mon 18h', temperature: 17.1, rain: 0, wind: 19, gust: 32, direction: 212 },
{ label: 'Mon 21h', temperature: 13.1, rain: 0, wind: 8, gust: 17, direction: 221 },
{ label: 'Tue 00h', temperature: 9, rain: 0, wind: 20, gust: 30, direction: 210 },
{ label: 'Tue 03h', temperature: 7.4, rain: 2.3, wind: 17, gust: 29, direction: 233 },
{ label: 'Tue 06h', temperature: 9.3, rain: 6, wind: 12, gust: 22, direction: 222 },
{ label: 'Tue 09h', temperature: 13.7, rain: 0.2, wind: 10, gust: 19, direction: 216 },
{ label: 'Tue 12h', temperature: 18, rain: 4.2, wind: 12, gust: 25, direction: 243 },
{ label: 'Tue 15h', temperature: 20, rain: 0.6, wind: 17, gust: 25, direction: 252 },
{ label: 'Tue 18h', temperature: 18.3, rain: 4, wind: 18, gust: 36, direction: 246 },
{ label: 'Tue 21h', temperature: 14.3, rain: 0, wind: 19, gust: 33, direction: 272 },
{ label: 'Wed 00h', temperature: 10.2, rain: 0, wind: 12, gust: 31, direction: 250 },
{ label: 'Wed 03h', temperature: 8.6, rain: 0, wind: 18, gust: 36, direction: 246 },
{ label: 'Wed 06h', temperature: 10.5, rain: 0, wind: 9, gust: 23, direction: 291 },
{ label: 'Wed 09h', temperature: 14.9, rain: 0, wind: 18, gust: 35, direction: 272 },
{ label: 'Wed 12h', temperature: 19.2, rain: 0, wind: 11, gust: 23, direction: 265 },
{ label: 'Wed 15h', temperature: 21.2, rain: 0, wind: 20, gust: 25, direction: 269 },
{ label: 'Wed 18h', temperature: 19.5, rain: 0, wind: 20, gust: 31, direction: 299 },
{ label: 'Wed 21h', temperature: 15.5, rain: 0, wind: 14, gust: 20, direction: 294 },
],
feels: [
6.1, 4.5, 6.9, 10.9, 15.9, 16.4, 14.7, 12.1, 6.5, 5.3, 7.8, 12.5, 16.5, 17.9, 16.1, 11.9,
8.7, 6.4, 9.4, 12.7, 17.8, 18.7, 17, 13.8,
],
};
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 meteogram takes:
/** Temperature, rain and wind on one time axis: the line, the bars and an arrow for each step. */
interface MeteogramSpec extends Base {
type: 'meteogram';
/** Colour of the main series. */
color?: string;
data: MeteogramStep[];
/** ° by default. */
unit?: string;
/** km/h by default. */
windUnit?: string;
/** A second line: the temperature it feels like. */
feels?: (number | null)[];
}
/** One step of a meteogram: an hour or a few. */
interface MeteogramStep {
/** "06:00", "Mon 12h"… */
label: string;Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More