Skip to main content

esoc_chart/
lib.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! # esoc-chart
3//!
4//! High-level charting API for data visualization, built on esoc-gfx.
5//! Provides matplotlib-equivalent plotting for Rust ML workflows.
6//!
7//! ## New Grammar-of-Graphics API
8//!
9//! The new API provides 3 levels:
10//! - **Express**: one-liner functions (`scatter`, `line`, `bar`)
11//! - **Grammar**: composable `Chart`/`Layer`/`Encoding` types
12//! - **Scene Graph**: direct access via `esoc-scene`
13
14#![warn(missing_docs)]
15#![deny(unsafe_code)]
16#![allow(clippy::doc_markdown)]
17
18// ── Legacy API (preserved for backward compatibility) ────────────
19#[allow(deprecated)]
20pub mod axes;
21pub mod axis;
22#[allow(deprecated)]
23pub mod chart;
24pub mod error;
25pub mod figure;
26#[allow(deprecated)]
27pub mod legend;
28pub mod render;
29pub mod series;
30#[allow(deprecated)]
31pub mod theme;
32
33#[cfg(feature = "scry-learn")]
34#[allow(deprecated)]
35pub mod interop;
36
37// ── New Grammar-of-Graphics API ──────────────────────────────────
38pub mod compile;
39pub mod express;
40pub mod grammar;
41pub mod new_theme;
42
43/// Legacy re-exports.
44#[allow(deprecated)]
45pub mod prelude {
46    pub use crate::axes::Axes;
47    pub use crate::axis::{AxisConfig, AxisPosition, Scale};
48    pub use crate::chart::{
49        BarSeries, BoxPlotSeries, ErrorBarSeries, HeatmapSeries, HistogramSeries, LineSeries,
50        ScatterSeries,
51    };
52    pub use crate::error::{ChartError, Result};
53    pub use crate::figure::Figure;
54    pub use crate::legend::LegendPosition;
55    pub use crate::series::SeriesRenderer;
56    pub use crate::theme::Theme;
57
58    // Re-export key gfx types for convenience
59    pub use esoc_gfx::color::Color;
60    pub use esoc_gfx::style::{DashPattern, Fill, Stroke};
61
62    #[cfg(feature = "scry-learn")]
63    pub use crate::interop::*;
64}
65
66/// New API re-exports.
67pub mod v2 {
68    #[allow(deprecated)]
69    pub use crate::express::{
70        area, bar, boxplot, grouped_bar, heatmap, heatmap_ref, histogram, line, pie, pie_labeled,
71        scatter, stacked_bar, treemap,
72    };
73    pub use crate::grammar::annotation::Annotation;
74    pub use crate::grammar::chart::Chart;
75    pub use crate::grammar::coord::CoordSystem;
76    // nominal() and quantitative() removed — they are deprecated.
77    // Use Encoding struct directly instead.
78    pub use crate::grammar::facet::{Facet, FacetScales};
79    pub use crate::grammar::layer::{Layer, MarkType};
80    pub use crate::grammar::position::Position;
81    pub use crate::grammar::stat::Stat;
82    pub use crate::new_theme::{NewTheme, Theme};
83
84    // Re-export scene/color types
85    pub use esoc_color::{Color, OkLab, OkLch, Palette};
86    pub use esoc_scene::SceneGraph;
87}