Skip to content

Instantly share code, notes, and snippets.

@ctufts
Last active April 6, 2017 13:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ctufts/95187d4ac019a02fc19b6e783c0e91b0 to your computer and use it in GitHub Desktop.
function for crossfade transition of text using d3 based on this block: https://bl.ocks.org/mbostock/f7dcecb19c4af317e464
function transition_text(element_id, display_text, t_duration){
// base off of https://bl.ocks.org/mbostock/f7dcecb19c4af317e464
svg.select(element_id)
.transition()
.duration(t_duration)
.on("start", function () {
var t = d3.active(this)
.style("opacity", 0)
.remove();
svg.select(element_id)
.style("opacity", 0)
.text(display_text)
.transition(t)
.style("opacity", 1)
.transition()
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment