0.2.0 • Published 8 years ago

d3-chronological v0.2.0

Weekly downloads
17
License
MIT
Repository
github
Last release
8 years ago

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.