AntV Infographic Preview for VSCode
A Visual Studio Code extension that renders AntV Infographic visualizations directly in your Markdown preview.
Features
- 📊 Live Preview: See your infographics render in real-time as you edit
- 🎨 Theme Support: Automatically adapts to VSCode's light and dark themes
- 📦 Offline Ready: All dependencies bundled - no CDN or internet required
- 🔒 Secure: Fully compliant with VSCode's strict Content Security Policy
- ⚡ Fast: Optimized rendering with smart caching and updates
Installation
From VSIX File
- Download the
.vsix file from the releases page
- Open VSCode
- Go to Extensions view (Cmd+Shift+X / Ctrl+Shift+X)
- Click the "..." menu at the top right
- Select "Install from VSIX..."
- Choose the downloaded
.vsix file
From Source
git clone <repository-url>
cd infographic-vscode-extension
npm install
npm run build
npm run package
Then install the generated .vsix file using the steps above.
Usage
Create infographic visualizations in your Markdown files using code blocks with the infographic language identifier:
Example 1: Simple Process Flow
```infographic
infographic list-row-simple-horizontal-arrow
data
items
- label Step 1
desc Initialize
- label Step 2
desc Process
- label Step 3
desc Complete
```
Example 2: Growth Metrics with Icons
```infographic
infographic list-row-horizontal-icon-arrow
data
title Customer Growth Engine
desc Multi-channel acquisition strategy
items
- label Lead Generation
value 18.6
desc Content marketing and outreach
icon company-021_v1_lineal
- label Conversion
value 12.4
desc Lead scoring and automation
icon antenna-bars-5_v1_lineal
- label Retention
value 32.1
desc Customer success programs
icon activities-037_v1_lineal
```
Example 3: Organizational Structure
```infographic
infographic list-column-vertical-icon
data
title Product Team
desc Engineering Organization
items
- label Product Management
icon company-021_v1_lineal
children
- label Strategy
desc Product roadmap and planning
- label Execution
desc Feature delivery
- label Engineering
icon antenna-bars-5_v1_lineal
children
- label Frontend
desc User interface
- label Backend
desc Services and APIs
```
Syntax Reference
Basic Structure
All infographics follow this basic pattern:
infographic [template-name]
data
title [Optional title]
desc [Optional description]
items
- label [Item label]
desc [Item description]
value [Optional numeric value]
icon [Optional icon name]
Available Templates
list-row-simple-horizontal-arrow - Simple horizontal process flow
list-row-horizontal-icon-arrow - Horizontal flow with icons and values
list-column-vertical-icon - Vertical list with hierarchical structure
For more templates and detailed syntax, visit the AntV Infographic Documentation.
Design Customization
You can customize the design using the design block:
infographic list-row-horizontal-icon-arrow
design
structure default
gap 12
item card
showIcon true
data
items
- label Example
desc Description
Theme Customization
Apply custom themes using the theme block:
infographic list-row-horizontal-icon-arrow
theme
colorPrimary #1890ff
palette #1890ff #52c41a #faad14
data
items
- label Example
desc Description
Error Handling
The extension provides helpful error messages when:
- Syntax is invalid or incomplete
- Template names are not recognized
- Required data is missing
Errors are displayed directly in the preview pane with details about what went wrong.
Theme Support
The extension automatically adapts to your VSCode theme:
- Light themes: Clean, bright appearance
- Dark themes: Comfortable dark mode rendering
- High contrast: Enhanced borders and visibility
- Smart Caching: Infographics are only re-rendered when syntax changes
- Efficient Updates: Live preview updates use debouncing to prevent excessive rendering
- Memory Management: Automatic cleanup of removed infographics
Troubleshooting
Infographic Not Rendering
- Check that the code block language is set to
infographic
- Verify your syntax follows the AntV Infographic format
- Look for error messages in the preview pane
- Try closing and reopening the Markdown preview
Preview Not Updating
- Make sure the Markdown preview is open
- Try refreshing the preview (close and reopen)
- Check VSCode's output panel for extension errors
CSP Errors
This extension is fully CSP-compliant. If you see CSP errors:
- Ensure you're using the latest version of the extension
- Check that no other extensions are interfering
- Report the issue on GitHub with reproduction steps
Technical Details
Architecture
- Markdown-it Plugin: Transforms infographic code blocks into placeholder containers
- Preview Script: Initializes and renders infographic instances in the webview
- Bundled Library: Includes @antv/infographic library for offline functionality
Security
- No external CDN dependencies
- No dynamic script execution
- Fully compliant with VSCode's strict CSP
- All resources bundled within extension package
Dependencies
- @antv/infographic - The core rendering library
- Webpack bundled for browser compatibility
Development
Building from Source
# Install dependencies
npm install
# Build for development (with watch mode)
npm run watch
# Build for production
npm run build
# Package as VSIX
npm run package
Testing Locally
- Open the project in VSCode
- Press F5 to launch Extension Development Host
- Open or create a Markdown file
- Add infographic code blocks
- Open the Markdown preview
Project Structure
├── src/
│ ├── extension.ts # Extension entry point
│ ├── markdown-it-plugin.ts # Markdown-it plugin
│ ├── preview.ts # Preview script
│ └── measury-stub.js # Browser-compatible text measurement
├── media/
│ └── infographic.css # Preview styles
├── dist/ # Compiled output
├── package.json # Extension manifest
└── webpack.config.js # Build configuration
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
MIT
Resources
Changelog
0.1.0 (Initial Release)
- ✅ Markdown preview rendering for infographic code blocks
- ✅ Bundled @antv/infographic library
- ✅ Theme support (light, dark, high contrast)
- ✅ Live preview updates
- ✅ Error handling and user feedback
- ✅ CSP compliant implementation
Support
If you encounter any issues or have suggestions, please open an issue on GitHub.