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 🙏

© 2025 – Pkg Stats / Ryan Hefner

d3-time-quarter

v0.0.6

Published

D3 time quarter interval

Downloads

5

Readme

d3 Time Quarter Interval

The missing "quarter" interval methods in d3 to process Quarters

I came across having to deal with Quarters when creating a chart and of course there's a simple way of using the d3.time.month using it's offsets, I figured it'll be nice to have the quarter interval with all the methods and even additional methods make life a bit easier.

Intervals

All the default time intervals methods are included:

d3.time.quarter.floor(date)

d3.time.quarter.round(date)

d3.time.quarter.ceil(date)

d3.time.quarter.range(start, stop[, step])

d3.time.quarter.offset(date, step)

NOTE: UTC has some sort of bug, so this won't work yet. There are some closure issues so I'm open to some help!

d3.time.quarter.utc

Methods

d3.time.quarter.value(date);

Returns the Quarter of the given date.

d3.time.quarter.meta(date);

Returns an object containing metadata of the designated quarter given the date. The object includes the Quarter value, the Start (floor) of the quarter and the End (ceil) of the quarter.

Custom Quarter Interval

d3.time.createCustomQuarter(startDate);

Returns a new custom time interval 3 months apart when provided with a quarter start date.

Example of use:
 var d3TimeCustomQuarter = d3.time.createCustomQuarter(new Date('02/01/2015'));
 
 d3TimeCustomQuarter.range(new Date('03/01/2015'), new Date('09/01/2015'));
 // Should return:
 // [
 //   Fri May 01 2015 00:00:00 GMT-0700 (Pacific Daylight Time), 
 //   Sat Aug 01 2015 00:00:00 GMT-0700 (Pacific Daylight Time)
 // ]
 

Aliases

d3.time.quarters(start, stop[, step])

Misc.

d3.time.__interval(local, step, number)

This method is the same method used to create the time interval methods. I decided to expose this you can create your own time intervals. To create your own, define the three functions seen in the signature: local, step, number.

  • local = this function that will return the Date for beginning of the interval range that the date belongs to
  • step = this function describes the interval length and should mutate the date to the next "step"
  • number = this function will return the value of the interval given the date.

(i.e. d3.time.newInterval = d3.time.__interval( ... ); )

Still got some work to do to make this compliant with the rest of the d3 interval methods, but this should help quite a bit.