Venn
A venn draws two or three sets as overlapping circles. A row is one set, or one intersection. Two-set areas follow the sizes. Three-set areas are a best effort, and the chart says so.
When to use it
Use a venn when the question is who sits in more than one set. What customers use together is search, filters, and saved views, including the 90 customers in all three. Wheel, glaze, kiln and What notebooks combine are the same shape.
A pie or a donut splits one total. A slice is not in two sets. A treemap and a sunburst nest a hierarchy. A child belongs to one parent. A venn is the chart when membership overlaps.
Venn and the part-to-whole charts
Pie, donut, treemap, and sunburst account for one whole. The parts do not overlap, and they add up.
type: "venn" does not start from one total. Each set has its own size. The intersection is its own row. A customer in Search and Filters is counted in both sets and in the overlap. The circles are not slices of a pie.
Two sets are area-proportional: the circle area follows the set size, and the lens follows the intersection. Three sets are approximate. The chart adds the line "3-set areas are approximate". Four or more sets are an error, not a fourth circle.
Data
Each row is one region. set is the name, or several names joined with +. size is the weight. encoding.x is the set name and encoding.y is the size. The defaults are those column names, so a small spec can omit encoding.
Search+Filters is the pairwise overlap. Search+Filters+Saved views is the triple. The chart matches the names either way around, so Filters+Search is the same region. An intersection larger than its smallest set is CK1408. One set, or four or more, is CK1407.
Set names sit by the circles. Counts sit in the regions. There is no legend. legend is not read, and there is no key that makes a three-set area exact.
a11y.alt is required. One sentence, 10 to 500 characters, with the point of the chart. Say that three-set areas are approximate when the chart has three sets.
[
{ "set": "Search", "size": 1280 },
{ "set": "Filters", "size": 860 },
{ "set": "Search+Filters", "size": 410 }
]A spec that renders
This is the smallest venn. version, type, and a11y.alt are required. A and B are the sets. A+B is the overlap. Two sets, so the areas follow the sizes and there is no approximate caption.
The chart loads from @chartkitdev/core/charts/venn, or from @chartkitdev/core/extra. It is not in the line bundle. validate() warns CK1011 and points at validatePhase4().
{
"version": "1",
"type": "venn",
"data": [
{
"set": "A",
"size": 12
},
{
"set": "B",
"size": 8
},
{
"set": "A+B",
"size": 3
}
],
"a11y": {
"alt": "A and B overlap."
}
}Install core and the adapter for your framework. The menu in the sidebar picks the snippet. spec is the JSON above.
npm install @chartkitdev/core
npm install @chartkitdev/react
import { Chart } from "@chartkitdev/react";
export function Panel() {
return <Chart spec={spec} />;
}npm install @chartkitdev/core
npm install @chartkitdev/vanilla
import { mount } from "@chartkitdev/vanilla";
const chart = mount(document.querySelector("#chart"), spec);
chart.update(spec);npm install @chartkitdev/core
npm install @chartkitdev/vue
<script setup>
import { Chart } from "@chartkitdev/vue";
</script>
<template>
<Chart :spec="spec" />
</template>npm install @chartkitdev/core
npm install @chartkitdev/svelte
<script>
import { Chart } from "@chartkitdev/svelte";
</script>
<Chart {spec} />npm install @chartkitdev/core
npm install @chartkitdev/astro
---
import { Chart } from "@chartkitdev/astro";
---
<Chart spec={spec} />npm install @chartkitdev/core
npm install @chartkitdev/solid
import { Chart } from "@chartkitdev/solid";
export function Panel() {
return <Chart spec={spec} />;
}npm install @chartkitdev/core
npm install @chartkitdev/qwik
import { component$ } from "@builder.io/qwik";
import { Chart } from "@chartkitdev/qwik";
export const Panel = component$(() => {
return <Chart spec={spec} />;
});npm install @chartkitdev/core
npm install @chartkitdev/angular
import { Component } from "@angular/core";
import { Chart } from "@chartkitdev/angular";
@Component({
standalone: true,
imports: [Chart],
template: `<ck-chart [spec]="spec" />`,
})
export class Panel {
spec = spec;
}npm install @chartkitdev/core
npm install @chartkitdev/element
import "@chartkitdev/element";
const chart = document.querySelector("chart-kit");
chart.spec = spec;The option below is a key on the spec. The demo changes that key and updates the chart and the snippet together.
Examples
The rail switches among existing venn specs. What customers use together is the core example, three sets. Wheel, glaze, kiln is the showcase chart from a Mermaid venn. What notebooks combine is the discovery chart. The spec has no title, so the switcher uses the showcase heading. All three are three-set charts, so the areas are approximate.
Tooltip
tooltip is on for a venn when the key is omitted. Hovering a circle shows the set name and its size. Hovering a count shows the sets in that region and the size. The same sentence is the SVG title. tooltip: false tells the hover card not to open. tooltip: true turns it on.
{
"tooltip": false
}{
"tooltip": true
}tooltip.fields is not read. The card is the mark label, not a field table. Turning the card off and on again puts a custom tooltip object back in the spec. The card still uses the mark label.
The rest of the spec
There is no mark key for the circle layout, and no legend position. A fourth set is a second chart, not a smaller circle. Theme presets live on the playground.