Skip to content

Barcode plot ​

One thin tick for each value, a row for each group. Good for where values gather and where they are rare, in little room.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'barcode',
  data: [
    {
      name: 'North',
      values: [
        58.7, 49, 54.5, 53.7, 57.1, 50.7, 51.4, 52.2, 64.8, 44.7, 56.1, 48.3, 59, 46.8, 58.9, 49.4,
        60.3, 43.3, 51.7, 44.3, 47.6, 36, 52.5, 51.7, 51.1, 40.5, 51.2, 53.2, 52.3,
      ],
    },
    {
      name: 'South',
      values: [
        50.8, 72.2, 62.2, 56.9, 56.3, 79.4, 69.1, 78.7, 77.2, 48.4, 63.6, 63.4, 47.9, 65.5, 69.7,
        68.6, 76.6, 63.3, 54.3, 60.3, 54.1, 80.9, 57.5, 67.6, 59.8, 73.3, 59.2, 63.4, 82.8, 46.6,
        69.5, 96.6, 74,
      ],
    },
    {
      name: 'East',
      values: [
        66.3, 76.9, 64.1, 83.9, 67.4, 74.5, 70, 68.1, 77.2, 71.1, 73.6, 76, 65.7, 70.9, 66.9, 77.5,
        69.4, 66.6, 75.3, 79, 66.7, 75.5, 69.9, 77.6, 69.3, 73.1, 68.7, 75.2, 68.1, 47.7,
      ],
    },
    {
      name: 'West',
      values: [
        44, 44.4, 43, 38.6, 56.5, 47.5, 66.2, 46.6, 51.2, 37.4, 40.7, 43.3, 41.7, 41.6, 47.1, 46.2,
        46.7, 53.3, 50.5, 43.1, 46.4, 49, 47.7, 42.4, 42.5, 44.4, 48, 40.8, 40.5, 48, 52.2, 50,
        53.6, 41.9, 54.8, 44.5, 46.2, 30, 45.8,
      ],
    },
    {
      name: 'Centre',
      values: [
        56.8, 56.3, 61.1, 54.2, 60.2, 58.1, 55.4, 55.1, 55.6, 71.2, 64.9, 59.8, 58.5, 55.5, 70.2,
        61.7, 60.2, 64.3, 53.4, 56.8, 46.5, 67.5, 54.4, 56.5, 57.4, 59, 75.6, 66.3, 63.6, 63.4,
        58.6, 59.2, 59.8, 67.3, 52.9, 57.6,
      ],
    },
  ],
};

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

/** One thin tick for each value, a row for each group. */
interface BarcodeSpec extends Base {
  type: 'barcode';
  data: { name: string; values: number[]; color?: string }[];
  /** A thicker tick on the median, true by default. */
  median?: boolean;
}

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