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.
Constructor Attributes | Constructor Name and Description |
---|---|
links.Timeline.Step(start, end, bestStepNum)
|
Method Attributes | Method Name and Description |
---|---|
addZeros(value, len)
Add
|
|
begin()
Set the step iterator to the start date.
|
|
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
|
|
Returns formatted text for the major axislabel, depending on the current
date and the scale.
|
|
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
|
|
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.
|
- 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.
- Parameters:
- value
- len
- Returns:
- {boolean} true if the current date has passed the end date
- Returns:
- {Date} current The current date
- Returns:
- {string} major axislabel
- Returns:
- {string} minor axislabel
- Returns:
- true if current date is major, else false.
- Parameters:
- {boolean} enable
- If true or not defined, autoscaling is enabled. If false, autoscaling is disabled.
- 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.
- 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.
- Parameters:
- {Date} date
- the date to be snapped