| name | timeline-generator |
| description | This skill generates interactive timeline visualizations using the vis-timeline JavaScript library. Use this skill when users need to create historical timelines, project timelines, event sequences, or any chronological data visualization with optional category filtering. The skill creates a complete MicroSim package with HTML, CSS, JSON data, and documentation. |
Timeline Generator
Overview
This skill generates professional, interactive timeline visualizations using vis-timeline.js. Timelines are ideal for displaying chronological events with rich context including descriptions, notes, and category groupings. The skill creates a complete MicroSim package suitable for embedding in educational content or documentation sites built with MkDocs.
When to Use This Skill
Use this skill when users request:
- Historical timelines: Family histories, organizational milestones, historical periods
- Project timelines: Development phases, product roadmaps, release schedules
- Event sequences: Course schedules, curriculum timelines, process flows
- Category-based timelines: Multi-track timelines with filtering capabilities
- Interactive visualizations: Need for hover tooltips, clickable events, zoom/pan navigation
Common trigger phrases:
- "Create a timeline showing..."
- "Visualize the history of..."
- "Build an interactive timeline for..."
- "Show chronological events for..."
Workflow
Step 1: Gather Timeline Requirements
Before generating the timeline, collect information about:
Timeline content:
- What is the subject/title of the timeline?
- What time period does it cover?
- What are the specific events to display?
Event data (for each event):
- Event headline/title (required)
- Date (year, month, day - year is required)
- Description text (required)
- Category/group (optional, for filtering)
- Historical context notes (optional, for tooltips)
Category filtering:
- Ask: "Would you like category filter buttons in the viewer?"
- If yes, gather category names and colors
- If not provided, create logical categories from the event data
Integration context:
- Standalone page
- Embedded in MkDocs documentation
- Part of educational content
IMPORTANT: If the user has not provided a specific event list, prompt them:
"I'll create an interactive timeline for you. Please provide the events you'd like to include with:
- Event title/headline
- Date (at least the year)
- Description
- Category (optional)
- Any additional context notes for tooltips (optional)
Would you also like category filter buttons to allow viewing specific types of events?"
Step 2: Create Directory Structure
Create a new directory for the MicroSim following this pattern:
docs/sims/<timeline-name>/
├── main.html # Main visualization file
├── timeline.json # Event data in TimelineJS format
└── index.md # Documentation (if part of MkDocs)
Naming convention: Use kebab-case (lowercase with hyphens) for directory names that are descriptive and URL-friendly (e.g., project-history-timeline, course-schedule, family-heritage-timeline).
Step 3: Create timeline.json Data File
Generate a JSON file following this structure:
{
"title": "Timeline Title",
"events": [
{
"start_date": {
"year": "2024",
"month": "1",
"day": "15",
"display_date": "January 15, 2024"
},
"text": {
"headline": "Event Title",
"text": "Detailed description of the event."
},
"group": "Category Name",
"notes": "Additional context that appears in the tooltip."
}
]
}
Key data structure notes:
yearis required instart_datemonthanddayare optional (default to 1 if omitted)display_dateis optional (for custom date formatting)groupis the category used for filteringnotesprovides tooltip/hover text with additional context- All text fields support basic HTML formatting
Data preparation guidelines:
- Sort events chronologically (oldest to newest)
- Use consistent category names across related events
- Keep headlines concise (5-10 words)
- Provide substantive descriptions (2-4 sentences)
- Add historical context in notes for educational value
Step 4: Create main.html with vis-timeline
Generate the main HTML file with the following structure:
- HTML boilerplate with proper meta tags
- vis-timeline CDN imports:
- JS:
https://cdnjs.cloudflare.com/ajax/libs/vis-timeline/7.7.3/vis-timeline-graph2d.min.js - CSS:
https://cdnjs.cloudflare.com/ajax/libs/vis-timeline/7.7.3/vis-timeline-graph2d.min.css
- JS:
- Styled header with timeline title and subtitle
- Category filter controls (if requested)
- Timeline container div
- Info panel with legend and event details
- JavaScript implementation:
- Load timeline.json data
- Convert to vis-timeline format
- Create color scheme for categories
- Initialize timeline with options
- Implement category filtering
- Handle event selection for detail display
Key vis-timeline configuration elements:
// Color scheme for categories
const categoryColors = {
'Category 1': '#color1',
'Category 2': '#color2',
// ... more categories
};
// Convert JSON events to vis-timeline format
allItems = data.events.map((event, index) => {
const year = event.start_date.year;
const month = event.start_date.month || 1;
const day = event.start_date.day || 1;
const startDate = new Date(parseInt(year), month - 1, day);
return {
id: `event-${index}`,
content: event.text.headline,
start: startDate,
title: event.notes || event.text.headline,
className: event.group.replace(/\s+/g, '-').toLowerCase(),
style: `background-color: ${categoryColors[event.group]}; color: white;`,
category: event.group,
eventData: event
};
});
// Timeline options
const options = {
width: '100%',
height: '600px',
margin: { item: 20, axis: 40 },
orientation: 'top',
zoomMin: 1000 * 60 * 60 * 24 * 365 * 10, // 10 years
zoomMax: 1000 * 60 * 60 * 24 * 365 * 1200, // 1200 years
tooltip: {
followMouse: true,
template: function(item) {
return item.notes || '';
}
},
stack: true,
selectable: true
};
Important implementation features:
Category filtering: Filter button implementation
function filterCategory(category) { if (category === 'all') { timelineData.clear(); timelineData.add(allItems); } else { const filtered = allItems.filter(item => item.category === category); timelineData.clear(); timelineData.add(filtered); } timeline.fit(); }Event detail display: Show full event information on click
timeline.on('select', function(properties) { if (properties.items.length > 0) { showEventDetails(properties.items[0]); } });Color-coded events: Apply category colors to timeline items
Responsive tooltips: Show context notes on hover
Legend display: Visual guide for category colors
Design considerations:
- Use a professional color scheme (distinct, accessible colors)
- Provide clear visual hierarchy
- Ensure text readability against colored backgrounds
- Include hover effects for interactivity
- Make the layout responsive for different screen sizes
Step 5: Create index.md Documentation
If the timeline is part of a MkDocs site, create comprehensive documentation:
# [Timeline Title]
[Brief description of what this timeline visualizes]
[Run the [Timeline Name]](./main.html)
[View the Raw Timeline Data](timeline.json)
## Overview
[Detailed explanation of the timeline's purpose, content, and coverage]
## Features
### Interactive Elements
- **Zoom and Pan**: Click and drag to pan, scroll to zoom in/out
- **Event Details**: Click any event to see full details below the timeline
- **Hover Tooltips**: Hover over events to see historical context notes
- **Category Filtering**: Use filter buttons to view specific event categories
### Visual Design
- **Color-coded categories**: Each event category has a distinct color
- **Responsive layout**: Works on desktop, tablet, and mobile devices
- **Legend**: Visual guide showing category colors and meanings
## Data Structure
The timeline data is stored in `timeline.json` following this format:
[Include JSON structure example]
## Customization Guide
### Adding New Events
1. Open `timeline.json`
2. Add a new event object to the `events` array
3. Reload the page to see your changes
### Changing Colors
To modify category colors, edit the `categoryColors` object in `main.html`:
[Code example]
### Adjusting Time Range
To change the zoom limits, modify the `zoomMin` and `zoomMax` options:
[Code example]
## Technical Details
- **Timeline Library**: vis-timeline 7.7.3
- **Data Format**: TimelineJS-compatible JSON
- **Browser Compatibility**: Modern browsers (Chrome, Firefox, Safari, Edge)
- **Dependencies**: vis-timeline.js (loaded from CDN)
## Use Cases
This timeline pattern can be adapted for:
- Historical education
- Project planning and tracking
- Course schedules and curricula
- Organizational history
- Personal timelines and biographies
Documentation best practices:
- Provide clear usage instructions
- Include code examples for common customizations
- Explain the data format thoroughly
- Link to external resources (vis-timeline docs)
- Suggest related use cases
Step 6: Integrate into Navigation (MkDocs)
If using MkDocs, add the timeline to the navigation in mkdocs.yml:
nav:
- MicroSims:
- Introduction: sims/index.md
- [Timeline Name]: sims/[timeline-name]/index.md
- [Other sims...]: ...
Place the entry in a logical position based on:
- Related content (group similar visualizations)
- Alphabetical order
- Chronological order of creation
Step 7: Test and Validate
Before considering the timeline complete:
Data validation:
- Verify timeline.json is valid JSON
- Check all dates parse correctly
- Confirm all events have required fields
- Validate category names are consistent
Visual testing:
- Open
main.htmldirectly in browser - Test with
mkdocs serveif applicable - Check timeline spans entire date range
- Verify all events are visible and properly spaced
- Test on different screen sizes
- Open
Interactive testing:
- Zoom in/out to verify scale limits
- Pan across the full timeline
- Hover over events to check tooltips
- Click events to verify detail display
- Test category filter buttons (if present)
- Check "All Events" filter restores full view
Content review:
- Proofread all event text
- Verify historical accuracy
- Check that context notes provide value
- Ensure descriptions are complete
Browser compatibility:
- Test on Chrome, Firefox, Safari, Edge
- Verify CDN resources load correctly
- Check console for JavaScript errors
Best Practices
Data Preparation
- Date accuracy: Use precise dates when available
- Chronological order: Sort events in JSON for easier maintenance
- Consistent categories: Use standardized category names
- Rich context: Provide substantive descriptions and notes
- Source validation: Verify historical facts and dates
Category Design
- Limit categories: 3-6 categories works best for filtering
- Meaningful groupings: Categories should reflect natural divisions
- Balanced distribution: Aim for relatively even event distribution
- Clear naming: Use descriptive, non-overlapping category names
- Color accessibility: Choose colors with sufficient contrast
Visual Design
- Color coding: Use distinct, visually appealing colors
- Text readability: Ensure white text on colored backgrounds is clear
- Legend placement: Make the legend visible and understandable
- Responsive sizing: Timeline should work on all screen sizes
- Loading states: Consider showing a loading indicator
Documentation
- Usage examples: Show how to interact with the timeline
- Data format: Clearly document the JSON structure
- Customization: Provide code snippets for common changes
- Attribution: Credit data sources when appropriate
- Educational context: Explain why the timeline matters
MkDocs Integration
- Direct linking: Provide links to both main.html and timeline.json
- Iframe embedding: Can use iframe for inline display if desired
- Navigation placement: Group with related content
- Cross-references: Link to related pages or timelines
Common Variations
Simple Timeline (No Categories)
Omit the category filtering UI and use a single color:
const categoryColors = {
'Default': '#2d5016'
};
Vertical Timeline
Change orientation for a vertical layout:
options: {
orientation: 'left' // or 'right'
}
Range Events
For events with duration, add an end_date:
{
"start_date": {"year": "2020", "month": "1"},
"end_date": {"year": "2021", "month": "12"},
"text": {"headline": "Multi-year Project"}
}
Embedded Media
Add images or videos to events (requires additional configuration).
Troubleshooting
Timeline Not Displaying
Solution: Check browser console for errors, verify timeline.json loads correctly, ensure CDN resources are accessible.
Events Overlapping
Solution: Increase margin.item value in options or enable stack: true for automatic vertical stacking.
Zoom Too Fast/Slow
Solution: Adjust zoomMin and zoomMax values based on your date range.
Filter Buttons Not Working
Solution: Verify category names match exactly between JSON data and filter buttons, check JavaScript console for errors.
Dates Parsing Incorrectly
Solution: Ensure month values are 1-12, not 0-11. The conversion to JavaScript Date handles this in the code.
References
This skill uses the following assets and references:
Assets
- vis-timeline CDN:
- JS:
https://cdnjs.cloudflare.com/ajax/libs/vis-timeline/7.7.3/vis-timeline-graph2d.min.js - CSS:
https://cdnjs.cloudflare.com/ajax/libs/vis-timeline/7.7.3/vis-timeline-graph2d.min.css
- JS:
- No local assets required (vis-timeline loaded from CDN)
References
- vis-timeline Documentation
- TimelineJS3 Data Format (compatible structure)
- vis-timeline GitHub Repository
Example Implementation
See the timeline example at /docs/sims/timeline/ for a complete reference implementation showcasing McCreary family heritage timeline.
License
This skill is provided under the same license as the claude-skills repository. The vis-timeline library is licensed under Apache-2.0/MIT dual license.