echart-ggplot-style
July 31, 2025 ยท View on GitHub
๐ High-quality, publication-ready charts using Apache ECharts, inspired by the aesthetics of ggplot2.
This project provides a set of reusable ECharts chart templates and themes that mimic the clean, minimal, and publication-ready style popularized by R's ggplot2.
๐ฅ Why this project?
While ggplot2 is the gold standard in R for beautiful statistical plots, many web-based dashboards and publications require interactive JavaScript visualizations. Apache ECharts is powerful but its default theme is not publication-focused.
This repo bridges that gap by:
- Offering custom ggplot-like themes for ECharts
- Providing reusable ECharts chart components in
TypeScriptorJavaScript - Creating high-resolution, vector-exportable charts suitable for scientific publication
๐งฐ Features
- ๐จ ggplot-style themes for ECharts
- ๐ Chart templates: line, bar, scatter, boxplot, violin, etc.
- ๐งโ๐ป Written in TypeScript with React & ECharts-for-React
- ๐ Export options: SVG / PNG / PDF (via
html2canvasorsvg-crowbar) - ๐ Beautiful typography, spacing, and grid control
- ๐ Web-ready, suitable for blog posts, papers, and reports
๐ฌ Note: Currently works with ECharts v6, which is not released yet. You need to clone and build ECharts locally. See Setup for instructions.
๐งช Available Custom Series
| Violin Plot | Contour Plot |
|---|---|
| violin | contour |
| Stage View | Segmented Doughnut |
|---|---|
| stage | segmentedDoughnut |
| Bar Range | Line Range |
|---|---|
| barRange | lineRange |
๐ฏ Each chart includes support for ggplot-style themes, hover interactions, and is SVG-friendly for high-quality export.
๐จ ggplot-Inspired Styling
All charts follow these ggplot-style design principles:
- โ Minimalist grid and axis lines
- โ Balanced white space and layout
- โ Scientific typography
- โ Publication-friendly color palettes
- โ Exportable to SVG for high-resolution reports
Example of scatter with ggplot-like styling
๐ Setup
1. Install dependencies
npm install
2. Build & link Apache ECharts v6 locally
Since ECharts v6 is still unreleased, youโll need to build and link it manually:
# Under apache/zrender
git checkout v6
npm install
npm run prepare
npm link
# Under apache/echarts
git checkout v6
npm install
npm link zrender
npm link
npm run prepare
npm run build
# In echarts-custom-series
cd custom-series/<series-name>
npm link echarts
๐ Development
Create a new custom series
npm run generate <seriesName>
Use camelCase for multi-word names:
โbarRange| โbar-range
๐งฑ Build
Build all custom series
npm run build
Build one series
npm run build <series-name>
Example:
npm run build violin
๐ผ๏ธ Generate Thumbnails
npm run thumbnail
# or only one
npm run thumbnail violin
These will appear in /screenshots and update the README preview.
๐ค Publish to npm
TODO: Coming soon.
๐ญ Roadmap
- Violin and density plots
- Line/Bar with ranges (confidence intervals)
- ggplot-style themes
- Boxplot, Beeswarm, Histogram
- Export helper: SVG / PNG / PDF
- Playground site with live editing
๐ฌ Contributing
Pull requests are welcome! You can contribute new custom series, themes, or export helpers.
๐ชช License
MIT ยฉ 2025 # echart-ggplot-style
