I want to create a donut chart using an SVG circle element by setting stroke-dasharray
and varying stroke-dashoffset
. The SVG element needs to be rotated by 270 (or -90) degrees in order for the chart "bar" to start at the top. Here is the code:
The rotation angle is specified using the first number in transform="rotate(270, 80, 80)"
.
The problem is: when viewed in Safari on iOS 10 this rotation is not applied. In fact, setting 90, 180 or 270 degree rotation has no effect. The same angles but negative (for example -90) are also not applied.
Here is a screenshot of the above fiddle in Safari on iOS 10.0.1:
And here is the same fiddle in Safari on iOS 9.3.5:
As a workaround, I have found that using something like 270.1 degrees solves the problem, however I would like to know why 270 is not working and if there is a better way of dealing with it.
This is happening to me as well, I settled on using a rotation just shy of being divisible by 90 degrees to get around this in the interim.
Indeed, set the rotate transformation to something like 90.1deg solves the issue...
I have test many things, reported here: https://codepen.io/KevinNTH/pen/ZBgKdG
I've experienced this painfully on iOS 10.1 and Safari 10.0.1. The bug is definitely triggered by any
rotate
value which computes to a value divisible by 90 degrees.But it gets weirder.
See this demo/series of minimal test cases I put together (jsFiddle version here). Best to run the snippet then expand to full page:
As stated in the demo, it appears to be fixed in iOS 10.2, at least in the public beta version I just downloaded. Presumably, a Safari fix will also be arriving in due time.
iOS 10.1
iOS 10.2 (Public Beta 2)