This skill generates interactive Venn diagram visualizations using the venn.js JavaScript library...
Generate interactive Venn diagram visualizations using venn.js and D3.js for intelligent textbooks. Creates complete MicroSim packages with standalone HTML files, MkDocs integration, and Dublin Core metadata. Each diagram features customizable colors, interactive tooltips, and follows the educational MicroSim pattern for seamless integration into educational content.
Use the venn-diagram-generator skill when users request:
Example user requests:
If the user has NOT provided a title, ask them for one using clear, friendly language:
To create your Venn diagram, I need a title. What would you like to call this diagram?
Examples:
- "Programming Languages Comparison"
- "Pet Characteristics"
- "Technology Skill Overlap"
Required information before proceeding:
Check for Existing Definitions (IMPORTANT):
Before asking the user for definitions, check if /docs/glossary.md exists and contains definitions for the set terms:
Read /docs/glossary.mdExample glossary lookup:
If creating diagram for "AI, Machine Learning, Deep Learning":
- Search glossary.md for "Artificial Intelligence", "Machine Learning", "Deep Learning"
- Extract the definitions
- Use them directly in the definitions object
If the description is incomplete or unclear, prompt the user for additional information:
To create an accurate Venn diagram, I need more information:
1. What sets/categories do you want to compare?
2. What items or characteristics are shared between sets?
3. Are there any items unique to each set?
4. What's the educational purpose of this diagram?
5. (Only if not in glossary) How would you define each set and their overlaps?
Priority for Definitions:
/docs/glossary.md for existing definitionsNote on Definitions: Using glossary definitions ensures consistency across the textbook and leverages existing ISO 11179-compliant content. Every hover interaction becomes a teaching moment that reinforces concepts from the glossary.
Consult references/venn-js-reference.md for detailed syntax guidance and examples.
Design decisions:
Determine set count (2, 3, or 4 circles):
Define set sizes: Use proportional values that reflect relationships:
Choose color palette: Select from educational-friendly schemes:
Structure the data in venn.js format:
// 2-Circle Example
var sets = [
{sets: ['Python'], size: 100},
{sets: ['JavaScript'], size: 100},
{sets: ['Python', 'JavaScript'], size: 40}
];
// 3-Circle Example
var sets = [
{sets: ['AI'], size: 100},
{sets: ['ML'], size: 80},
{sets: ['Data Science'], size: 90},
{sets: ['AI', 'ML'], size: 60},
{sets: ['AI', 'Data Science'], size: 50},
{sets: ['ML', 'Data Science'], size: 55},
{sets: ['AI', 'ML', 'Data Science'], size: 40}
];
Create the diagram directory following the MicroSim pattern:
mkdir -p /docs/sims/[diagram-name]
Naming convention:
programming-languages, pet-comparison, ml-ai-overlapUse the template files in assets/template/ as a starting point. Replace all placeholders with actual content.
Copy assets/template/script.js and replace placeholders:
{{VENN_DATA}}: Replace with the actual sets array (from Step 2){{COLOR_SCHEME}}: Replace with color configuration array{{DEFINITIONS}}: Create educational definitions object (see Educational Tooltips below)Example color scheme format:
var colorScheme = [
{set: 'Python', color: '#667eea'},
{set: 'JavaScript', color: '#764ba2'},
{set: 'Java', color: '#4facfe'}
];
Educational Tooltips (CRITICAL):
Always create a definitions object that maps sets to educational content. Replace meaningless size values with definitions that explain what each region represents.
// Example definitions object
var definitions = {
'Python': 'High-level language known for readability and data science',
'JavaScript': 'Language that runs in browsers for web interactivity',
'Java': 'Platform-independent language used in enterprise applications',
'JavaScript,Python': 'Both are dynamically typed and interpreted languages',
'Java,Python': 'Both support object-oriented programming with classes',
'Java,JavaScript': 'Both use C-like syntax and are widely adopted',
'Java,JavaScript,Python': 'All three support variables, loops, and functions'
};
// Helper function to retrieve definitions
function getDefinition(sets) {
var key = sets.sort().join(',');
return definitions[key] || sets.join(" ā© ");
}
// Use in tooltip (NOT d.size)
.on("mouseover", function(event, d) {
tooltip.html(getDefinition(d.sets)); // Educational content
})
Definition Guidelines:
Good vs Bad Examples:
ā Good: "Systems that simulate human intelligence and decision-making" ā Good: "Overlap: Methods combining statistical analysis with AI"
ā Bad: "Size: 150" (not educational) ā Bad: "This is the intersection of sets A and B containing 40 elements" (too technical) ā Bad: "Machine learning algorithms are techniques that..." (too long)
Why This Matters:
Important: Ensure proper JavaScript syntax - the data will be embedded directly into the script.
Copy assets/template/main.html and replace these placeholders:
{{TITLE}}: Diagram title (e.g., "Programming Languages Comparison"){{SUBTITLE}}: Brief subtitle (e.g., "Interactive Venn Diagram"){{DESCRIPTION}}: 2-3 sentence explanation of what the diagram showsThe main.html template already includes:
Copy assets/template/style.css directly - no modifications needed unless custom styling is requested.
The default stylesheet ensures:
Copy assets/template/index.md and replace placeholders:
{{TITLE}}: Same as main.html title{{META_DESCRIPTION}}: SEO-friendly description (1 sentence){{OVERVIEW}}: 1-paragraph overview of what the diagram illustrates{{DESCRIPTION}}: Detailed description of the visualization{{SET_RELATIONSHIPS}}: Bulleted list explaining relationships:- **Set A**: Contains items X, Y, Z (unique to A)
- **Set B**: Contains items M, N, O (unique to B)
- **A ā© B**: Shared items include P, Q
{{KEY_CONCEPTS}}: Bulleted list of educational concepts illustrated{{EDUCATIONAL_APPLICATIONS}}: How teachers/students can use this diagram{{DIAGRAM_NAME}}: Directory name (for iframe embedding example){{RELATED_CONCEPTS}}: Links to related textbook sectionsCopy assets/template/metadata.json and replace placeholders:
{{TITLE}}: Diagram title{{DESCRIPTION}}: Brief description (2-3 sentences){{SUBJECT}}: Educational subject area (e.g., "Mathematics", "Computer Science", "Biology"){{DATE}}: Current date in ISO format (YYYY-MM-DD){{COVERAGE}}: Scope of content (e.g., "Introductory", "Intermediate", "Advanced"){{AUDIENCE}}: Target audience (e.g., "High School", "Undergraduate", "General"){{SET_COUNT}}: Number of main circles (2, 3, or 4){{INTERSECTION_COUNT}}: Number of intersection areas{{CONCEPTS_LIST}}: JSON array of set labels with proper quoting:"Set A", "Set B", "Set C"
{{BLOOM_LEVEL}}: Highest Bloom's Taxonomy level (e.g., "Understand", "Apply", "Analyze")Example metadata.json:
{
"title": "Programming Languages Comparison",
"description": "Interactive Venn diagram showing the overlap and unique features of Python, JavaScript, and Java programming languages",
"subject": "Computer Science",
"creator": "Claude AI with Venn Diagram Generator Skill",
"date": "2025-11-07",
"type": "Interactive Venn Diagram",
"format": "text/html",
"language": "en-US",
"coverage": "Introductory",
"rights": "Educational Use",
"audience": "Undergraduate",
"diagram_type": "venn",
"set_count": "3",
"intersection_count": "7",
"concepts": [
"Python",
"JavaScript",
"Java",
"Programming Paradigms",
"Language Features"
],
"bloom_taxonomy": "Understand",
"version": "1.0",
"library": "venn.js 0.2.20",
"dependencies": ["d3.js 7.9.0"]
}
Perform quality checks:
Data validation:
File structure: Verify all 5 files are present:
Placeholder replacement: Check that no {{PLACEHOLDERS}} remain in any file
JavaScript syntax: Ensure script.js has valid JSON for sets array
Responsive design: Verify diagram adapts to different screen sizes
Test the diagram:
Open main.html directly in a browser to verify:
If working within a textbook project with mkdocs.yml, suggest adding the diagram to navigation:
nav:
- Visualizations:
- Programming Languages: sims/programming-languages/index.md
Or integrate into relevant chapter:
nav:
- Chapter 2 - Set Theory:
- Introduction: chapters/02/index.md
- Venn Diagrams: sims/set-relationships/index.md
Provide a clear summary of what was created:
ā Created interactive Venn diagram: [Diagram Title]
Location: /docs/sims/[diagram-name]/
Files generated:
ā main.html - Standalone interactive diagram with venn.js
ā index.md - MkDocs integration page with iframe embed
ā style.css - Responsive styling with tooltips
ā script.js - Venn diagram data and interactive features
ā metadata.json - Dublin Core metadata for searchability
Features:
⢠[X]-circle Venn diagram
⢠Interactive tooltips showing set intersections
⢠Customized color scheme
⢠Responsive design for mobile and desktop
⢠Educational-friendly 16px fonts
The diagram illustrates: [brief description of what it shows]
To view:
1. Standalone: Open /docs/sims/[diagram-name]/main.html in a browser
2. In textbook: Run `mkdocs serve` and navigate to the diagram page
Next steps:
- Test the diagram by opening main.html
- Add navigation link in mkdocs.yml (if applicable)
- Reference from relevant chapter content
- Consider creating related diagrams for connected concepts
ALWAYS use educational definitions in tooltips instead of size values. This is the most important improvement for educational Venn diagrams.
The Problem: Default venn.js examples display size values like "150 users" which provide no educational value. Students see numbers instead of learning content.
The Solution: Create a definitions object that maps each set and intersection to a clear, concise educational definition:
var definitions = {
'AI': 'Systems that simulate human intelligence, reasoning, and decision-making',
'ML': 'Algorithms that learn patterns from data without explicit programming',
'Deep Learning': 'Neural networks with multiple layers that learn complex representations',
'AI,ML': 'Machine Learning is a subset of AI that focuses on learning from data',
'ML,Deep Learning': 'Deep Learning is a specialized form of ML using neural networks',
'AI,ML,Deep Learning': 'Deep Learning represents the intersection of AI and ML approaches'
};
function getDefinition(sets) {
var key = sets.sort().join(',');
return definitions[key] || sets.join(" ā© ");
}
Implementation Pattern:
getDefinition(d.sets) in tooltip, NOT d.sizeImpact: Every hover interaction becomes a teaching moment that reinforces learning objectives and provides immediate context.
Clarity over Complexity:
Proportional Sizing:
Color Selection:
Meaningful Labels:
Educational Context:
Use case: Comparing two categories with clear overlap
Example: "Fruits vs Vegetables"
var sets = [
{sets: ['Fruits'], size: 100},
{sets: ['Vegetables'], size: 100},
{sets: ['Fruits', 'Vegetables'], size: 20} // e.g., Tomatoes
];
Use case: Showing complex relationships between three domains
Example: "Math, Physics, Computer Science"
var sets = [
{sets: ['Math'], size: 100},
{sets: ['Physics'], size: 100},
{sets: ['CS'], size: 100},
{sets: ['Math', 'Physics'], size: 40}, // e.g., Calculus
{sets: ['Math', 'CS'], size: 35}, // e.g., Algorithms
{sets: ['Physics', 'CS'], size: 30}, // e.g., Simulations
{sets: ['Math', 'Physics', 'CS'], size: 15} // e.g., Computational Physics
];
Use case: Showing hierarchical relationships (one set inside another)
Example: "Animals > Mammals > Dogs"
var sets = [
{sets: ['Animals'], size: 150},
{sets: ['Mammals'], size: 50},
{sets: ['Animals', 'Mammals'], size: 50} // Mammals ā Animals
];
Use case: Showing mutually exclusive categories
Example: "Odd Numbers vs Even Numbers"
var sets = [
{sets: ['Odd'], size: 100},
{sets: ['Even'], size: 100}
// No intersection - sets are disjoint
];
Issue: Sets data is invalid
// BAD
{sets: ['A'], size: 10},
{sets: ['A','B'], size: 15} // Can't be larger than A!
// GOOD
{sets: ['A'], size: 20},
{sets: ['A','B'], size: 15}
Issue: Colors not showing correctly
// Data uses 'Python' but colors use 'python' (case mismatch)
var sets = [{sets: ['Python'], size: 10}];
var colorScheme = [{set: 'python', color: '#667eea'}]; // Wrong!
// Correct
var colorScheme = [{set: 'Python', color: '#667eea'}]; // Fixed!
Issue: Diagram too small/large
venn.VennDiagram() callIssue: Labels cut off
Issue: Tooltips not appearing
Issue: Diagram not responsive on mobile
makeResponsive() function is called and SVG has viewBox attributereferences/venn-js-reference.md: Comprehensive venn.js guide with examples, data formats, styling options, color palettes, and troubleshootingai-ml-dl-examplejs.js: Complete working example demonstrating educational tooltips with definitions for AI, ML, and Deep Learning relationships. Shows proper implementation of the definitions pattern.assets/template/main.html: Standalone HTML diagram template with CDN linksassets/template/style.css: Responsive stylesheet with tooltip and print stylesassets/template/script.js: Interactive venn.js initialization with tooltipsassets/template/index.md: MkDocs integration templateassets/template/metadata.json: Dublin Core metadata templateUser Request: "Create a Venn diagram comparing dogs and cats"
Generated Data:
var sets = [
{sets: ['Dogs'], size: 100},
{sets: ['Cats'], size: 100},
{sets: ['Dogs', 'Cats'], size: 40}
];
var colorScheme = [
{set: 'Dogs', color: '#667eea'},
{set: 'Cats', color: '#764ba2'}
];
Set Relationships:
User Request: "Show the overlap between AI, Machine Learning, and Data Science"
Generated Data:
var sets = [
{sets: ['AI'], size: 120},
{sets: ['Machine Learning'], size: 100},
{sets: ['Data Science'], size: 110},
{sets: ['AI', 'Machine Learning'], size: 70},
{sets: ['AI', 'Data Science'], size: 60},
{sets: ['Machine Learning', 'Data Science'], size: 65},
{sets: ['AI', 'Machine Learning', 'Data Science'], size: 50}
];
var colorScheme = [
{set: 'AI', color: '#667eea'},
{set: 'Machine Learning', color: '#764ba2'},
{set: 'Data Science', color: '#f093fb'}
];
// Educational tooltips
var definitions = {
'AI': 'Systems that simulate human intelligence and decision-making',
'Machine Learning': 'Algorithms that learn patterns from data without explicit programming',
'Data Science': 'Field combining statistics, analysis, and domain expertise to extract insights',
'AI,Machine Learning': 'ML is a core approach within AI for building intelligent systems',
'AI,Data Science': 'AI techniques applied to data analysis and predictive modeling',
'Data Science,Machine Learning': 'ML provides the algorithms that data scientists use for analysis',
'AI,Data Science,Machine Learning': 'The intersection where intelligent systems learn from data'
};
function getDefinition(sets) {
var key = sets.sort().join(',');
return definitions[key] || sets.join(" ā© ");
}
Set Relationships:
User Request: "Compare Python, JavaScript, and Java programming languages"
Generated Data:
var sets = [
{sets: ['Python'], size: 100},
{sets: ['JavaScript'], size: 100},
{sets: ['Java'], size: 100},
{sets: ['Python', 'JavaScript'], size: 45},
{sets: ['Python', 'Java'], size: 40},
{sets: ['JavaScript', 'Java'], size: 35},
{sets: ['Python', 'JavaScript', 'Java'], size: 25}
];
var colorScheme = [
{set: 'Python', color: '#4ECDC4'},
{set: 'JavaScript', color: '#FFE66D'},
{set: 'Java', color: '#FF6B6B'}
];
Set Relationships:
This skill works well with other intelligent textbook skills:
/docs/glossary.md first for ISO 11179-compliant definitions to use in tooltips. This ensures consistency across the textbook and reinforces glossary terms through interactive hover experiences.Best Practice: When creating Venn diagrams for an existing textbook project, always check the glossary first. This creates a cohesive learning experience where glossary terms are reinforced through multiple touchpoints (definitions, diagrams, quizzes).
v1.0 - Initial release