SVG Axis Labels align inconsistently across browsers
See original GitHub issueThe align of axis labels in svg is based on the alignment-baseline
property, which differs across browsers:
https://stackoverflow.com/questions/41822995/inconsistent-svg-text-alignment-in-chrome-and-firefox
https://stackoverflow.com/questions/19212498/firefox-support-for-alignment-baseline-property
This is due to the specification not permitting alignment-baseline
on text
elements: https://www.w3.org/TR/SVG11/text.html#AlignmentBaselineProperty
Therefore, I suggest changing the use of alignment-baseline
to dominant-baseline
and the valuesbefore-edge
to text-before-edges
and after-edge
to text-after-edge
, which appears to resolve the issues for me, but I have not tried to build this from the source.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:6
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Inconsistent SVG text alignment in Chrome and Firefox
The icons represent weather stations and they are rotated according to the wind direction and show the average wind speed as an overlay....
Read more >[Solved]-d3.js: Align text labels between ticks on the axis-d3.js
I often do this by stacking multiple axes, each with a custom .tickFormat() . If I'm placing labels in between dates, I'll often...
Read more >Align y-labels — Matplotlib 3.6.2 documentation
Two methods are shown here, one using a short call to Figure.align_ylabels and the second a manual way to align the labels. ......
Read more >Balisage Paper: How long is my SVG <text> element?
Under those bar labels we label the X axis itself. ... in browsers is inconsistent, and user-controlled kerning support in SVG and CSS...
Read more >SVG Animation and CSS Transforms: A Complicated Love Story
In all browsers, px-based origins are measured differently for SVG elements than other DOM elements (see below). Here's a video demonstrating ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Contributions are welcome 😃
Ps: a fast CSS fix in the meantime is the following (not tested in IE though):
It looks like it won’t work in IE though. So maybe something like the following? (untested as well)