Skip to content

clip voronoi mesh to geo polygon #1338

Answered by pdebruic
pdebruic asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the pointer. Because I don't know how to incorporate the workflow from #1109 I ended up writing some js to post-process the plots.

var geos = document.querySelectorAll('g[aria-label="geo"]')
document.querySelectorAll('g[aria-label="voronoi"]').forEach((element,index) =>{
    var clipPath = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
    clipPath.innerHTML=geos[index].innerHTML;
    var clipId = 'clip'+index;
    clipPath.setAttribute('id',clipId);
    var plot = element.parentNode;
    plot.appendChild(clipPath);
    element.setAttribute('clip-path',"url(#"+clipId+")");
})

Which works for my needs.

Is there a way to set a class or id attribute on a plot?

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@Fil
Comment options

@mbostock
Comment options

@pdebruic
Comment options

Answer selected by Fil
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants