[package]
name = "ggplot-rs"
version = "0.11.0"
edition = "2021"
# Only the explicit [[bin]] below is a binary; src/bin/load.rs is its module.
autobins = false
description = "A Rust implementation of ggplot2's Grammar of Graphics"
authors = ["Simon Müller <sm@data-zoo.de>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/sipemu/ggplot-rs"
homepage = "https://github.com/sipemu/ggplot-rs"
documentation = "https://docs.rs/ggplot-rs"
readme = "README.md"
keywords = ["ggplot2", "plotting", "dataviz", "charts", "grammar"]
categories = ["visualization", "science"]

# `rlib` for normal crate use; `cdylib` so `wasm-pack build --features wasm`
# can emit a browser module.
[lib]
crate-type = ["cdylib", "rlib"]

[dependencies]
# Use plotters' `ab_glyph` text backend instead of the default `ttf` (font-kit),
# so rendering needs no system fonts / fontconfig — we register a bundled font at
# render time. This is the default set minus `ttf`, plus `ab_glyph`.
plotters = { version = "0.3", default-features = false, features = [
    "bitmap_backend",
    "bitmap_encoder",
    "bitmap_gif",
    "svg_backend",
    "chrono",
    "image",
    "deprecated_items",
    "all_series",
    "all_elements",
    "full_palette",
    "colormaps",
    "ab_glyph",
] }
indexmap = "2"
rand = "0.8"
# Optional data-source adapters. Neither is needed for the core pipeline —
# they only provide `GGData` conversions for external frame types.
polars = { version = "0.46", features = ["lazy"], optional = true }
arrow = { version = "53", default-features = false, optional = true }
# Regression backend for stat_quantile / geom_smooth glm (issues #10, #11).
anofox-regression = { version = "0.5", optional = true }
faer = { version = "0.23", default-features = false, features = [
    "std",
    "linalg",
], optional = true }
# In-memory PNG encoding for `render_png`. Already pulled in transitively by
# plotters' bitmap backend, so this adds no extra compile cost.
image = { version = "0.24", default-features = false, features = ["png"] }
# CLI tool (`cli` feature): arg parsing + a bundled DuckDB engine for reading
# parquet/CSV and running SQL. Both are optional and off by default.
clap = { version = "4", features = ["derive"], optional = true }
duckdb = { version = "1", features = ["bundled"], optional = true }
# Theme-config parsing for the CLI (TOML/JSON).
serde = { version = "1", features = ["derive"], optional = true }
toml = { version = "0.8", optional = true }
serde_json = { version = "1", optional = true }
# Browser bindings (`wasm` feature): expose plotting to JavaScript.
wasm-bindgen = { version = "0.2", optional = true }

# On wasm, rand's RNG seeding needs the browser crypto API (getrandom `js`).
# Enables browser builds; ignored on every other target.
[target.'cfg(target_arch = "wasm32")'.dependencies]
getrandom = { version = "0.2", features = ["js"] }

[features]
# `polars` is on by default to preserve existing behaviour (prelude re-export +
# `impl GGData for polars::DataFrame`). Downstream crates that don't want the
# heavy polars tree can depend with `default-features = false`.
default = ["polars"]
polars = ["dep:polars"]
# Zero-copy-friendly input path for Arrow-native producers (e.g. DuckDB).
arrow = ["dep:arrow"]
# Regression-backed stats (stat_quantile, glm smooth) via anofox-regression.
regression = ["dep:anofox-regression", "dep:faer"]
# Serde-deserialisable theme config (theme::config::ThemeConfig).
serde = ["dep:serde"]
# Spatial layer: geom_sf over simple-features geometry (self-contained WKT
# parser — no extra dependencies).
sf = []
# Read GeoJSON into a plot-ready frame (geometry + properties). Adds serde_json.
geojson = ["sf", "dep:serde_json"]
# Browser (WASM) bindings: `crate::wasm::render_geo(spec) -> SVG`, driving the
# plotters-free SvgBackend. Pair with DuckDB-Wasm for spatial data in the browser.
wasm = ["sf", "dep:wasm-bindgen", "dep:serde_json"]
# `ggplot-rs` command-line tool: plot parquet files and DuckDB SQL from the shell.
# Includes `sf` so `--geom sf` can plot geometry from the DuckDB spatial extension.
cli = ["dep:clap", "dep:duckdb", "serde", "dep:toml", "dep:serde_json", "sf"]

# The CLI binary (built only with `--features cli`).
[[bin]]
name = "ggplot-rs"
path = "src/bin/ggplot.rs"
required-features = ["cli"]

[dev-dependencies]
criterion = "0.5"
proptest = "1"

# Criterion benchmarks for the build/stat/render hot paths.
[[bench]]
name = "pipeline"
harness = false

# All bundled examples build their input frames with the polars `df!` macro,
# so they only compile when the `polars` feature is enabled.
[[example]]
name = "gallery"
required-features = ["polars"]

# Spatial choropleth — needs the `sf` feature.
[[example]]
name = "spatial"
required-features = ["sf", "polars"]

# Polars-free: builds and runs with --no-default-features too.
[[example]]
name = "supplier_leadtime"

[[example]]
name = "scatter"
required-features = ["polars"]

[[example]]
name = "histogram"
required-features = ["polars"]

[[example]]
name = "bar_chart"
required-features = ["polars"]

[[example]]
name = "annotations"
required-features = ["polars"]

[[example]]
name = "color_palettes"
required-features = ["polars"]

[[example]]
name = "continuous_color"
required-features = ["polars"]

[[example]]
name = "coord_flip"
required-features = ["polars"]

[[example]]
name = "density"
required-features = ["polars"]

[[example]]
name = "faceted"
required-features = ["polars"]

[[example]]
name = "loess_smooth"
required-features = ["polars"]

[[example]]
name = "log_scale"
required-features = ["polars"]
