I am currently working on rendering an area graph (together with a single line chart and a scatter plot on the very same graph region).
On chrome, it looks perfectly fine, as the area graph does not extend beyond the axes.
However, on Safari (both mobile and desktop), it appears that the clipping path is not applied, as the entire area graph is shown, and its not 'clipped off'.
This is the relevant code that involves the clip-path
and rendering of the area chart. Even though the <clipPath>
element is rendered, the subsequent element does not seem to register the effects from the clip-path..
const ciClip = svg.append('defs').append('clipPath')
.attr('id', 'ciClip')
.append('rect')
.attr('width', width)
.attr('height', height)
.attr('x', 0)
.attr('y', 0);
svg.append('g')
.attr('clip-path', 'url(#ciClip)')
.append('path')
.datum(ciData)
.attr('class', 'area')
.attr('d', area)
.style('fill', '#D2E6FF')
.style('opacity', .2);
I have tried the following:
1) Why doesn't CSS clip-path with SVG work in Safari?
2) SVG Clip-Path not working on Safari
Unfortunately, they do not solve my problems.
The funny thing is, this is not my first time working with clip-paths, and I have not faced any cross-browser issues with it. Has anyone else faced a similar issue and successfully solved it? I would love to learn about how I can solve this particular issue. Thank you very much.
I am currently on D3.js v5.9.2 and Angular, if that matters (not sure if this could be due to the Angular's encapsulation).
P.S. I can try to reproduce a demo. I will try to produce a minimal version if for testing purposes.