In Configurable circular timer with D3 I showed a circular timer made with D3.js . Although it's not really what it's for, this simple example shows how to make a complex viz. This is a clock that shows the animated hours/mins and seconds using only the timer and some configuration options. It also demonstrates the main features of the timer, such as pausing, resuming and using promises to communicate time expiry and cancellation.
You can use the codepen below to run it and take a look at the code. Fork it an play around with the options to understand how it works.
The hours are animated in smaller circle, minutes the middle one, and seconds by the external viz filling up. I needed quite a few animation elements to make this one.
Here's the default options.
Each transition is 60 seconds - the time it takes for the second timer to fill up. The time is formatted by a decorator which is called at every tick and returns the current time.
Here's the clock data.
The shadow elements are used to show the hours and minutes already passed up to the current time - so their start angles are 0 and finish angles are the start time of the cycles of animation. The hour and minute elements start at the current time and animate 60 seconds worth of hours and minutes. I've used the same color for the shadow elements as I did for the main. Another alternative would be to modify the colors used for hours and minutes and make the start angle the time that the clock was first shown (as opposed to the start of the current animation cycle) - why not try to figure that out with the codepen example. It's just a couple of small changes
Since this is all configured, the code is simply the orchestration of 60 second cycles and the handling of clicks.
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Complete Apps Script Applications > BigQuiz app >