charton 0.5.7

A high-performance, layered charting system for Rust, featuring a flexible data core and multi-backend rendering.
Documentation
# Production Integration


For a visualization library to succeed in an industrial ecosystem, it must extend beyond local rendering. It must integrate seamlessly into CI/CD pipelines, support automated regression testing, and provide deterministic output across various deployment environments—whether that is a cloud-native microservice, a WASM-powered browser interface, or a static report generation tool.

## Automated Regression & Snapshot Testing


Visual libraries are notoriously difficult to test because the "correct" output is often subjective. Charton addresses this by implementing a Snapshot-Based Testing architecture.

- Binary Snapshotting: Since Charton generates SVGs or binary image buffers through defined backends, we can serialize the output of a chart specification into a reference file. During CI, the library renders the chart and compares the output byte-by-byte (or via fuzzy perceptual hashing) against the golden master.
- Deterministic Configuration: By forcing all layouts to rely on the `Theme` and `Coordinate` systems, we eliminate non-determinism caused by OS-specific font rendering or system-level float rounding, ensuring that a chart generated on a developer’s machine matches the production CI build exactly.

## CI/CD Pipeline Integration


Charton is engineered to be a "headless" citizen of the cloud. The bridge system (`matplotlib.rs`, `altair.rs`) and the core rendering pipeline are optimized for containerized environments:

- Minimal Footprint: By utilizing high-performance columnar data layouts, Charton ensures that memory overhead remains flat even when processing datasets that would crash standard plotting tools. This makes it ideal for running in restricted-resource container environments (e.g., AWS Lambda, K8s sidecars).
- Feature Flagging: The `composite.rs` implementation demonstrates how output formats (PNG, PDF, etc.) are controlled via `Cargo` features. This allows production builds to prune unnecessary dependencies, drastically reducing the binary size and attack surface in production environments.

## Deployment Strategies


When deploying Charton-powered services, we recommend three distinct patterns depending on the load:

| Deployment Pattern | Use Case | Implementation Strategy |
| :--- | :--- | :--- |
| **Edge Rendering (WASM)** | Interactive UI / Dashboards | Compile the core library to WASM for client-side rendering, minimizing server load. |
| **Headless Batch Service** | Automated Report Generation | Use a containerized Rust service to consume IPC data, render to SVG/PNG, and pipe to S3. |
| **Bridge-Integrated API** | Prototyping / Hybrid Apps | Utilize the Python bridge to leverage established libraries (Altair/Matplotlib) while maintaining data integrity via Rust’s polars types. |

## Semantic Validation in CI


The `Semantic Validation` pipeline described in our Error Registry is essential for production stability. Before a deployment is cleared:

- Schema Check: CI runners parse the user-provided ChartSpec and perform a static analysis to ensure all channels (X, Y, Color) are bound to valid data types.
- Bounds Audit: The pipeline evaluates the dataset range against the ScaleDomain. If the system detects potential data overflow or empty domains before rendering, the build fails immediately, preventing "blank chart" incidents in the production dashboard.

## Key Takeaways


Deterministic Outputs: Leverage snapshot testing to ensure that cross-environment chart generation yields identical visual results.

Resource Optimization: Use feature-gated builds and columnar data handling to ensure high-throughput rendering within containerized cloud environments.

Headless Capability: Design services for headless batch processing by treating the rendering engine as a pure, stateless function that transforms `Dataset` + `Theme` into a serialized visual artifact.