d3rs/
lib.rs

1//! # d3rs - D3.js-inspired plotting library for GPUI
2//!
3//! A Rust plotting library that brings D3.js concepts to GPUI using idiomatic Rust patterns.
4//!
5//! ## Features
6//!
7//! - **Scales**: Linear, log, power, symlog, quantize, quantile, threshold scales
8//! - **Axes**: Four orientations (Top, Right, Bottom, Left) with customizable formatting
9//! - **Colors**: RGB/HSL with interpolation and categorical schemes
10//! - **Shapes**: Bars, lines, areas, scatter plots, arcs, pies, symbols, stacks
11//! - **Curves**: Linear, step, basis, cardinal, catmull-rom, monotone, natural
12//! - **Grids**: Dots and lines at tick intersections
13//! - **Legends**: Configurable position and formatting
14//! - **Arrays**: Statistics, search, binning, transformations (d3-array)
15//! - **Interpolation**: Numeric, color (HSL/LAB/HCL/Cubehelix), transform, string, zoom (d3-interpolate)
16//! - **Contours**: Marching squares, density estimation (d3-contour)
17//! - **Fetch**: CSV/TSV/JSON parsing utilities (d3-fetch)
18//! - **Format**: Number formatting with SI prefixes, locales (d3-format)
19//!
20//! ## Example
21//!
22//! ```rust,no_run
23//! use d3rs::scale::{LinearScale, Scale};
24//!
25//! let scale = LinearScale::new()
26//!     .domain(0.0, 100.0)
27//!     .range(0.0, 500.0);
28//!
29//! let output = scale.scale(50.0); // 250.0
30//! ```
31
32#![cfg_attr(feature = "gpui", recursion_limit = "512")]
33
34pub mod array;
35pub mod brush;
36pub mod color;
37pub mod ease;
38pub mod format;
39pub mod interpolate;
40pub mod scale;
41pub mod time;
42pub mod zoom;
43// Note: axis, grid, and text modules are excluded from test builds due to
44// a known gpui_macros proc macro stack overflow issue in debug compilation.
45// See: https://github.com/rust-lang/rust - the proc macro crashes with SIGBUS
46// when parsing complex closures in the canvas! macro during debug builds.
47// Release builds work fine. Tests can be run with --no-default-features.
48#[cfg(all(feature = "gpui", not(test)))]
49pub mod axis;
50pub mod contour;
51pub mod delaunay;
52pub mod fetch;
53pub mod geo;
54#[cfg(all(feature = "gpui", not(test)))]
55pub mod grid;
56pub mod legend;
57pub mod polygon;
58pub mod quadtree;
59pub mod random;
60pub mod shape;
61#[cfg(all(feature = "gpui", not(test)))]
62pub mod surface;
63pub mod timer;
64pub mod transition;
65#[cfg(all(feature = "gpui", not(test)))]
66pub mod text;
67
68/// Prelude module for convenient imports
69pub mod prelude {
70    #[cfg(all(feature = "gpui", not(test)))]
71    pub use crate::axis::{render_axis, AxisConfig, AxisOrientation, AxisTheme, DefaultAxisTheme};
72    pub use crate::color::{ColorScheme, D3Color};
73    #[cfg(all(feature = "gpui", not(test)))]
74    pub use crate::grid::{render_grid, GridConfig};
75    pub use crate::scale::{LinearScale, LogScale, Scale};
76    #[cfg(all(feature = "gpui", not(test)))]
77    pub use crate::shape::{
78        render_bars, render_line, render_scatter, BarConfig, BarDatum, CurveType, LineConfig,
79        LinePoint, ScatterConfig, ScatterPoint,
80    };
81    #[cfg(all(feature = "gpui", not(test)))]
82    pub use crate::surface::{
83        render_surface, ColorScaleType, SurfaceConfig, SurfaceData, SurfaceElement,
84    };
85}