Skip to content

Render: draw chart trendlines - #603

Merged
h-a-n-a-s-h-i merged 3 commits into
storytold:mainfrom
NikitkaRa:cursor/chart-trendlines-draw-b770
Oct 14, 2026
Merged

h-a-n-a-s-h-i merged 3 commits into
storytold:mainfrom
NikitkaRa:cursor/chart-trendlines-draw-b770

Conversation

@NikitkaRa

Copy link
Copy Markdown
Contributor

Summary

Stacked on #590. Upstream can't use a fork branch as the base, so this PR targets main and also contains #590's commit; please review only the last commits. The diff shrinks once #590 merges.

Chart trendlines are drawn. Linear, exponential, logarithmic, polynomial (order 2–6), power, and moving average are fitted from the series, including a forecast, and stroked as a dashed line. When the file asks for the equation or R², that label is placed in an open corner of the plot. A moving average has no equation, and its R² is not drawn. The value axis grows to include the fit, with a bound so a wild polynomial cannot flatten the chart.

Secondary-axis export stays with #255. The chart-elements row stays partial.

Test plan

  • cargo fmt --all -- --check and cargo clippy --workspace --all-targets -- -D warnings (follow-up commit checked with -p deckcraft-model)
  • cargo test --workspace with three known environment-only failures skipped (craft-fonts missing on that machine): symbol_font_characters_draw_in_the_sym_font, korean_composes_in_the_notes_pane, cjk_text_in_the_interface_is_drawn_with_real_glyphs
  • moving_average_shows_neither_equation_nor_r2
  • cargo xtask assets, cargo xtask layers, and cargo xtask wasm
  • Screenshot on macOS of six charts (linear with forecast, exponential, logarithmic, polynomial, power, moving average); labels read y = 2x + 1, y = 0.5e^(0.693x), y = ln(x), y = x², y = 2x^0.5.

An owned corpus slice checks combo charts with data labels, merged
tables with diagonal borders, and text columns, autofit, vertical text
and a WordArt warp. Trendlines (type, order, period, forecast,
intercept, equation and R²) are now read and written.
Fit linear, exponential, logarithmic, polynomial, power and moving-average
lines, including forecast, and draw them with the equation and R² label.
PowerPoint does not show R² for a moving average, and the value can be
negative. The line is still drawn.
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 8f0640a into storytold:main Oct 14, 2026
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 14, 2026
#640 orders category slots bottom-to-top on horizontal bars (or reversed via
c:orientation) while #603 pads the axis for trendline forecasts. Slots now
include the forecast padding on the right side, and trendlines map their
category positions through the same slot order as the bars.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 14, 2026
#662 gives scatter and bubble charts one x scale over every series; #603's
trendlines still mapped x over each series' own extent, so a fit drifted off
its points. Use the chart's x scale where there is one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
h-a-n-a-s-h-i pushed a commit that referenced this pull request Oct 14, 2026
…#591 #594 #598 #602 #603 #638 #640 #662 #666 #669 #690 #582 #588 #633 #635)

# Conflicts:
#	crates/pptx/src/write/mod.rs
#	crates/pptx/tests/roundtrip.rs
@echelon

echelon commented Oct 14, 2026

Copy link
Copy Markdown
Member

Thank you for this contribution, @NikitkaRa! It has landed on main and will ship in the next DeckCraft release.

If you haven't already, please come join us on Discord: https://discord.gg/artcraft

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants