Repository navigation
SVG: read stroke-dasharray and stroke-dashoffset lengths with a unit - #2173
Merged
Merged
Conversation
Plotly writes every dotted or dashed line as stroke-dasharray: 3px,3px, which failed with ValueError: could not convert string to float. Plain numbers are still read with float(), so that NaN and infinity keep their own error.
andersonhc
approved these changes
Nov 12, 2026
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
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.
Plotly writes every dotted or dashed line with pixel lengths. Its
Drawing.dashStyle()(src/components/drawing/index.js) turnsdash="dot"into3px,3pxand"dash"into9px,9px. So any Plotly figure with a dashed line, exported to SVG, fails inpdf.image():stroke-dasharrayandstroke-dashoffsetwere read withfloat(), whilestroke-widthalready goes throughresolve_length(). A newconvert_dash_length()keeps plain numbers onfloat(), sonanandinfstill get their own "must be finite" errors. A value with a unit now goes throughresolve_length(), so4pxis 3 and1mmis 72/25.4, as forstroke-width="2px".Two new cases in
test_svg_attribute_conversioncover a dasharray and dashoffset inpx, and mixed units. Both fail without the change.