
Charton: A columnar-native plotting library for Rust (Polars-friendly)
Charton is a columnar-native plotting library designed to keep memory layouts as close to Apache Arrow as possible, allowing for near-zero-copy integration.
Here’s the core of how it handles data:
pub enum ColumnVector {
Boolean { data: Vec<bool>, validity: Option<Vec<u8>> },
Int8 { data: Vec<i8>, validity: Option<Vec<u8>> },
// ... handles all int/float types
String { data: Vec<String>, validity: Option<Vec<u8>> },
Categorical { keys: Vec<u32>, values: Vec<String>, validity: Option<Vec<u8>> },
Datetime { data: Vec<i64>, validity: Option<Vec<u8>>, timezone: Option<String> },
}
// ... other types
And the Dataset structure ensures alignment:
pub struct Dataset {
schema: AHashMap<String, usize>,
columns: Vec<Arc<ColumnVector>>,
row_count: usize,
}
The load_polars_df! macro is ready to use, and the Altair-style declarative API makes building layered charts intuitively.
The roadmap is to go full native Arrow and eventually integrate DataFusion for a "SQL-to-chart" workflow. It’s still early days, so if you’re doing data analysis in Rust, I’d love to get your thoughts or feedback on the API.