https://github.com/yuankunzhang/charming

A visualization library for Rust

https://github.com/yuankunzhang/charming

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (6.9%) to scientific vocabulary

Keywords

chart data-science rust visualization webassembly
Last synced: 5 months ago · JSON representation

Repository

A visualization library for Rust

Basic Info
  • Host: GitHub
  • Owner: yuankunzhang
  • License: apache-2.0
  • Language: Rust
  • Default Branch: main
  • Homepage:
  • Size: 2.77 MB
Statistics
  • Stars: 2,373
  • Watchers: 12
  • Forks: 96
  • Open Issues: 13
  • Releases: 0
Topics
chart data-science rust visualization webassembly
Created over 2 years ago · Last pushed 7 months ago
Metadata Files
Readme Changelog License

README.md

Charming - A Rust Visualization Library

crates.io docs.rs

Charming is a powerful and versatile chart rendering library for Rust that leverages the power of Apache ECharts to deliver high-quality data visualizations. Built with the Rust programming language, this library aims to provide the Rust ecosystem with an intuitive and effective way to generate and visualize charts, using a declarative and user-friendly API.

Highlights:

  • Easy-to-use, declaritive API.
  • Abundant chart types with rich and customizable chart themes and styles.
  • Ready to use in WebAssembly environments.
  • Rendering to multiple formats, including HTML, SVG, PNG, JPEG, GIF, WEBP, PNM, TIFF, TGA, DDS, BMP, ICO, HDR, OPENEXR, FARBFELD, AVIF, and QOI.

Themes

Default

Default

Dark

Dark

Vintage

Vintage

Westeros

Westeros

Essos

Essos

Wonderland

Wonderland

Walden

Walden

Chalk

Chalk

Infographic

Infographic

Macarons

Macarons

Roma

Roma

Shine

Shine

Purple Passion

Purple Passion

Halloween

Halloween

Future versions of Charming will support custom themes.

Basic Usage

Add charming as a dependency:

sh $ cargo add charming

Refer to the documentation of the Chart struct for how to create a chart with various components.

Once you create a chart, you can render it into various format. Charming provides three types of renderers:

  • HTML renderer: HtmlRenderer renders a chart into an HTML fragments and offloads the actual rendering to user's web browser for an interactive, seamless experience. This renderer is useful when you want to render a chart on the client side, e.g., in a web application.
  • Image renderer: ImageRenderer renders a chart into an image file. This renderer makes use of an embed deno_core engine to execute the JavaScript code of Echarts and generate an image file. This renderer is disabled by default, and you need to enable the ssr (Server-Side Rendering) feature to use it.
  • WASM renderer: WasmRenderer renders a chart in a WebAssembly runtime. This renderer is disabled by default, and you need to enable the wasm feature to use it. Note that the wasm feature and ssr feature are mutually exclusive.

Here is an example of drawing a simple pie chart into an SVG file:

```rust use charming::{ component::Legend, element::ItemStyle, series::{Pie, PieRoseType}, Chart, ImageRenderer };

fn main() { let chart = Chart::new() .legend(Legend::new().top("bottom")) .series( Pie::new() .name("Nightingale Chart") .rosetype(PieRoseType::Radius) .radius(vec!["50", "150"]) .center(vec!["50%", "50%"]) .itemstyle(ItemStyle::new().border_radius(8)) .data(vec![ (40.0, "rose 1"), (38.0, "rose 2"), (32.0, "rose 3"), (30.0, "rose 4"), (28.0, "rose 5"), (26.0, "rose 6"), (22.0, "rose 7"), (18.0, "rose 8"), ]), );

let mut renderer = ImageRenderer::new(1000, 800);
renderer.save(&chart, "/tmp/nightingale.svg");

} ```

This code creates the following SVG file:

As another example, the code file gallery/src/dataset/encodeandmatrix.rs draws a complex chart with four sub-charts:

MSRV

We do not provide any minimal supported Rust version and it is usually the latest stable release as the deno dependency upgrades their version very frequently.

Crate Feature Flags

The following feature flags are available, note that ssr and wasm can't be used together:

  • ssr - Enables the ImageRenderer, which provides the capability to generate image files.
  • ssr-raster Enables raster support to the ImageRenderer (png, jpg, etc.)
  • wasm - Enables the WasmRenderer, which provides the capability to render charts in WebAssembly runtime.

Renderers

