Schematex

Venn / Euler diagram

About Venn and Euler diagrams

A Venn diagram uses overlapping circles to show every possible logical relationship among a collection of sets — whether or not each intersection actually contains any elements. A Euler diagram is the more general form: circles are only drawn where relationships actually exist, so a set fully contained in another is shown as a nested circle, and two disjoint sets do not overlap at all. John Venn introduced the fixed-overlap form in 1880; Leonhard Euler described the general set-containment form in the 1760s.

Educators use them to teach set theory; data analysts reach for them to show audience overlap between segments (email list ∩ mobile users ∩ paid subscribers); researchers in biology, linguistics, and medicine use Euler diagrams to map taxonomic or conceptual hierarchies. Schematex supports all four common usage patterns in one DSL — declarative counts, element enumeration, region labels, and Euler subset/disjoint/overlap relations — and can mix them in a single diagram. See the Wikipedia article on Venn diagrams and Euler diagrams for background.

venn·§
↘ preview
100%
Customer Segments — Q3 2025 Venn/Euler diagram "Customer Segments — Q3 2025": 3 sets, 7 regions. Customer Segments — Q3 2025 Set Email subscribers Set Paid users Set Mobile app users Email subscribers Paid users Mobile app users 1840 920 2100 650 12400 3200 8700
UTF-8 · LF · 11 lines · 318 chars✓ parsed·16.7 ms·3.7 KB SVG

1. Your first Venn diagram

The smallest useful diagram: two sets, one overlap, two exclusive regions.

venn·§
↘ preview
100%
Support channels Venn/Euler diagram "Support channels": 2 sets, 3 regions. Support channels Set Email support Set Live chat Email support Live chat 320 1450 890
UTF-8 · LF · 6 lines · 140 chars✓ parsed·7.1 ms·2.4 KB SVG

Four rules cover 80% of usage:

  1. Start with venn, optionally followed by a quoted title.
  2. Declare each set with set ID "Label" — the id is used internally, the label appears in the diagram.
  3. Assign values to regions using A & B : value for intersections and A only : value for exclusive regions.
  4. Configure appearance with config: lines; the diagram mode (venn vs euler) can be set explicitly or left as auto.

Comments must start with # on their own line.


2. Sets

A set declaration creates one circle in the diagram.

set ID "Label" [color: "#hex"]
PartRequiredNotes
IDYesMust match [A-Za-z][A-Za-z0-9_-]*
"Label"YesQuoted string displayed on the circle
[color: "#hex"]NoOverride fill color for this set

Sets must be declared before they are referenced in region or relation lines.

venn·§
↘ preview
100%
Programming paradigms Venn/Euler diagram "Programming paradigms": 3 sets, 7 regions. Programming paradigms Set Object-Oriented Set Functional Set Logic Object-Oriented Functional Logic 180 45 90 12 620 340 95
UTF-8 · LF · 11 lines · 264 chars✓ parsed·2.1 ms·3.3 KB SVG

3. Regions

A region assigns a value to an intersection or exclusive area. The four DSL modes can be mixed in one diagram.

3.1 Declarative mode — counts and percentages

Assign a number or percentage to a named region. The region key is either an &-separated list of set ids (for intersections) or ID only (for the part of that set not covered by any other set).

A & B : 320          # integer count
A & B & C : 45       # three-way intersection
A only : 1450        # A minus all other sets
A & B : 18.5%        # percentage value
venn·§
↘ preview
100%
Market research Venn/Euler diagram "Market research": 3 sets, 7 regions. Market research Set Awareness Set Consideration Set Conversion Awareness Consideration Conversion 3400 890 210 150 18200 2100 540
UTF-8 · LF · 11 lines · 318 chars✓ parsed·7.9 ms·3.6 KB SVG

3.2 Region labels (text)

Use the region keyword prefix and assign a quoted string instead of a number. The string is rendered inside the region.

region A & B : "Nurture"
region B & C : "Convert"
region A & B & C : "Loyal customer"
venn·§
↘ preview
100%
Go-to-market funnel Venn/Euler diagram "Go-to-market funnel": 3 sets, 5 regions. Go-to-market funnel Set Awareness Set Consideration Set Purchase Awareness Consideration Purchase Nurture Convert Cold audience Loyal Direct buyers
UTF-8 · LF · 9 lines · 281 chars✓ parsed·1.6 ms·3.0 KB SVG

3.3 Enumeration mode — element lists

List the actual elements of each set. Schematex computes all intersections automatically.

ID = { element1, element2, element3 }

Elements are comma-separated bare words or quoted strings. Enumeration sets do not need an explicit set declaration — the declaration is implied.

venn·§
↘ preview
100%
Full-stack team skills Venn/Euler diagram "Full-stack team skills": 3 sets, 5 regions. Full-stack team skills Set Frontend Set Backend Set DevOps Frontend Backend DevOps React, CSS, Webpack Node.js TypeScript, Jest Docker, Kubernetes, Terraform PostgreSQL, Redis
UTF-8 · LF · 4 lines · 206 chars✓ parsed·2.2 ms·3.4 KB SVG

4. Euler relations

Euler relations express structural containment or separation — that one set is a subset of another, that two sets are completely disjoint, or that they merely overlap. They must reference set ids already declared with set.

