Skip to content

Monthly returns ​

Years by months, green above zero and red below, with the return of each year. Good for performance reports of a fund, a portfolio or a strategy.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'returns',
  data: [
    { year: 2020, months: [1, -1, -4.4, 0.4, -5.1, -5.2, 2.5, 1.3, -3.7, -3.4, -3.9, -3.9] },
    { year: 2021, months: [7.8, -6.6, 2.6, -6.9, -0.6, -3.4, -3.2, 4.3, -6.8, -0.4, 2, -0.2] },
    { year: 2022, months: [5.8, -4.2, -1.1, 1.1, 6.6, -3.7, 1.6, -1.7, -6.1, 4.6, -2.6, -0.1] },
    { year: 2023, months: [7.8, 6.4, -1.7, -5, 4.4, -1.1, 0.2, 1, -2, 8.5, -1.6, -3.5] },
    { year: 2024, months: [-3.3, -6.6, -2.7, -6.8, -1.5, 4, 1.7, 0.5, 4.4, -5.5, -3.9, 1.9] },
    { year: 2025, months: [4.7, 3.5, 6.3, -1, 6.1, 2.4, 2.3, 5.8, -2, -2, null, null] },
  ],
};

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

/** Monthly returns: years by months, green above zero, red below, and the return of each year. */
interface ReturnsSpec extends Base {
  type: 'returns';
  data: YearReturns[];
  up?: string;
  down?: string;
}

interface YearReturns {
  year: string | number;

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