mod bar_chart;
mod chart_builder;
mod chart_renderer;
mod dashboard_integration;
mod line_chart;
mod pie_chart;
pub use bar_chart::{BarChart, BarChartBuilder, BarOrientation};
pub use chart_builder::{Chart, ChartBuilder, ChartData, ChartType, LegendPosition};
pub use chart_renderer::ChartRenderer;
pub use dashboard_integration::{DashboardBarChart, DashboardLineChart, DashboardPieChart};
pub use line_chart::{DataSeries, LineChart, LineChartBuilder};
pub use pie_chart::{PieChart, PieChartBuilder, PieSegment};
use crate::error::PdfError;
use crate::page::Page;
pub trait ChartExt {
fn add_chart(
&mut self,
chart: &Chart,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<(), PdfError>;
fn add_bar_chart(
&mut self,
chart: &BarChart,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<(), PdfError>;
fn add_pie_chart(
&mut self,
chart: &PieChart,
x: f64,
y: f64,
radius: f64,
) -> Result<(), PdfError>;
fn add_line_chart(
&mut self,
chart: &LineChart,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<(), PdfError>;
}
impl ChartExt for Page {
fn add_chart(
&mut self,
chart: &Chart,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<(), PdfError> {
let renderer = ChartRenderer::with_coordinate_system(self.coordinate_system());
renderer.render_chart(self, chart, x, y, width, height)
}
fn add_bar_chart(
&mut self,
chart: &BarChart,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<(), PdfError> {
let renderer = ChartRenderer::with_coordinate_system(self.coordinate_system());
renderer.render_bar_chart(self, chart, x, y, width, height)
}
fn add_pie_chart(
&mut self,
chart: &PieChart,
x: f64,
y: f64,
radius: f64,
) -> Result<(), PdfError> {
let renderer = ChartRenderer::with_coordinate_system(self.coordinate_system());
renderer.render_pie_chart(self, chart, x, y, radius)
}
fn add_line_chart(
&mut self,
chart: &LineChart,
x: f64,
y: f64,
width: f64,
height: f64,
) -> Result<(), PdfError> {
let renderer = ChartRenderer::with_coordinate_system(self.coordinate_system());
renderer.render_line_chart(self, chart, x, y, width, height)
}
}