Venn Diagram Lab β interactive viewer, editor, and data visualization tool for Venn diagrams. 44 SVG models (2-set to 9-set) covering all major construction methods, with interactive region detection (Layer/Cut/UpSet views), a full SVG editor, CSV/TSV/GMT/GMX data import (file, paste, URL), statistical analysis, PDF report generation, and light/dark theme support.
Repository: https://github.com/ZoliQua/React-Venn-Diagram-Lab
Tech stack: React 19 + TypeScript 5.9 + Vite 8 + Vitest 4
Version file: src/version.ts (currently 1.9.3)
index.htmlnow contains a restrictive Content Security Policy. Keep GA consent loading, local assets, andblob:/data:export flows working when modifying it.src/utils/exportData.tsescapes spreadsheet-style formula prefixes in TSV text cells. Preserve that hardening when changing export behavior.- The welcome screen now includes
AboutVennDialog.tsx. Its educational text should stay source-grounded, English, and visually balanced for long-form reading. vite.config.tsnow copiespublications/*.pdfintodist/publications. Preserve that if the About dialog keeps linking to local PDFs.
- Do NOT hallucinate data. If unsure, flag it and ask.
- Always ask when uncertain about a decision.
- Plan first, then execute. Write a plan before non-trivial changes.
- Verify everything. Read a file before referencing it.
- Write and run tests. Anything marked DONE must be tested and working.
- No placeholder/stub code.
- All commits go under the user's name only (Zoltan Dul).
- Claude does NOT appear as co-author in commits.
- Only commit when explicitly asked.
- Strict SemVer.
- Major feature / UI change: +0.1 bump (e.g. 1.7.0 -> 1.8.0)
- Bugfix / text fix: +0.0.1 bump (e.g. 1.7.0 -> 1.7.1)
- Version lives in
src/version.ts, must be updated before each commit. - Changes must be recorded in
CHANGELOG.md.
- Do not "fix" code without reading it first.
- Do not expand scope without justification.
2-venn-diagram/
βββ src/ React + TypeScript source
β βββ App.tsx Main component (View/Edit/Data/Summary modes)
β βββ version.ts Version constant (APP_VERSION, APP_NAME)
β βββ models.ts 44-model catalog (MODEL_LIST) + fetch utilities
β βββ components/
β β βββ Toolbar.tsx Top bar (mode switcher, zoom, tools, theme toggle)
β β βββ Canvas.tsx SVG rendering + mouse interaction
β β βββ CutViewCanvas.tsx Pre-computed region rendering (Cut View)
β β βββ UpsetPlot.tsx UpSet plot SVG rendering component
β β βββ NetworkPlot.tsx Force-directed network graph (drag & move, click select)
β β βββ ViewerSidebar.tsx Model selector dropdown + region list
β β βββ ViewerInfoPanel.tsx Region info + item search (global Find Item + in-region filter)
β β βββ SummaryDialog.tsx Gallery dialog + SOURCES publication table
β β βββ AboutVennDialog.tsx Educational welcome-screen dialog
β β βββ WelcomeDialog.tsx Welcome screen + Credits with author photos
β β βββ HelpDialog.tsx Help content for each mode
β β βββ CsvImportDialog.tsx CSV/TSV import with format detection
β β βββ PasteImportDialog.tsx Paste gene lists directly (2-9 textareas)
β β βββ UrlImportDialog.tsx URL import with 5-step validation pipeline
β β βββ SampleDataDialog.tsx Sample dataset selector (5 curated datasets)
β β βββ PdfReportDialog.tsx PDF report generation dialog
β β βββ DataSummaryPanel.tsx Statistics panel (Jaccard, Dice, enrichment)
β β βββ Sidebar.tsx Editor layer tree
β β βββ PropertyPanel.tsx Editor property editor
β β βββ TestSidebar.tsx Data mode sidebar (file info, model, column mapping, view settings, export)
β β βββ ...
β βββ hooks/
β β βββ useSvgDocument.ts Document state + undo/redo
β β βββ useRegionDetection.ts Hit-testing + label-based detection
β β βββ useZoomPan.ts Zoom & pan
β βββ parser/ SVG parser & serializer
β βββ utils/
β β βββ hitTest.ts Shape containment detection
β β βββ regions.ts Region enumeration (2^n - 1 subsets)
β β βββ csvParser.ts CSV/TSV/GMT/GMX parser, binary & aggregated Venn calculation
β β βββ statistics.ts Statistical tests (Jaccard, Dice, hypergeometric, BH-FDR)
β β βββ exportData.ts TSV export (Region Summary + Item Matrix)
β β βββ upsetData.ts UpSet data conversion + sorting utilities
β β βββ upsetSvgBuilder.ts Print-optimized UpSet SVG string builder (max 20 cols)
β β βββ networkData.ts Network data model + force-directed layout algorithm
β β βββ networkSvgBuilder.ts Print-optimized Network SVG string builder
β β βββ proportionalLayout.ts Area-proportional circle solver (2/3-set binary search)
β β βββ proportionalModel.ts VennDocument generator for proportional diagrams
β β βββ proportionalRegions.ts Cut View region paths (analytical 2-set, grid-sampled 3-set)
β β βββ pdfReport.ts PDF report generation (jsPDF, lazy-loaded ~400KB chunk)
β β βββ svgToImage.ts SVG-to-PNG capture utility
β βββ __tests__/
β βββ aboutVennContent.test.ts About dialog content consistency tests
β βββ exportData.test.ts TSV export hardening tests
β βββ models.test.ts Model catalog integrity (44 models)
β βββ svgFormat.test.ts SVG format validation (venn*.svg only, Euler exception)
β βββ regions.test.ts Region enumeration logic
β βββ hitTest.test.ts Shape/Count ID parsing
β βββ csvParser.test.ts CSV parser tests
β βββ statistics.test.ts Statistical function tests
βββ models/
β βββ svg/ 44 SVG Venn diagram models
β βββ json/ 44 JSON pre-computed region data
βββ credits/ Author profile photos (4 images)
βββ data/ Sample datasets (3 real + 2 mock, prefixed dataset_real_/dataset_mock_)
βββ samples/ Source SVG samples used for model generation
βββ publications/ Research papers (PDF)
βββ article/ Implementation plans (markdown)
βββ public/ Static assets
βββ *.py Python utility scripts
βββ CHANGELOG.md Version history
βββ VENN-DIAGRAM-SVG-SPECIFICATION.md SVG format specification
βββ VENN-DIGARAM-PROJECT-STRUCTURE.md Standard color mapping & project info
βββ package.json Node.js project config
βββ vite.config.ts Vite build config
βββ index.html HTML entry point
- Summary β Gallery of all 44 diagrams, grouped by set count, with publication references
- View β Interactive viewer with three sub-modes:
- Layer View β transparent overlapping shapes,
isPointInFill()hit-testing - Cut View β pre-computed region paths from JSON, direct mouse events per region; two color modes: Depth and Heatmap
- UpSet View β UpSet plot visualization with matrix dots, intersection bars, set size bars, pagination (top 50), sort by size/degree, color modes (depth/heatmap/custom), threshold filter
- Network View β Force-directed network graph: nodes = sets (sized by cardinality), edges = pairwise intersections (weighted by count/Jaccard/FE/OC), significance coloring, drag & move, click to select region
- Layer View β transparent overlapping shapes,
- Edit β Full SVG editor with drag, text editing, shape move/rotate/resize, undo/redo, validation, export
- Data β 4 import methods (sample datasets, file upload, paste lists, URL import), visual model browser filtered by set count, area-proportional computed models (2-3 sets), auto-calculate on model/column change, column-to-set mapping (up to 9 sets), UpSet plot, statistical analysis (Jaccard, Dice, hypergeometric), PDF report, item search (global + in-region), image/data export
- Light/dark mode via
data-themeattribute on<html> - ~30 CSS variables in
:root(backgrounds, text, borders, semantic colors, significance) :root[data-theme="light"]block overrides all variables- Toggle button (β/βΎ) in toolbar, persisted to
localStorage, defaults to OSprefers-color-scheme
- Sample Data β
SampleDataDialogwith 5 curated datasets (3 real biological + 2 mock) - File Upload β CSV, TSV, TXT, GMT, GMX via
CsvImportDialogwith format detection - Paste Lists β
PasteImportDialogwith 2-9 textareas, delimiter auto-detect, generates aggregated CsvData - URL Import β
UrlImportDialogwith 5-step validation (URL, protocol, extension, fetch, content), preview, CORS handling
- jsPDF lazy-loaded (~400KB separate chunk)
- Page 1: Data Overview (timestamp, file, items, regions), Set Sizes pie chart + table (with Exclusive/Inclusive), footnotes for truncated names
- Page 2: Venn Diagram image (title hidden, names at 16px) + UpSet Plot image (max 20 cols, print-optimized white bg)
- Page 3+: Statistics tables (Jaccard, Dice, Enrichment with FDR coloring); 7-8-9 sets: each table on own page
- Network page: Set Relationship Network image + significant edges list with Jaccard values
- Last page: "About This Report" methodology explanations (Venn, UpSet, Network, Jaccard, Dice, Enrichment)
- Find Item (global): Collapsible section at top of right panel, searches across all regions' exclusive items, shows matching regions with color dots, set names, match count, and up to 5 matching items with highlighted text. Click to navigate to region.
- In-region filter: Search bar appears when >10 items in a region, filters with highlighted matches, limit increased from 50 to 200 when filtering.
src/models.tscontainsMODEL_LISTarray β the single source of truth for all 44 models- SVGs served from
models/svg/, JSONs frommodels/json/ SummaryDialog.tsxhas aSOURCESrecord mapping filenames to publication references- When adding a new model, update:
MODEL_LIST,SOURCES(if applicable), tests, and all hardcoded model counts in UI text
Every model SVG must contain these groups:
<g id="Shapes">β shapes namedShapeAthroughShapeI<g id="ShapesExtras">(optional) β additional shapes for Euler diagrams (ShapeX2)<g id="Texts">containing:<g id="Header">with<text id="Title"><g id="Group_Names">withNameA,NameB, etc.<g id="Group_Values">withCount_A,Count_AB, ...,Count_ABCDEFGHI<g id="Group_CountSums">(optional, 6+ set models)
<g id="Group_Bullets">with colored circlesBulletA,BulletB, etc.
Shape types used: <circle>, <ellipse>, <rect>, <path>, <polygon>
Text elements within Group_Values must be sorted:
- Single characters first: A, B, C, ...
- Then two-character combinations: AB, AC, AD, ...
- Then three-character, etc.
- Within same length: alphabetical order
| Set | Color | Hex |
|---|---|---|
| A | Yellow | #FFF200 |
| B | Blue | #2E3192 |
| C | Red | #ED1C24 |
| D | Grey | #808285 |
| E | Brown | #3C2415 |
| F | Magenta | #9E1F63 |
| G | Pink | #CA4B9B |
| H | Cyan | #21AED1 |
| I | Orange | #F7941E |
All SVGs use this exact comment:
<!-- Created by Zoltan Dul in 2026 - free to use with MIT license. Part of React Venn Diagram Lab Module - https://github.com/ZoliQua/React-Venn-Diagram-Lab - SVG Version: 3.0.0 -->
Each SVG has a matching JSON in models/json/ with pre-computed region boundaries.
JSON structure:
{
"name": "Diagram name",
"n": 3,
"sets": ["A", "B", "C"],
"curves": ["M ... Z", ...],
"regions": ["", "M ... Z", ...],
"colors": {"A": "#FFF200", ...},
"region_labels": {"A": [196.2, 357.7], ...},
"set_names": {"A": "NameA", ...}
}curves: shape boundaries as SVG path strings in normalized coordinates ([-50, 50] range, Y-flipped)regions: array indexed by bitmask (0=exterior empty, 1=last set only, 2=second-to-last set only, 3=both, ...)region_labels: centroid positions in SVG pixel coordinates
Generation: python generate_region_json.py uses Shapely for Boolean intersection/difference operations.
- Create SVG in
models/svg/following the standard format - Run
python generate_region_json.py <name>to create matching JSON - Add entry to
MODEL_LISTinsrc/models.ts(sorted by set count) - Add
SOURCESentry insrc/components/SummaryDialog.tsxif publication exists - Update model count in:
src/components/WelcomeDialog.tsx(3 places)src/components/HelpDialog.tsx(2 places)src/__tests__/models.test.ts(2 places)src/__tests__/svgFormat.test.ts(1 place)- Or better: grep for the old count number across
src/
- Run
npm testto verify
| Script | Purpose |
|---|---|
generate_region_json.py |
Generate JSON region data from SVGs (Shapely). Supports --all, specific names, or auto-detect missing |
svg_rotate_labels.py |
Cyclic label rotation with color & sort support |
svg_normalize_after_illustrator.py |
Normalize SVGs after Illustrator export |
svg_center_texts.py |
Center text elements in SVGs |
svg_generate_tests.py |
Generate test SVG files |
| Method | Sets | Key property |
|---|---|---|
| Venn (1880) | 2-5 | Classic circles/ellipses |
| Edwards (1996) | 2-9 | Cogwheel curves, all regions guaranteed |
| Anderson (1988) | 3-6 | Rectangles + U-shapes + comb paths |
| Grunbaum (1984/1992) | 5, 7 | Ellipses (5-set) and complex curves (7-set) |
| Bannier & Bodin (2017) | 5-8 | Rectangles + Z-shapes + combs, scalable to 8+ |
| Carroll (2000) | 3-6 | Triangular polygon arrangements |
| Mamakani et al. (2012) | 7 | Rosette symmetric curves (Adelaide, Hamilton, etc.) |
| SUMO-Venn | 6, 8 | Organic freeform curves |