Break D3 Each Loop Without a flag

不问归期 提交于 2019-12-01 20:19:26

No, there is not. Take a look at the each source code https://github.com/mbostock/d3/blob/78e0a4bb81a6565bf61e3ef1b898ef8377478766/src/selection/each.js.

You may be able to throw an exception to break the loop, but unless your case is really "exceptional", using an exception is probably more confusing than helpful.

you can do following

var flag = false;
circle.some(function (d) {
    if (flag) return true;
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!