# Weird behaviour fill tonext

**URL:** <https://community.plotly.com/t/weird-behaviour-fill-tonext/95054>\
**Category:** plotly.js\
**Created:** [October 9, 2025, 12:20pm UTC](https://community.plotly.com/t/weird-behaviour-fill-tonext/95054 "2025-10-09T12:20:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkatgert](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@mkatgert](https://community.plotly.com/u/mkatgert)\
**Post date:** [October 9, 2025, 12:20pm UTC](https://community.plotly.com/t/weird-behaviour-fill-tonext/95054/1 "2025-10-09T12:20:15Z")

</div>

Hi all,

I’m trying to render patches with holes in them. I can achieve that by adding a scatter trace for the outside edge of the patch, and a scatter trace for the inside edge of the patch, with a fill: tonext on the latest added trace.

For simple shapes, that works, but if the shapes get a bit more complicated, the hole is not cutout properly. See example:

[https://codepen.io/mkatgert/pen/myVmvyM](https://codepen.io/mkatgert/pen/myVmvyM)

The left shape has been created by adding the ‘hole edge’ first, and then the outer edge, and then the outer edge has a fill tonext.

The right shape follows the exact same logic, but the hole is not cut out.

Is this a bug or am I doing something wrong?

---

<div class="post-metadata">

**Author:** ![Saratoga](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/saratoga/32/28634_2.png) [@Saratoga](https://community.plotly.com/u/Saratoga)\
**Post date:** [October 12, 2025, 12:33am UTC](https://community.plotly.com/t/weird-behaviour-fill-tonext/95054/2 "2025-10-12T00:33:42Z")

</div>

It could be a mistake, the “d” parameter for filling is well implemented but it seems they forgot to add the fill-rule=“evenodd” parameter, I’ll leave it as homework for you.

I tried all the values ​​for fill and none of them worked, maybe they need to add an evennod value for the fill, hopefully in future versions they will add it or maybe I could be wrong too

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/2/5/250a68a31f3922fbd8457d09ef1337477b4ec95e.png)

---

<div class="post-metadata">

**Author:** ![mkatgert](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@mkatgert](https://community.plotly.com/u/mkatgert)\
**Post date:** [October 13, 2025, 10:12am UTC](https://community.plotly.com/t/weird-behaviour-fill-tonext/95054/3 "2025-10-13T10:12:53Z")

</div>

Thanks Saratoga. Turns out the fill algorithm is very sensitive to the direction of the polygon. In this example I reversed the direction of the hole of the right example: [https://codepen.io/mkatgert/pen/YPwxvqw](https://codepen.io/mkatgert/pen/YPwxvqw) and then it works. The documentation might benefit from a small reference to this sensitivity.
