Last active
September 28, 2015 13:29
-
-
Save obenjiro/366f0e6dc3c46730877e to your computer and use it in GitHub Desktop.
d3 template gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Шаблонная функция для работы с D3 | |
| */ | |
| function act(scenario) { | |
| // устанавливаем сцену | |
| var stage = d3.select('body'); | |
| // выбераем актеров | |
| var actors = stage.selectAll('div'); | |
| // раздаем роли актерам | |
| var awroles = actors.data(scenario, function(d){ return d }); | |
| awroles | |
| /* действия актеров которые уже на сцене */ | |
| /* .style({ color: 'blue' }) */ | |
| ; | |
| awroles.enter() | |
| /* действия актеров которые выходят на сцену */ | |
| /* .append('div').text(String) */ | |
| ; | |
| awroles.exit() | |
| /* действия актеров которые уходят со сцены */ | |
| /* .style({ color: 'red' }) */ | |
| ; | |
| } | |
| // current state of DOM -> act #1 | |
| act([1,2,3]) | |
| // act #1 -> act #2 | |
| act([2,4]); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment