Closed edemaine closed 1 year ago
Actually we have this option if we can add css to our page. Look at this notebook: https://observablehq.com/@alexbol99/inversion-in-a-circle That is why I added support only for basic attributes.
Ah, good point; we could use className
. I'd personally still prefer to have direct attribute access so it's easy to configure without CSS and programmatically for each element. (For example, what if every segment wanted a different dash array? Admittedly I don't have a use case for this. 😅) I guess there's a question of where to draw the line (no pun intended), but e.g. stroke-dashoffset
has applications with stroke-dasharray
, and doesn't make sense with CSS.
An alternative approach would be to just pass all unrecognized properties of attrs
on as attributes. Then every attribute is supported. We could still support e.g. strokeWidth
and className
for backward compatibility, but it would then be possible to use stroke-width
and class
as alternatives. And the added code would be generic so pretty minimal I think.
Let me know if you'd accept a PR in either direction, and I can work on it.
Support any attribute in svg() attribute parameter objects released in version v1.3.7 See https://observablehq.com/d/76f6be5777ed58a2 for example
Released in version 1.3.7, issue closed
I'd like to be able to render
Segment
s/Ray
s/Line
s with dashed or dotted patterns. Adding astrokeDashArray
option insvg
'sattrs
argument to optionally add astroke-dasharray
would be really easy.