```rs // Use HtmlRenderer. use charming::HtmlRenderer;

// Chart dimension 1000x800. let renderer = HtmlRenderer::new("my charts", 1000, 800); // Render the chart as HTML string. let html_str = renderer.render(&chart).unwrap(); // Save the chart as HTML file. renderer.save(&chart, "/tmp/chart.html").unwrap();

// Use ImageRenderer. The ssr feature needs to be enabled. use charming::{ImageRenderer, ImageFormat};

// Chart dimension 1000x800. let mut renderer = ImageRenderer::new(1000, 800); // Render the chart as SVG string. renderer.render(&chart).unwrap(); // Render the chart as PNG bytes. renderer.renderformat(ImageFormat::Png, &chart).unwrap(); // Save the chart as SVG file. renderer.save(&chart, "/tmp/chart.svg").unwrap(); // Save the chart as PNG file. renderer.saveformat(ImageFormat::Png, &chart, "/tmp/chart.png");

// Use WasmRenderer. The wasm feature needs to be enabled. use charming::WasmRenderer;

// Chart dimension 1000x800. let renderer = WasmRenderer::new(1000, 800); // Render the chart in the WebAssembly runtime renderer.render("my-chart-id", &chart).unwrap(); ```

Themes

Charming supports a number of themes out of the box. You can use the Theme enum to specify a theme for your chart. For instance, the following code snippet shows how to use the Westeros theme:

```rust use charming::{Chart, ImageRenderer}; use charming::theme::Theme; use charming::component::Title;

ImageRenderer::new(1000, 800).theme(Theme::Westeros).save( &Chart::new().title(Title::new().text("Westeros")), "/tmp/westeros.svg", ); ```

Future versions of Charming will support custom themes.

Gallery

Here are some selected chart examples. Click on any single chart to view its source code file.

You can also clone the repo and run cargo run --bin gallery to view the interactive charts on the rendered HTML page.

Bar Charts

Bar with Background Basic Bar Radial Polar Bar Label Position Set Style of Single Bar Stacked Column Tangential Polar Bar Waterfall World Population

Boxplot Charts

Boxplot Light Velocity Multiple Categories

Candlestick Charts

Basic Candlestick Shanghai Index

Funnel Charts

Funnel Chart Multiple Funnels

Gauge Charts

Gauge Barometer Gauge Basic Gauge Simple

Graph Charts

Hide Overlapped Label Les Miserables

Heatmap Charts

Heatmap on Cartesian

Line Charts

Area Pieces Basic Area Basic Line Confidence Band Data Transform Filter Distribution of Electricity Gradient Stacked Area Large Scale Area Line Gradient Rainfall Rainfall Vs. Evaporation Smoothed Line Stacked Area Stacked Line Step Line Temperature Change Two Value-Axes in Polar

Parallel Charts

Basic Parallel Parallel AQI

Pie Charts

Nightingale Nightingale Referer of a Website

Radar Charts

Basic Radar Multiple Radar Proportion of Browsers

Sankey Charts

Basic Sankey Node Align Left Sankey Sankey Orient Vertical

Scatter Charts

Anscombe Quartet Basic Scatter Bubble Chart Effect Scatter Punch Card of Github

Calendar Charts

Simple Calendar Heatmap Calendar

Sunburst Charts

Drink Flavors

Theme River Charts

Theme River LastFM

Tree Charts

From Left to Right Tree Multiple Trees

Custom Charts

Custom Error Bar/Candle Stick

Owner

  • Name: Yuankun Zhang
  • Login: yuankunzhang
  • Kind: user
  • Location: Singapore

Coder.

GitHub Events

Total
  • Issues event: 30
  • Watch event: 550
  • Issue comment event: 118
  • Push event: 52
  • Pull request review event: 12
  • Pull request review comment event: 10
  • Pull request event: 102
  • Fork event: 35
  • Create event: 3
Last Year
  • Issues event: 30
  • Watch event: 550
  • Issue comment event: 118
  • Push event: 52
  • Pull request review event: 12
  • Pull request review comment event: 10
  • Pull request event: 102
  • Fork event: 35
  • Create event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 280
  • Total Committers: 23
  • Avg Commits per committer: 12.174
  • Development Distribution Score (DDS): 0.518
Past Year
  • Commits: 122
  • Committers: 13
  • Avg Commits per committer: 9.385
  • Development Distribution Score (DDS): 0.631