from subset to    # from is fully inside to (also: "in")
from in to        # alias for subset
from disjoint to  # from and to do not overlap
from overlap to   # from and to partially overlap (explicit — the default for unrelated sets)
venn·§
↘ preview
100%
Biology taxonomy Venn/Euler diagram "Biology taxonomy": 5 sets, 0 regions. Biology taxonomy Set Animals Set Vertebrates Set Mammals Set Birds Set Fish Animals Vertebrates Mammals Birds Fish
UTF-8 · LF · 13 lines · 299 chars✓ parsed·0.9 ms·3.1 KB SVG
KeywordAliasMeaning
subsetinfrom is fully contained within to
disjointfrom and to do not intersect
overlapfrom and to intersect but neither contains the other

5. Configuration

config: lines tune diagram behavior. Each goes on its own line.

Config keyValuesDefaultEffect
diagramvenn, euler, autoautoForce Venn (all circles fixed) or Euler (subset nesting). auto infers from the presence of Euler relations.
proportionaltrue, falsefalseScale circle area proportional to region count values
showCountstrue, falseautoAlways / never show count labels. auto shows them when counts are provided.
showPercenttrue, falsefalseShow each region value as a percentage of the grand total
palettedefault, brand, monochromedefaultColor palette for sets (overridden by per-set color:)
blendModemultiply, screen, nonemultiplyHow overlapping fill colors blend

Config can also be written inline on the header line: venn "Title" [proportional: true, showPercent: true].

venn "Segment overlap"
config: proportional = true
config: showPercent = true
config: blendMode = screen

Layout selection:

  • layout venn — alternative form of config: diagram = venn (parses identically).
  • layout euler — alternative form of config: diagram = euler.
  • layout auto — alternative form of config: diagram = auto.

6. Labels & comments

  • Title: venn "My diagram" — first line only.
  • Set label: set A "Email subscribers" — quoted string on the set line.
  • Region value: integer, percentage, quoted string, or element list assigned after the :.
  • Comments: # at the start of a line (after leading whitespace).

7. Reserved words & escaping

Reserved at line start: venn (header), set, config:, layout, region.

Reserved operators in region keys: & (intersection), only (exclusive region).

Euler relation keywords: subset, in, disjoint, overlap — cannot be used as set ids.

ID rules: must match [A-Za-z][A-Za-z0-9_-]*. Labels with spaces go in the quoted "Label" field.


8. Common mistakes

You wroteParser saysFix
A & B : 320 before set A … and set B …VennParseError: unknown set id "A" in region keyDeclare sets with set before referencing them in region lines
dogs subset mammals before set dogs …VennParseError: unknown set "dogs" in relationDeclare sets first, then write Euler relations
set A Email subscribers (unquoted label with space)Parser error — label is expected to be a quoted stringQuote it: set A "Email subscribers"
A & B = 320 (equals instead of colon)Line doesn't match region pattern; parse errorUse colon: A & B : 320
Frontend = { React TypeScript } (no commas)React TypeScript treated as one elementComma-separate: Frontend = { React, TypeScript }
config: mode = vennmode is not a recognized key (key is diagram)Use config: diagram = venn
Mixing enumeration sets with explicit A & B : regionsEnumeration auto-derive only runs when regions.length === 0Use one style per diagram or add all regions explicitly

9. Grammar (EBNF)

document       = header (blank | comment | config | layout-stmt | set-decl | enum-decl | euler-rel | region)*

header         = "venn" ( ":"? WS quoted-string )? ( WS "[" config-props "]" )? NEWLINE
quoted-string  = '"' any-char-but-quote* '"'

config         = "config" WS ":" WS config-key WS "=" WS config-value NEWLINE
config-key     = "diagram" | "proportional" | "palette" | "blendMode" | "showCounts" | "showPercent"

layout-stmt    = "layout" WS ( "venn" | "euler" | "auto" ) NEWLINE

set-decl       = "set" WS id WS quoted-string ( WS "[" set-props "]" )? NEWLINE
set-props      = "color:" quoted-hex | "fill:" quoted-hex

enum-decl      = id WS "=" WS "{" element-list "}" NEWLINE
element-list   = element ( "," element )*
element        = quoted-string | bare-word

euler-rel      = id WS euler-op WS id NEWLINE
euler-op       = "subset" | "in" | "disjoint" | "overlap"

region         = "region"? WS region-key WS ":" WS region-value NEWLINE
region-key     = id WS "only"
               | id ( WS "&" WS id )+
region-value   = integer | percent | quoted-string | "[" element-list "]"

percent        = number "%"
id             = [A-Za-z] [A-Za-z0-9_-]*
comment        = "#" any NEWLINE

Authoritative source: src/diagrams/venn/parser.ts. If this diverges from the parser, the parser wins — please open an issue.


10. Roadmap

Planned — not yet parseable. Do not use these in generated DSL today; the parser will reject or ignore them.

  • Three-way and N-way Euler nesting — the renderer currently supports up to 3 sets in Venn mode; larger Euler diagrams with complex containment are not yet fully laid out.
  • fill: color alias — the fill: property on set is accepted by the parser (as an alias for color:) but the renderer currently only uses color:.
  • label: on regionsregion A & B [label: "Core"] syntax for separate label vs. value.
  • Area-proportional Eulerproportional: true currently only affects Venn mode; Euler containment layout ignores the flag.
  • and keyword — natural-language A and B : 120 as alias for A & B : 120.

Track in the GitHub issues if you need any of these sooner.