Home Manipulating Opacity and Text in D3.js
Reply: 0

Manipulating Opacity and Text in D3.js

user729
1#
user729 Published in April 22, 2018, 12:59 am

I'm trying to write a function that changes text a div, using dot-chaining and D3.

I want to select my outer div, transition it's opacity to 0, select the inner div and change the text, and then transition the outer div back to 1. So the entire thing looks something like this:

d3.select("div#outer").transition()
    .duration(200)
    .style("opacity",0)
    .transition()
    .duration(200)
    .style("opacity",1)

d3.select("div#inner").transition().delay(200).text("This is the new text")

There's got to be a better way of doing this. Is there a way for me to combine these two selections? Ideally I would make this all one function and just call it accordingly.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.302283 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO