pub mod grid;
pub mod ir;
mod legacy_column_layout;
mod legacy_column_renderer;
mod legacy_combo_renderer;
mod legacy_legend_layout;
mod legacy_presentation;
mod legacy_string;
mod legacy_text_metrics;
mod ooxml_text;
pub mod orientation;
pub mod parser;
mod preview_palette;
pub mod svg_renderer;
pub use grid::{
legacy_grid_window, scan_legacy_grid, GridCell, GridScanError, GridValue, LegacyChartGrid,
};
pub use ir::{
ole_chart_ir_base64, ole_chart_ir_json, OleChartIrPayload, OLE_CHART_IR_SCHEMA,
OLE_CHART_IR_VERSION,
};
pub(crate) use ooxml_text::render_ooxml_chart;
pub use orientation::{decide_series_axis, SeriesAxis, SeriesAxisEvidence};
pub use parser::{
parse_ole_chart_contents, probe_ole_chart_contents, OleChart, OleChartContentsProbe,
OleChartParseError, OleChartSeries, OleChartType,
};
pub use preview_palette::apply_preview_palette;
pub use svg_renderer::{
render_ole_chart_standalone_svg, render_ole_chart_svg_body, render_ole_chart_svg_fragment,
};
pub fn render_ole_chart_svg_fragment_with_contents(
chart: &OleChart,
contents: &[u8],
bounds: [f64; 4],
bin_data_id: u32,
) -> String {
render_ole_chart_svg_fragment_with_contents_at_dpi(chart, contents, bounds, bin_data_id, 96.0)
}
pub fn render_ole_chart_svg_fragment_with_contents_at_dpi(
chart: &OleChart,
contents: &[u8],
bounds: [f64; 4],
bin_data_id: u32,
dpi: f64,
) -> String {
if let Some(presentation) = legacy_presentation::parse(contents) {
if presentation.chart_type == 1
&& !presentation.series.iter().any(|series| series.secondary)
&& chart.series.len() == presentation.series.len()
&& chart
.series
.iter()
.all(|series| series.values.len() == chart.categories.len())
{
return svg_renderer::render_legacy_column_fragment(
chart,
&presentation,
bounds,
bin_data_id,
dpi,
);
}
if let Some(svg) = legacy_combo_renderer::render(chart, &presentation, bounds) {
return svg;
}
}
let [x, y, width, height] = bounds;
render_ole_chart_svg_fragment(chart, x, y, width, height, bin_data_id)
}