Top Committers
Name Email Commits
yuankunzhang f****a@g****m 135
LukaOber l****r@g****m 45
humphreylee 6****e 26
Paolo Barbolini p****i@m****t 13
Grey g****g@o****m 13
am@pa.dev am@p****v 9
Mason Ginter m****n@d****m 8
Daniel Santana d****a@g****m 5
Kuba Groblewski k****i@g****m 4
Joachim Schiele js@l****e 3
solitary_crow 1****u 3
Ben Lambert b****t@p****m 2
Nashwan Azhari a****n@i****m 2
Sam Heuck s****m@s****m 2
mbn-gy m****n@m****m 2
Alexander Jophus a****e@g****m 1
Chanyub.Park m****k@g****m 1
Gábor Szabó g****r@s****m 1
Mada997 c****2@g****m 1
Mikhail Nazarov m****v@y****u 1
Shun s****s@g****m 1
koopa1338 s****1@g****m 1
zishon z****u@q****m 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 64
  • Total pull requests: 157
  • Average time to close issues: 3 months
  • Average time to close pull requests: 16 days
  • Total issue authors: 41
  • Total pull request authors: 30
  • Average comments per issue: 1.95
  • Average comments per pull request: 0.69
  • Merged pull requests: 140
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 27
  • Pull requests: 130
  • Average time to close issues: 17 days
  • Average time to close pull requests: 10 days
  • Issue authors: 17
  • Pull request authors: 13
  • Average comments per issue: 1.74
  • Average comments per pull request: 0.6
  • Merged pull requests: 119
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • LukaOber (11)
  • humphreylee (4)
  • wangjiawen2013 (4)
  • pferreira8 (3)
  • moinmoti (2)
  • ngmisl (2)
  • tempbottle (2)
  • ginsolvibile (2)
  • tower120 (2)
  • G2GreenTea (1)
  • bioinformatist (1)
  • tqwewe (1)
  • structwafel (1)
  • edg-l (1)
  • Groni3000 (1)
Pull Request Authors
  • LukaOber (90)
  • humphreylee (21)
  • paolobarbolini (17)
  • yg0x01 (15)
  • cooljingle (14)
  • yuankunzhang (7)
  • samheuck (4)
  • qknight (2)
  • youngday (2)
  • KG32 (2)
  • jasoncg (2)
  • Mada997 (2)
  • renanrod4 (2)
  • zishon (2)
  • shunsock (2)
Top Labels
Issue Labels
question (3) enhancement (2) good first issue (1)
Pull Request Labels

Packages

  • Total packages: 3
  • Total downloads:
    • cargo 434,421 total
  • Total dependent packages: 2
    (may contain duplicates)
  • Total dependent repositories: 1
    (may contain duplicates)
  • Total versions: 17
  • Total maintainers: 3
crates.io: charming

A visualization library for Rust

  • Versions: 15
  • Dependent Packages: 2
  • Dependent Repositories: 1
  • Downloads: 422,312 Total
Rankings
Stargazers count: 4.4%
Forks count: 9.8%
Average: 16.3%
Dependent repos count: 16.5%
Dependent packages count: 18.2%
Downloads: 32.7%
Maintainers (1)
Last synced: 6 months ago
crates.io: charming_macros

Procedural macros used in charming

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 9,810 Total
Rankings
Dependent repos count: 21.3%
Dependent packages count: 28.2%
Average: 48.1%
Downloads: 94.8%
Maintainers (2)
Last synced: 6 months ago
crates.io: charming-fork-zephyr

A visualization library for Rust

  • Versions: 1
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 2,299 Total
Rankings
Dependent repos count: 27.1%
Dependent packages count: 35.9%
Average: 53.2%
Downloads: 96.5%
Maintainers (1)
Last synced: 6 months ago

Dependencies

.github/workflows/rust.yml actions
  • actions/checkout v3 composite
Cargo.lock cargo
  • 205 dependencies
charming/Cargo.lock cargo
  • 187 dependencies
Cargo.toml cargo
charming/Cargo.toml cargo
examples/Cargo.lock cargo
  • 316 dependencies
examples/Cargo.toml cargo
examples/dioxus-web-demo/Cargo.toml cargo
examples/leptos-demo/Cargo.toml cargo
examples/yew-demo/Cargo.toml cargo
gallery/Cargo.toml cargo