Skip to content

variable styles - #909

Draft
Fil wants to merge 4 commits into
mainfrom
fil/variable-styles
Draft

Fil wants to merge 4 commits into
mainfrom
fil/variable-styles

Conversation

@Fil

@Fil Fil commented Jun 2, 2022 •

Copy link
Copy Markdown
Contributor

This PR wants to make all of the common styles (or most of them) "variable" (#175, #380)

  • strokeDasharray (difficult case: we can't consider that an array is a columnar representation of a channel) 🌶
  • strokeDashoffset (number)
  • dx and dy
    • DX without X, DY without Y?
  • mixBlendMode
  • more?

for the text mark:

  • textAnchor
  • fontFamily
  • fontSize (was already variable)
  • fontStyle
  • fontVariant
  • fontWeight

for the arrow mark:

@Fil

Fil commented Jul 7, 2022

Copy link
Copy Markdown
Contributor Author

I'm not sure how to make dx and dy variable when X or Y are not channels; I think I'll punt on this for now, because I don't want to overcomplicate the PR—my first prototype was making changes in each and every mark, depending on X, Y, and possibly cx, cy when X and Y were not defined… booo. The current approach which shifts X seems much better, but doesn't work when X is not a channel.

@Fil
Fil marked this pull request as ready for review July 7, 2022 12:28
@Fil
Fil requested a review from mbostock July 11, 2022 06:14
…ont-weight, strokeDasharray, strokeDashoffset

maybeDasharrayChannel identifies arrays of numbers (possibly joined by white space or commas) as constant; a single number is an acceptable strokeDasharray option
@Fil
Fil force-pushed the fil/variable-styles branch from d6f6085 to b2ca6c4 Compare July 22, 2022 14:15
@Fil

Fil commented Jul 22, 2022

Copy link
Copy Markdown
Contributor Author

rebased

@mbostock

Copy link
Copy Markdown
Member

Fil, thanks for the work here. I would like to put this on hold to focus on animation and interaction. I am concerned that this generalization may make animation more difficult to implement. Let’s discuss this week.

@Fil Fil mentioned this pull request Oct 27, 2022
2 tasks
@Fil
Fil marked this pull request as draft April 3, 2023 14:59
@Fil

Fil commented Dec 5, 2026

Copy link
Copy Markdown
Contributor Author

I regularly trip on this one, and agents do too; in particular the textAnchor for specific labels, like in https://observablehq.com/@visionscarto/us-measles-resurgence

Fil and others added 2 commits December 5, 2026 16:18
Conflict resolution:
- src/plot.js: Mark moved to src/mark.js on main; the PR's removal of the
  constant dx/dy from the Mark constructor is applied there instead.
- src/channel.js: take main's valueObject. The dx/dy channel offsets now
  apply in Mark.scale, after the projection (if any), so that pixel offsets
  are not added to longitude and latitude.
- src/style.js: combine main's "auto" scales, filter: null on title, href
  and ariaLabel, and the channels option with the PR's new channels.
- src/marks/text.js: keep main's optional text channel and title (TL)
  channel alongside the PR's text style channels.
- README.md: take main's; port the documentation to docs/features/marks.md
  and docs/marks/text.md.
- test/plots/index.js: deleted on main; convert the PR's test plots to
  TypeScript and register them in test/plots/index.ts. Snapshots
  regenerated (same dash, anchor, fill and font attributes as before; only
  main's newer SVG structure and number precision differ).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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