= (0..n_colors)
- .map(|i| {
- cd.style
- .colors
- .as_ref()
- .and_then(|c| c.get(i).cloned())
- .unwrap_or_else(|| DEFAULT_COLORS[i % DEFAULT_COLORS.len()].to_string())
- })
- .collect();
-
ResolvedContent::Chart {
svg: crate::chart_render::render_svg(cd, w_mm, h_mm),
- chart_data: Box::new(ChartRenderData {
- chart_type: cd.chart_type.clone(),
- categories: cd.categories.clone(),
- series: cd
- .series
- .iter()
- .map(|s| ChartSeriesData {
- name: s.name.clone(),
- values: s.values.clone(),
- })
- .collect(),
- title_text: cd.title.as_ref().map(|t| t.text.clone()),
- title_font_size: cd.title.as_ref().and_then(|t| t.font_size),
- title_color: cd.title.as_ref().and_then(|t| t.color.clone()),
- colors,
- show_labels: cd.labels.as_ref().is_some_and(|l| l.show),
- label_font_size: cd.labels.as_ref().and_then(|l| l.font_size),
- show_grid: cd.axis.as_ref().and_then(|a| a.show_grid).unwrap_or(true),
- grid_color: cd.axis.as_ref().and_then(|a| a.grid_color.clone()),
- bar_gap: cd.style.bar_gap,
- stacked: matches!(
- cd.group_mode,
- Some(dreport_core::models::GroupMode::Stacked)
- ),
- inner_radius: cd.style.inner_radius,
- show_points: cd.style.show_points,
- line_width: cd.style.line_width,
- background_color: cd.style.background_color.clone(),
- label_color: cd.labels.as_ref().and_then(|l| l.color.clone()),
- legend_show: cd.legend.as_ref().is_some_and(|l| l.show),
- legend_position: cd.legend.as_ref().and_then(|l| l.position.clone()),
- legend_font_size: cd.legend.as_ref().and_then(|l| l.font_size),
- x_label: cd.axis.as_ref().and_then(|a| a.x_label.clone()),
- y_label: cd.axis.as_ref().and_then(|a| a.y_label.clone()),
- title_align: cd.title.as_ref().and_then(|t| t.align.clone()),
- }),
+ chart_data: Box::new(crate::ChartRenderData::from(cd)),
}
})
} else {
diff --git a/layout-engine/tests/snapshots/chart_test_svg.html b/layout-engine/tests/snapshots/chart_test_svg.html
index 77cdfd8..232628a 100644
--- a/layout-engine/tests/snapshots/chart_test_svg.html
+++ b/layout-engine/tests/snapshots/chart_test_svg.html
@@ -1 +1 @@
-Chart SVG Preview (HTML render)
\ No newline at end of file
+Chart SVG Preview (HTML render)
\ No newline at end of file