mod constants;
mod series;
mod structs;
use crate::format::FormatColor;
use crate::XlsxError;
pub use self::constants::*;
pub use self::series::*;
pub use self::structs::*;
use super::Workbook;
pub struct Chart<'a> {
pub(crate) _workbook: &'a Workbook,
pub(crate) chart: *mut libxlsxwriter_sys::lxw_chart,
}
impl<'a> Chart<'a> {
pub fn add_series(
&mut self,
categories: Option<&str>,
values: Option<&str>,
) -> Result<ChartSeries<'a>, XlsxError> {
let series = unsafe {
libxlsxwriter_sys::chart_add_series(
self.chart,
self._workbook.register_option_str(categories)?,
self._workbook.register_option_str(values)?,
)
};
Ok(ChartSeries {
_workbook: self._workbook,
chart_series: series,
})
}
pub fn add_title(&mut self, title: &str) -> Result<(), XlsxError> {
unsafe {
libxlsxwriter_sys::chart_title_set_name(
self.chart,
self._workbook.register_str(title)?,
);
}
Ok(())
}
}
pub struct ChartSeries<'a> {
pub(crate) _workbook: &'a Workbook,
pub(crate) chart_series: *mut libxlsxwriter_sys::lxw_chart_series,
}
#[derive(Copy, Clone, PartialEq, PartialOrd)]
pub struct ChartPattern {
pub fg_color: FormatColor,
pub bg_color: FormatColor,
pub chart_pattern: ChartPatternType,
}
#[derive(Copy, Clone, PartialEq, PartialOrd)]
pub struct ChartLine {
pub color: FormatColor,
pub none: bool,
pub width: f32,
pub dash_type: ChartDashType,
pub transparency: u8,
}
#[derive(Clone, PartialEq, PartialOrd)]
pub struct ChartFill {
pub color: FormatColor,
pub none: bool,
pub transparency: u8,
}
#[derive(Debug, Copy, Clone, PartialEq, PartialOrd)]
pub enum ChartType {
None,
Area,
AreaStacked,
AreaStackedPercent,
Bar,
BarStacked,
Column,
ColumnStacked,
ColumnStackedPercent,
Doughnut,
Line,
Pie,
Scatter,
ScatterStraight,
ScatterStraightWithMarkers,
ScatterSmooth,
ScatterSmoothWithMarkers,
Radar,
RadarWithMarkers,
RadarFilled,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ChartDashType {
Solid,
RoundDot,
SquareDot,
Dash,
DashDot,
LongDash,
LongDashDot,
LongDashDotDot,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ChartPatternType {
None,
Percent5,
Percent10,
Percent20,
Percent25,
Percent30,
Percent40,
Percent50,
Percent60,
Percent70,
Percent75,
Percent80,
Percent90,
LightDownwardDiagonal,
LightUpwardDiagonal,
DarkDownwardDiagonal,
DarkUpwardDiagonal,
WideDownwardDiagonal,
WideUpwardDiagonal,
LightVertical,
LightHorizontal,
NarrowVertical,
NarrowHorizontal,
DarkVertical,
DarkHorizontal,
DashedDownwardDiagonal,
DashedUpwardDiagonal,
DashedHorizontal,
DashedVertical,
SmallConfetti,
LargeConfetti,
Zigzag,
Wave,
DiagonalBrick,
HorizontalBrick,
Weave,
Plaid,
Divot,
DottedGrid,
DottedDiamond,
Shingle,
Trellis,
Sphere,
SmallGrid,
LargeGrid,
SmallCheck,
LargeCheck,
OutlinedDiamond,
SolidDiamond,
}
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum ChartMarkerType {
MarkerAutomatic,
MarkerNone,
MarkerSquare,
MarkerDiamond,
MarkerTriangle,
MarkerX,
MarkerStar,
MarkerShortDash,
MarkerLongDash,
MarkerCircle,
MarkerPlus,
}