Skip to content

Range band ​

The space between a low and a high series. Good for forecasts with their uncertainty, daily low and high.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'xy',
  categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
  legend: true,
  series: [
    {
      name: 'Range',
      kind: 'band',
      low: [
        67, 65.7, 60.400000000000006, 60.7, 54.599999999999994, 48.4, 51.099999999999994,
        52.400000000000006, 47.9, 43.8, 39.2, 34.6,
      ],
      data: [97, 95.7, 90.4, 90.7, 84.6, 78.4, 81.1, 82.4, 77.9, 73.8, 69.2, 64.6],
      color: '#2a9d8f',
    },
    {
      name: 'Median',
      data: [81, 79.7, 74.4, 74.7, 68.6, 62.4, 65.1, 66.4, 61.9, 57.8, 53.2, 48.6],
      color: '#2a9d8f',
      dots: false,
    },
  ],
};

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

interface XYSpec extends Base {
  type: 'xy';
  categories: string[];
  series: Series[];
  axes?: Axis[];
  horizontal?: boolean;
  stacked?: boolean;
  /** Horizontal bars: first category at the top (default) or at the bottom. */
  reverse?: boolean;
  totals?: boolean;
  legend?: boolean;
  labelWidth?: number;
  grid?: boolean | 'dashed';
  /** Title under the horizontal axis. */
  xTitle?: string;
  /** Angle of the category labels (vertical charts), for example -45. */
  labelAngle?: number;
  lines?: ReferenceLine[];
  annotations?: Annotation[];
  /** Drag on the chart to look closer, double click to come back (vertical charts). */
  zoom?: boolean;
  /** No axis, no legend, no margin: a sparkline. */
  bare?: boolean;
}

interface Series {
  name: string;

interface Axis {
  side?: 'left' | 'right';

/** A line across the chart: a target, an average, a date. */
interface ReferenceLine {
  value?: number;

/** A note pinned on the chart. `at` is a category (xy) or an x value (scatter). */
interface Annotation {
  at: 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