CSS animations are typically far more processor efficient than Javascript animations. Far more clever people than I have spent a lot of brainpower optimizing the animations natively in the browser. Whenever possible, I defer to their expertise.
The animation in use is a simple scale transform:
@keyframes pulsar {
from {
fill: red;
}
to {
fill: red;
transform: scale(1.3,1.3);
transform-origin: 50% 50%;
}
}
Here's an important potential 'gotcha'! Make sure in your normal CSS style for the data points to explicity set the scale
to 1
. If you don't you will likely end up with data points of various sizes once the warning condition has passed and the pulse
class is removed.
If you want to interact with these D3.js gists without downloading them yourself, replace https://gist.github.com
with http://bl.ocks.org
to go to Mike Bostock's excellent website for running D3.js gists.