npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

d3-clock

v0.1.5

Published

An analogue clock made with D3.

Downloads

16

Readme

D3 Clock

An analogue clock with multiple faces, based on d3.

screenshot

Credits go to Daniel Pradilla, who created the original d3clock.

I've only:

  • added the option to provide a time function that specifies the time (e.g. for simulation)
  • converted d3 from v3 to v5
  • converted the JavaScript to TypeScript
  • refactored the clock faces to separate files, so you only load faces that you will be using.
  • removed some redundant computations and code
  • fixed some bugs (e.g. the SBB clock added new circle elements on every clock tick, roman numeral IV...)
  • published it to npm.

Credits

by: Daniel Pradilla [email protected] blog: http://danielpradilla.info

With ideas from

  • https://github.com/wout/svg.clock.js
  • https://ericbullington.com/blog/2012/10/27/d3-oclock/
  • http://www.infocaptor.com/dashboard/d3-javascript-visualization-to-build-world-analog-clocks
  • Also see the excellent article by Mike Bostock: https://bost.ocks.org/mike/join/

Usage:

Call d3clock(config) for each clock instance e.g.:

import { d3clock, sbb } from 'd3-clock';

document.addEventListener('DOMContentLoaded', () => {
  d3clock({
    // Parent div to put the clock in
    target: '#sbb',
    // Width of the clock
    width: 600,
    // Fixed time
    // date:'Mon May 25 2015 10:09:37',
    // Time zone offset
    TZOffset: { hours: 0 },
    // Clock face, e.g. sbb, braun, modern, or classic, must be imported
    face: sbb
  });
});

You can create several instances in a page (for showing multiple time zones, for example). If you send a date value in the config object, it shows a fixed time (good for testing).

Available clock faces

  1. sbb: The famous Swiss Railway Clock
  2. modern: A somewhat modern/minimalist face
  3. classic: A classical face with roman numerals
  4. braun: A Braun BN0021-ish face

Build instructions

npm i
npm start