Skip to content

Venn diagram ​

Circles that overlap as much as their sets. Good for what two or three groups have in common.

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

In your framework

import { Chart } from 'nervure/react';

const spec = {
  type: 'venn',
  sets: [{ name: 'Readers', value: 81 }, { name: 'Buyers', value: 56 }, { name: 'Members', value: 35 }],
  overlaps: [
    { of: [0, 1], value: 21 },
    { of: [0, 2], value: 10 },
    { of: [1, 2], value: 7 },
    { of: [0, 1, 2], value: 4 },
  ],
};

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

interface VennSpec extends Base {
  type: 'venn';
  sets: { name: string; value: number; color?: string }[];
  /** Shared by some sets, by their indexes: { of: [0, 1], value: 12 }. */ overlaps?: { of: number[]; value: 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