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 TypeScript or JavaScript
  • 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 html2canvas or svg-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 PlotContour Plot
violin
violin
contour
contour
Stage ViewSegmented Doughnut
stage
stage
segmentedDoughnut
segmentedDoughnut
Bar RangeLine Range
barRange
barRange
lineRange
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

ggplot style demo
Example of scatter with ggplot-like styling


๐Ÿš€ Setup

1. Install dependencies

npm install

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

echart-ggplot-style