1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
//! # Shape Viz Core
//!
//! High-performance GPU-accelerated charting library with modular layer architecture.
//!
//! ## Architecture Overview
//!
//! Shape Viz Core is built around a modular layer system where each visual component
//! (range bars, grid, axes, indicators) is implemented as a separate layer that
//! can be composed together to create complex charts.
//!
//! ### Core Components
//!
//! - **Renderer**: GPU-accelerated rendering engine using WGPU
//! - **Layers**: Modular rendering components (range bars, grid, axes, etc.)
//! - **Viewport**: Coordinate system and transformation management
//! - **Data**: Efficient data structures for generic time series
//! - **Themes**: Professional styling and color schemes
//!
//! ## Example Usage
//!
//! ```rust,no_run
//! use shape_viz_core::{Chart, ChartConfig, ChartData, Series};
//! use shape_viz_core::layers::{CandlestickLayer, GridLayer, PriceAxisLayer};
//! use std::any::Any;
//!
//! #[derive(Debug)]
//! struct SimpleSeries {
//! name: String,
//! x: Vec<f64>,
//! y: Vec<f64>,
//! }
//!
//! impl Series for SimpleSeries {
//! fn name(&self) -> &str { &self.name }
//! fn len(&self) -> usize { self.x.len() }
//! fn get_x(&self, index: usize) -> f64 { self.x[index] }
//! fn get_y(&self, index: usize) -> f64 { self.y[index] }
//! fn get_x_range(&self) -> (f64, f64) {
//! (*self.x.first().unwrap(), *self.x.last().unwrap())
//! }
//! fn get_y_range(&self, _x_min: f64, _x_max: f64) -> (f64, f64) {
//! let min = self.y.iter().cloned().fold(f64::INFINITY, f64::min);
//! let max = self.y.iter().cloned().fold(f64::NEG_INFINITY, f64::max);
//! (min, max)
//! }
//! fn find_index(&self, x: f64) -> Option<usize> {
//! self.x.iter().position(|v| *v == x)
//! }
//! fn as_any(&self) -> &dyn Any { self }
//! }
//!
//! let config = ChartConfig::default();
//! let mut chart = pollster::block_on(Chart::new(config))?;
//!
//! // Add layers
//! chart.add_layer(Box::new(GridLayer::new()));
//! chart.add_layer(Box::new(CandlestickLayer::new()));
//! chart.add_layer(Box::new(PriceAxisLayer::new()));
//!
//! // Attach data
//! let series = SimpleSeries {
//! name: "demo".to_string(),
//! x: vec![1.0, 2.0, 3.0],
//! y: vec![10.0, 12.0, 11.0],
//! };
//! chart.set_data(ChartData::new(Box::new(series)))?;
//!
//! // Render frame
//! let image_data = pollster::block_on(chart.render())?;
//! # let _ = image_data;
//! # Ok::<(), Box<dyn std::error::Error>>(())
//! ```
pub use text_gpu as text;
// Re-export commonly used types
pub use ;
pub use ;
pub use ;
pub use ;
pub use Vec2;
pub use ;
pub use ;
pub use ;
pub use ;
// Re-export layer trait for external layer implementations
pub use Layer;