charton 0.4.1

A high-level, layered charting system for Rust, designed for Polars-first data workflows and multi-backend rendering.
Documentation
//! Charton is a powerful plotting library for Rust that provides first-class, native support
//! for Rust [Polars](https://github.com/pola-rs/polars), and offers an API similar to
//! Python's [Altair](https://altair-viz.github.io/), making it easy for users familiar with
//! declarative, instruction-based plotting to migrate. It also allows you to leverage existing
//! mature visualization ecosystems, such as Altair and [Matplotlib](https://matplotlib.org/).
//! By seamlessly integrating with [evcxr_jupyter](https://github.com/evcxr/evcxr), Charton
//! facilitates the creation of informative and aesthetically pleasing visualizations interactively,
//! making it especially well-suited for exploratory data analysis.

pub mod chart;
pub mod coordinate;
pub mod core;
pub mod datasets;
pub mod encode;
pub mod error;
pub mod facets;
pub mod mark;
pub mod render;
pub mod scale;
pub mod stats;
pub mod theme;
pub mod transform;
pub mod visual;

#[cfg(not(target_arch = "wasm32"))]
pub mod bridge;

pub mod prelude {
    pub use crate::core::data::{DataFrameSource, IntoChartonSource};
    pub use crate::datasets::load_dataset;
    pub use time::OffsetDateTime;

    pub use crate::encode::{
        Encoding, color::color, shape::shape, size::size, text::text, x::x, y::y, y2::y2,
    };

    pub use crate::chart::Chart;
    pub use crate::core::composite::LayeredChart;
    pub use crate::core::conversion::IntoLayered;
    pub use crate::scale::{Expansion, Scale};

    pub use crate::coordinate::CoordSystem;
    pub use crate::transform::{
        density_transform::{BandwidthType, DensityTransform, KernelType},
        window_transform::{WindowFieldDef, WindowOnlyOp, WindowTransform},
    };

    pub use crate::render::line_renderer::PathInterpolation;
    pub use crate::theme::Theme;
    pub use crate::visual::color::{ColorMap, ColorPalette, SingleColor};
    pub use crate::visual::shape::PointShape;

    #[cfg(not(target_arch = "wasm32"))]
    pub use crate::bridge::base::{Altair, Matplotlib, Plot, Visualization};
    #[cfg(not(target_arch = "wasm32"))]
    pub use crate::data; // Macro data!
}

/// Temporary column name used internally by Polars to avoid naming conflicts.
pub(crate) const TEMP_SUFFIX: &str = "__charton_temp_n9jh3z8";

/// Represents the floating-point precision used specifically for the rendering stage.
///
/// While data processing and coordinate transformations should be performed in `f64`
/// to maintain computational accuracy and prevent rounding errors, we convert to
/// `Precision` (f32) during the final draw calls for the following reasons:
///
/// 1. **GPU Hardware Native**: Modern Graphics APIs (WGPU, Metal) are optimized for `f32`.
///    Using `f32` for rendering structures allows direct GPU memory mapping.
///
/// 2. **Memory Efficiency**: Halves the memory footprint for large point sets (e.g., in
///    scatter plots) when passing data to the rendering backends.
///
/// 3. **SVG Size Reduction**: `f32` provides sufficient precision for screen-space
///    while keeping the generated XML string lengths shorter.
pub type Precision = f32;