Skip to content

Tree rings ​

The rings of a trunk, one a year, as wide as the growth of that year, with dry years pointed at. Good for climate history, forests, and any yearly growth told as a living thing.

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: 'treerings',
  data: [
    { year: 1958, width: 3.6 },
    { year: 1959, width: 3.57 },
    { year: 1960, width: 4.33 },
    { year: 1961, width: 4.19 },
    { year: 1962, width: 3.56 },
    { year: 1963, width: 3.63 },
    { year: 1964, width: 3.49 },
    { year: 1965, width: 3.46 },
    { year: 1966, width: 4.62 },
    { year: 1967, width: 3.09 },
    { year: 1968, width: 4.05 },
    { year: 1969, width: 0.6 },
    { year: 1970, width: 3.68 },
    { year: 1971, width: 3.35 },
    { year: 1972, width: 3.31 },
    { year: 1973, width: 4.08 },
    { year: 1974, width: 2.84 },
    { year: 1975, width: 3.51 },
    { year: 1976, width: 3.67 },
    { year: 1977, width: 3.44 },
    { year: 1978, width: 4 },
    { year: 1979, width: 2.97 },
    { year: 1980, width: 3.23 },
    { year: 1981, width: 3.4 },
    { year: 1982, width: 3.96 },
    { year: 1983, width: 2.83 },
    { year: 1984, width: 3.39 },
    { year: 1985, width: 3.06 },
    { year: 1986, width: 2.52 },
    { year: 1987, width: 3.59 },
    { year: 1988, width: 2.75 },
    { year: 1989, width: 3.02 },
    { year: 1990, width: 0.9 },
    { year: 1991, width: 3.65 },
    { year: 1992, width: 2.71 },
    { year: 1993, width: 2.38 },
    { year: 1994, width: 3.34 },
    { year: 1995, width: 2.71 },
    { year: 1996, width: 2.77 },
    { year: 1997, width: 2.84 },
    { year: 1998, width: 2.5 },
    { year: 1999, width: 3.57 },
    { year: 2000, width: 2.53 },
    { year: 2001, width: 2.3 },
    { year: 2002, width: 2.26 },
    { year: 2003, width: 1.83 },
    { year: 2004, width: 2.19 },
    { year: 2005, width: 1.75 },
    { year: 2006, width: 2.32 },
    { year: 2007, width: 2.79 },
    { year: 2008, width: 2.55 },
    { year: 2009, width: 2.42 },
    { year: 2010, width: 2.78 },
    { year: 2011, width: 1.74 },
    { year: 2012, width: 1.81 },
    { year: 2013, width: 2.38 },
    { year: 2014, width: 2.64 },
    { year: 2015, width: 2.51 },
    { year: 2016, width: 2.77 },
    { year: 2017, width: 1.93 },
    { year: 2018, width: 0.9 },
    { year: 2019, width: 2.27 },
    { year: 2020, width: 2.23 },
    { year: 2021, width: 2.5 },
    { year: 2022, width: 1.66 },
    { year: 2023, width: 1.62 },
    { year: 2024, width: 2.59 },
    { year: 2025, width: 1.56 },
  ],
  events: [
    { year: 1969, name: 'Dry summer' },
    { year: 1990, name: 'Drought' },
    { year: 2018, name: 'Heat wave' },
  ],
};

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

/** Rings of a tree trunk, one for each year, as wide as the growth of that year. */
interface TreeRingsSpec extends Base {
  type: 'treerings';
  /** From the oldest year to the last one. `width` in mm. */
  data: { year: number; width: number }[];
  /** Years to point at: a drought, a fire. */
  events?: { year: number; name: 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