简体   繁体   中英

D3 Update/Redraw SVG at Set Intervals

I have an animation where points on a plane are encapsulated dynamically by a polygon ( gift-wrapping algorithm ). I am using a path SVG to draw the polygon, however, I notice that as points transform around the plane and are added to/removed from the perimeter of the polygon, the entire polygon will rotate to adjust during it's transitions, which looks messy and makes for a poor visualization.

I can see that many examples ( example ) involve redrawing (instead of transitioning) the entire path SVG with new data when an event occurs. I was wondering if there is any way I can redraw the path at set intervals, such as once every x milliseconds, or once each time the points are transformed.

Thanks!

This is difficult to understand without an example of what your solution currently looks like.

That said, I noticed the bl.ock example you linked, and how it redraws instead of transitioning. If you want to avoid a full redraw, you'll need to separate out solely the changed SVG subsections in some way, so they can be individually targeted. Like an array of d3 SVG objects, or something.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM