Repository navigation
Charts: value axes start above zero when the values sit high, as in Office - #157
Merged
h-a-n-a-s-h-i merged 2 commits intoOct 14, 2026
Merged
Conversation
The value axis used a generic "nice" scale: about five intervals and no headroom, so data with a maximum of 42.1 got 0-50 in steps of 10, while PowerPoint and LibreOffice draw 0-45 in steps of 5. `auto_scale` now follows the rule Office documents for automatic limits: the maximum is the first major unit at or above max + (max - min)/20, the minimum is zero when all values are positive and the smallest is below 5/6 of the largest (otherwise the first major unit at or below min - the same headroom), and all-negative data mirrors that. The major unit is the smallest 1, 2 or 5 x 10^n that gives at most 10 intervals. Fixed `<c:min>`/`<c:max>` limits are kept as they are and no longer get rounded or padded; values beyond them stop at the plot edge. 100% charts get 0-1 in steps of 0.1. Fixes storytold#144 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 12, 2026
Upstream ce1c7b7 ("Charts: axis number formats, automatic major unit, hidden axes") replaced the value-axis scaling this branch changed, and already draws storytold#144's chart as 0-45 in steps of 5. Take its structure and API as they are (axis_scale with fixed bounds/unit and a room-based interval count, Chart::axis_scale(secondary, max_intervals), axis_range, combo charts' secondary axis) and drop this branch's auto_scale. On top of it, the Office rules upstream lacked: - Automatic minimum: zero only when every value is >= 0 and the smallest is below 5/6 of the largest; otherwise the first major unit at or below min - (max - min)/20. All-negative data mirrors it (the axis ends at zero only when the largest is above 5/6 of the smallest). Headroom is 5 % of the data range, as documented. Chart::axis_scale feeds it the plotted extremes (stacked sums still count from zero, 100 % series are 0-1); axis_range and value_range keep returning zero-inclusive ranges. - A fixed limit beyond the data makes the automatic end give way instead of producing an inverted axis. - The renderer stops values past the axis limits at the plot edge, on both value axes. The model tests from this branch are ported to the new signature with ten intervals of room. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Member
|
Thank you for this contribution, @LloydNicholson! It has landed on If you haven't already, please come join us on Discord: https://discord.gg/artcraft |
anishguduru
pushed a commit
to anishguduru/deckcraft
that referenced
this pull request
Oct 16, 2026
…d recovery beside pdfcraft.exe (storytold#325) * Issue storytold#157: the Windows portable zip keeps settings, logs and recovery beside pdfcraft.exe The portable zip had no portable.txt, and the app had no portable mode: it always wrote %APPDATA%\PdfCraft and %LOCALAPPDATA%\PdfCraft. Now portable.txt (or PdfCraft.portable) beside the executable puts the settings, log files, crash recovery and new digital IDs in PdfCraftData next to it, as PhotoCraft does, and the zip ships portable.txt. An unwritable PdfCraftData falls back to the per-user folders and says so. * Issue storytold#157: update ATTRIBUTION.toml SHA-256 for the translation catalogs this PR changes --------- Co-authored-by: Brandon Thomas <echelon@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #144.
Context
This PR first fixed #144: the issue's data (42.1, 18.7, 6.3) drew 0–50 in steps of 10, where PowerPoint and LibreOffice draw 0–45 in steps of 5. Upstream ce1c7b7 ("Charts: axis number formats, automatic major unit, hidden axes") has since rewritten the value-axis scaling, and
mainnow draws the issue's chart as 0–45 in steps of 5. So the branch now mergesmainand keeps upstream's structure and API as they are:axis_scale(lo, hi, fmin, fmax, major, max_intervals, headroom),Chart::axis_scale(secondary, max_intervals),axis_range, combo charts with a secondary axis, the room-based major unit, number formats and hidden axes. This PR's ownauto_scaleand its fixed "at most 10 intervals" unit rule are gone.What this adds on top of upstream
These are the documented rules for automatic axis limits (Microsoft's "How chart axis limits are determined", summarised by Jon Peltier) that
maindoesn't follow yet:mainalways starts the axis at zero. Office starts at zero only when every value is ≥ 0 and the smallest is below 5/6 of the largest. Otherwise the axis starts at the first major unit at or belowmin − (max − min)/20. Values of 85, 92 and 97 now get an 84–98 axis instead of bars that all look the same height.max + (max − min)/20. (maindidn't pad the top of an all-negative axis.) Mixed signs keep headroom at both ends, as onmain.max − min), as documented, not of the range from zero. A single value is measured from zero, so it still gets headroom.to_vandto_axisin the renderer). This covers values past a fixed<c:max>/<c:min>, and bars that start at zero on an axis that now starts above zero. Onmainthey drew outside the plot area.How it fits in:
Chart::axis_scalenow feedsaxis_scalethe plotted extremes. Plain values are used as they are, stacked series as running sums from zero (so stacked axes still start at zero), and 100% series as 0–1.axis_rangeandvalue_rangebehave as before (zero-inclusive), and all upstream tests pass unchanged.Testing
crates/model/src/chart.rs, run with room for 10 intervals:f64::MAX, denormals, inverted or non-finite fixed limits) always give a finite, non-empty axis.deckcraft-cli renderon synthetic decks:<c:max val="90"/>, it renders 84–90 and the 92 and 97 bars stop at the top of the plot.cargo xtask ci: fmt and clippy pass.cargo test --workspace --no-fail-fasthas three failures, and all three also fail on unmodifiedmainon the test machine. Two areime_tests::korean_composes_in_the_notes_paneandime_tests::cjk_text_in_the_interface_is_drawn_with_real_glyphsin deckcraft-ui-egui. The third istests::symbol_font_characters_draw_in_the_sym_fontin deckcraft-text, re-run separately onmain7d8bb05. Theassets,layersandwasmsteps pass.PowerPoint and LibreOffice weren't available on the test machine. The expected values come from the documented rule and the issue's reference images, not from a new Office export.
Source: Jon Peltier, How Excel Calculates Automatic Chart Axis Limits.
🤖 Generated with Claude Code