You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This can be an issue when calling wrapText on text elements generated by d3 (such as an axis tick), because d3 often sets these values in ems. The solution should either detect and use the selector's units or should use a computed value in pixels (not totally sure if this can be done with dy properties).
This is pretty related to #247, which should probably be done first.
The text was updated successfully, but these errors were encountered:
Check whether the dx/dy attribute contains a unit.
a. Potential approach: use regex (maybe overkill)
b. Potential approach: check whether the attribute is equal to the numeric representation of the attribute.
Store the unit as a variable. If it doesn't contain a unit, default to pixels.
Do any calculations on the attribute using the numeric representation of the attribute
Append the unit to the calculated value when setting the attribute value in d3
Under this approach, line height would have to be in the same units as dy. But that doesn't feel like that's too much to ask.
We'd still likely have to limit the accepted units. So far I have really only used pixels and ems; I guess someone could potentially want to use percent but I don't think we have to get that fancy.
The
wrapText
helper function assumes the selector'sdx
anddy
values are in pixels, and assigns the new computed values in pixels: https://github.com/nprapps/dailygraphics/blob/master/graphic_templates/_base/js/helpers.js#L99-L124This can be an issue when calling
wrapText
on text elements generated by d3 (such as an axis tick), because d3 often sets these values in ems. The solution should either detect and use the selector's units or should use a computed value in pixels (not totally sure if this can be done withdy
properties).This is pretty related to #247, which should probably be done first.
The text was updated successfully, but these errors were encountered: