Skip to content
This repository has been archived by the owner on Oct 12, 2020. It is now read-only.

metocean/d3-chronological

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

d3-chronological

d3 components using proper timezone information. Currently only scale has been implemented.

Scale

Replace d3.time.scale with d3.chrono.scale.

var x = d3.chrono.scale('Pacific/Auckland')
  .domain([
    moment('2015-01-01'),
    moment('2015-01-02')
  ])
  .nice(moment().tz('Pacific/Auckland').startOf('w').every(1, 'w'))
  .range([0, width]);

Create the scale with a timezone identifier from momentjs timezone or leave blank to use UTC. This timezone is used to create default ticks that align to the correct start of day, etc.

Pass a chronological time schedule to the nice function to round to the nearest schedule. The above example rounds to the nearest week.

Values are kept as milliseconds past epoch internally and converted to timezone moments on output from domain() and ticks(). Calculating your own tick values and tick format is suggested - using chronological makes this easy.

About

d3 components using proper timezone information

Resources

License

Stars

Watchers

Forks

Packages

No packages published