Skip to content

fix(nanoplots): keep a stroke width of zero passed to nanoplot_options - #893

Merged
rich-iannone merged 4 commits into
posit-dev:mainfrom
Rodrigo-Palma:fix/nanoplot-zero-stroke-width
Oct 2, 2026
Merged

rich-iannone merged 4 commits into
posit-dev:mainfrom
Rodrigo-Palma:fix/nanoplot-zero-stroke-width

Conversation

@Rodrigo-Palma

Copy link
Copy Markdown
Contributor

nanoplot_options() takes the default for data_line_stroke_width and vertical_guide_stroke_width with x or default (_helpers.py:1475, _helpers.py:1492), so a width of 0, which is how a caller asks for no stroke at all, reads as "not given":

from great_tables import nanoplot_options

nanoplot_options(data_line_stroke_width=0)["data_line_stroke_width"]  # 8
nanoplot_options(data_line_stroke_width=1)["data_line_stroke_width"]  # 1

Passing 0 produces an SVG byte for byte identical to the default one, so the option is dropped rather than doing something visible that the caller could notice.

The same function already draws this distinction where it matters. Every show_* flag uses True if x is None else x precisely so that False survives, and the widths that go through _normalize_listable_nanoplot_options keep a 0 because it becomes a truthy [0]. These two are the ones left on or.

Reading the default with is None is the smallest change that makes them behave like their neighbours. Colors are left as they are: an empty string is not a value a caller means.

Test run: full pytest tests, 2722 passed, 1 skipped, 6 xfailed. The new test fails on main. ruff check and ruff format --check clean on both files.

data_line_stroke_width and vertical_guide_stroke_width take their
default through 'x or default', so a width of 0, which is how a caller
asks for no stroke at all, is read as 'not given' and replaced by 8 and
by 12.

    nanoplot_options(data_line_stroke_width=0) -> 8
    nanoplot_options(data_line_stroke_width=1) -> 1

With 0 the generated SVG is byte for byte the default one, so the option
is silently dropped rather than doing nothing visible.

The same function already makes this distinction where it matters: every
show_* flag uses 'True if x is None else x' so that False survives, and
the widths that pass through _normalize_listable_nanoplot_options keep a
0 because it becomes a truthy [0]. These two are the ones left behind.
@codecov

codecov Bot commented Sep 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.34%. Comparing base (fc46ff9) to head (4a7ff12).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #893   +/-   ##
=======================================
  Coverage   98.34%   98.34%           
=======================================
  Files          52       52           
  Lines        8318     8318           
=======================================
  Hits         8180     8180           
  Misses        138      138           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rich-iannone rich-iannone left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@rich-iannone
rich-iannone merged commit bb04c10 into posit-dev:main Oct 2, 2026
15 checks passed
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.

2 participants