Class Index | File Index

## Classes

- _global_
- links.Timeline
- links.Timeline.Step

# Class links.Timeline.Step

Step The class step is an iterator for dates. You provide a start date and an end date. The class itself determines the best scale (step size) based on the provided start Date, end Date, and bestStepNum. For example if you want to have a label each 100px (you may reckon with the text size), and the width of your timeline is 1000px, then you can provide bestStepNum=10. Alternatively, you can set a scale by hand. After creation, you can initialize the class by executing begin(). Then you can iterate from the start date to the end date via next(). You can check if the end date is reached with the function end(). After each step, you can retrieve the current date via get(). The class step has scales ranging from milliseconds, seconds, minutes, hours, days, to years.
Defined in: timeline.js.

Class Summary
Constructor Attributes | Constructor Name and Description
--- | ---
| links.Timeline.Step(start, end, bestStepNum)

Method Summary
Method Attributes | Method Name and Description
--- | ---
| addZeros(value, len) Add
| begin() Set the step iterator to the start date.
| doAutoScale() Automatically determine the best scale and step, based on the start Date and end Date
| end() Check if the end date is reached
| getDate() Get the current datetime
| getLabelMajor() Returns formatted text for the major axislabel, depending on the current date and the scale.
| getLabelMinor() Returns formatted text for the minor axislabel, depending on the current date and the scale.
| isMajor() Check if the current step is a major step (for example when the step is DAY, a major step is each first day of the MONTH)
| next() Do the next step
| roundToMinor() Round the current date to the first minor date value This must be executed once when the current date is set to start Date
| setAutoScale(enable) Enable or disable autoscaling
| setRange(start, end, bestStepNum) Set a new range The scale is determined based on the difference in time and the bestStepNum.
| setScale(newScale, newStep) Set a custom scale.
| snap(date) Snap a date to a rounded value.

Class Detail
links.Timeline.Step(start, end, bestStepNum)

Parameters:
{Date} start
  The start date, for example new Date(2010,09,21) or new Date(2010,09,21,23,45,00)
{Date} end
  The end date
{int} bestStepNum
  Optional. The most ideal number of steps, labels.

Method Detail
addZeros(value, len)
Add

Parameters:
value
len

begin()
Set the step iterator to the start date.

doAutoScale()
Automatically determine the best scale and step, based on the start Date and end Date

{boolean} end()
Check if the end date is reached

Returns:
  {boolean} true if the current date has passed the end date

{Date} getDate()
Get the current datetime

Returns:
  {Date} current The current date

{string} getLabelMajor()
Returns formatted text for the major axislabel, depending on the current date and the scale. For example when scale is MINUTE, the major scale is hours, and the hour will be formatted as "hh".

Returns:
  {string} major axislabel

{string} getLabelMinor()
Returns formatted text for the minor axislabel, depending on the current date and the scale. For example when scale is MINUTE, the current time is formatted as "hh::mm".

Returns:
  {string} minor axislabel

isMajor()
Check if the current step is a major step (for example when the step is DAY, a major step is each first day of the MONTH)

Returns:
  true if current date is major, else false.

next()
Do the next step

roundToMinor()
Round the current date to the first minor date value This must be executed once when the current date is set to start Date

setAutoScale(enable)
Enable or disable autoscaling

Parameters:
{boolean} enable
  If true or not defined, autoscaling is enabled. If false, autoscaling is disabled.

setRange(start, end, bestStepNum)
Set a new range The scale is determined based on the difference in time and the bestStepNum. For example if you want to have a label each 100px (you may reckon with the text size), and the width of your timeline is 1000px, then you can provide bestStepNum=10. Alternatively, you can set a scale by hand.

Parameters:
{Date} start
  The start date and time.
{Date} end
  The end date and time.
{int} bestStepNum
  Optional. The most ideal number of steps, labels.

setScale(newScale, newStep)
Set a custom scale. Autoscaling will be disabled. For example setScale(SCALE.MINUTES, 5) will result in minor steps of 5 minutes, and major steps of an hour.

Parameters:
{Step.SCALE} newScale
  A scale. Choose from SCALE.MILLISECOND, SCALE.SECOND, SCALE.MINUTE, SCALE.HOUR, SCALE.DAY, SCALE.MONTH, SCALE.YEAR.
{int} newStep
  A step size, by default 1. Choose for example 1, 2, 5, or 10.

snap(date)
Snap a date to a rounded value. The snap intervals are dependent on the current scale and step.

Parameters:
{Date} date
  the date to be snapped

Documentation generated by JsDoc Toolkit 2.3.2 on Wed Oct 13 2010 15:20:31 GMT+0200 (CEST)