oxidize_pdf/dashboard/
scatter_plot.rs1use super::{
7 component::ComponentConfig, ComponentPosition, ComponentSpan, DashboardComponent,
8 DashboardTheme,
9};
10use crate::error::PdfError;
11use crate::graphics::Color;
12use crate::page::Page;
13
14#[derive(Debug, Clone)]
16pub struct ScatterPlot {
17 config: ComponentConfig,
19 data: Vec<ScatterPoint>,
21 options: ScatterPlotOptions,
23}
24
25impl ScatterPlot {
26 pub fn new(data: Vec<ScatterPoint>) -> Self {
28 Self {
29 config: ComponentConfig::new(ComponentSpan::new(6)), data,
31 options: ScatterPlotOptions::default(),
32 }
33 }
34}
35
36impl DashboardComponent for ScatterPlot {
37 fn render(
38 &self,
39 _page: &mut Page,
40 _position: ComponentPosition,
41 _theme: &DashboardTheme,
42 ) -> Result<(), PdfError> {
43 let _title = self.options.title.as_deref().unwrap_or("Scatter Plot");
45
46 Ok(())
56 }
57
58 fn get_span(&self) -> ComponentSpan {
59 self.config.span
60 }
61 fn set_span(&mut self, span: ComponentSpan) {
62 self.config.span = span;
63 }
64 fn preferred_height(&self, _available_width: f64) -> f64 {
65 300.0
66 }
67 fn component_type(&self) -> &'static str {
68 "ScatterPlot"
69 }
70 fn complexity_score(&self) -> u8 {
71 60
72 }
73}
74
75#[derive(Debug, Clone)]
77pub struct ScatterPoint {
78 pub x: f64,
79 pub y: f64,
80 pub size: Option<f64>,
81 pub color: Option<Color>,
82 pub label: Option<String>,
83}
84
85#[derive(Debug, Clone)]
87pub struct ScatterPlotOptions {
88 pub title: Option<String>,
89 pub x_label: Option<String>,
90 pub y_label: Option<String>,
91 pub show_trend_line: bool,
92}
93
94impl Default for ScatterPlotOptions {
95 fn default() -> Self {
96 Self {
97 title: None,
98 x_label: None,
99 y_label: None,
100 show_trend_line: false,
101 }
102 }
103}
104
105pub struct ScatterPlotBuilder;
107
108impl ScatterPlotBuilder {
109 pub fn new() -> Self {
110 Self
111 }
112 pub fn build(self) -> ScatterPlot {
113 ScatterPlot::new(vec![])
114 }
115}