liecharts 0.1.0-beta.1

A Rust charting library with PNG and SVG rendering support
Documentation

LieCharts

Crates.io Documentation Crates.io

Overview

A Rust library for creating charts, inspired by ECharts.

Features

  • Multiple Chart Types: Line, Bar, Pie, Area, Scatter, Radar, Gauge, Candlestick, Polar Bar, Polar Scatter, Table.
  • Double Rendering Engines: PNG/JPEG and SVG.
  • Theme System: customizable themes.
  • JSON Configuration: configurable JSON configuration.
  • Complex Layouts: Mixed charts, multiple Y axes, and more.

Usage

Builder API (Recommended)

use liecharts::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    ChartBuilder::new()
        .with_title(TitleOption::new("月度趋势").subtext("2024年"))
        .with_x_axis(AxisOption::category().data(["1月", "2月", "3月"]))
        .with_y_axis(AxisOption::value())
        .with_series(SeriesOption::Bar(BarSeriesOption::new(
            "销售额",
            vec![120.0, 200.0, 150.0],
        )))
        .build(800, 600)?
        .render_to_image("chart.png")?;
    Ok(())
}

JSON Configuration

use liecharts::ChartBuilder;

let json = r#"{
    "title": { "text": "月度趋势" },
    "xAxis": [{ "type": "category", "data": ["1月", "2月", "3月"] }],
    "yAxis": [{ "type": "value" }],
    "series": [{ "type": "bar", "name": "销售额", "data": [120, 200, 150] }]
}"#;

ChartBuilder::from_option_json(json)?
    .build(800, 600)?
    .render_to_image("chart.png")?;

Examples

Check the examples directory. Run with: cargo run --example <name>

Online Demo: https://zzzdong.github.io/liecharts

License

Apache-2.0