AnyChart
API Reference
Still have questions?
Contact support
Top
You are looking at an outdated v7 version of this document. Switch to the v8 version to see the up to date information.

class anychart.scales.DateTimeWithCalendar Improve this Doc

Extends: anychart.scales.ScatterBase

Date scale with calendar support.

Methods Overview

Specific settings
calendar()Calendar settings.
count()Count settings.
dateToPix()Transforms date to pixels.
extendDataRange()Extends the current input domain with the passed values (if such don't exist in the domain).
finishAutoCalc()Informs the scale that an auto range calculation started for the chart in past was ended.
getTicks()Returns ticks array.
getType()Returns scale type.
inverseTransform()Returns tick by its position ratio.
inverted()Inversion state.
maximum()Scale maximum.
maximumGap()Maximum gap settings.
minimum()Scale minimum.
minimumGap()Minimum gap settings.
pixToDate()Transforms pixels to date.
skipHolidays()Holidays settings.
softMaximum()Soft maximum settings.
softMinimum()Soft minimum settings.
startAutoCalc()Informs scale that an auto range calculation started for the chart, so it should reset its data range on the first
startDate()Start date.
transform()Returns tick position ratio by its name.
unit()Unit settings.
unitPixSize()Unit size settings.
Events
listen()Adds an event listener.
listenOnce()Adds a single time event listener.
removeAllListeners()Removes all listeners.
unlisten()Removes the listener.
unlistenByKey()Removes the listener by the key.

Methods Description

calendar

Getter for the scale calendar.

Returns:

anychart.scales.Calendar - Calendar instance.

count

Getter for the unit count.

Returns:

number - Count.
See listing
var currentCount = scale.count();
Setter for the unit count.

Params:

NameTypeDefaultDescription
valuenumber
1
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

dateToPix

Transforms date to pixels.

Params:

NameTypeDescription
datenumber | DateValue to transform.

Returns:

number - Pixel value.

extendDataRange

Extends the current input domain with the passed values (if such don't exist in the domain).
Note: Attention! anychart.scales.Base#finishAutoCalc drops all passed values.

Params:

NameTypeDescription
var_args*Values that are supposed to extend the input domain.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

finishAutoCalc

Informs the scale that an auto range calculation started for the chart in past was ended.

Params:

NameTypeDescription
silentlybooleanIf this flag is set, do not dispatch an event if reapplication needed.

Returns:

boolean - If the calculation changed the scale and it needs to be reapplied.

getTicks

Returns ticks array (even indexes are left borders, odd indexes are right borders of the tick) with passed interval. Ticks fill space from the fromPix pixel to the toPix pixel (if available).

Params:

NameTypeDescription
fromPixnumber"From" pixel.
toPixnumber"To" pixel.
unitanychart.enums.Interval | stringUnit interval.
countnumberUnit count.

Returns:

Array.<anychart.scales.DateTimeWithCalendar.Tick> - Returns ticks array.

getType

Returns scale type.

Returns:

string - Scale type.

inverseTransform

Returns tick by its position ratio.
Note: returns correct values only after anychart.scales.Base#finishAutoCalc or chart.draw().

Params:

NameTypeDescription
rationumberValue to transform in input scope.

Returns:

* - Value transformed to output scope.

inverted

Getter for scale inversion.

Returns:

boolean - Current inversion state.
Setter for scale inversion. If the scale is inverted, axes and series go upside-down or right-to-left instead of bottom-to-top and left-to-right.

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

listen

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method. Function that looks like function(event){ // event.actualTarget - actual event target // event.currentTarget - current event target // event.iterator - event iterator // event.originalEvent - original event // event.point - event point // event.pointIndex - event point index }.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

maximum

Getter for the current scale maximum.

Returns:

number - Current scale maximum.
Setter for scale maximum.

Params:

NameTypeDefaultDescription
valuenumber
null
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

maximumGap

Getter for the current scale maximum gap.

Returns:

number - The current scale maximum gap.
See listing
var scale = chart.xScale();
var currentMaximumGap = scale.maximumGap();
Setter for the scale maximum gap.

Params:

NameTypeDefaultDescription
valuenumber
0.01
Value from 0 to 1.

Returns:

anychart.scales.DateTime - Self instance for method chaining.

minimum

Getter for the current scale minimum.

Returns:

number - Current scale minimum.
Setter for scale minimum.

Params:

NameTypeDefaultDescription
valuenumber
null
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

minimumGap

Getter for the scale minimum gap.

Returns:

number - The current scale minimum gap.
See listing
var scale = chart.xScale();
var currentMinimumGap = scale.minimumGap();
Setter for the scale minimum gap.

Params:

NameTypeDefaultDescription
valuenumber
0.01
Value from 0 to 1.

Returns:

anychart.scales.DateTime - Self instance for method chaining.

pixToDate

Transforms pixels to date.

Params:

NameTypeDescription
pixnumberValue to transform.

Returns:

number - Date value.

removeAllListeners

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

NameTypeDescription
typestringType of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

skipHolidays

Getter for skipping holidays.

Returns:

boolean - State flag.
See listing
var flag = scale.skipHolidays();
Setter for skipping holidays.

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

softMaximum

Getter for the soft maximum.

Returns:

number - Soft maximum.
See listing
var scale = chart.xScale();
var maximum = scale.softMaximum();
Setter for the soft maximum.

Params:

NameTypeDescription
valuenumberValue to set

Returns:

anychart.scales.DateTime - Self instance for method chaining.

softMinimum

Getter for the soft minimum.

Returns:

number - Soft minimum.
See listing
var scale = chart.xScale();
var minimum = scale.softMinimum();
Setter for the soft minimum.

Params:

NameTypeDescription
valuenumberValue to set

Returns:

anychart.scales.DateTime - Self instance for method chaining.

startAutoCalc

Informs scale that an auto range calculation started for the chart, so it should reset its data range on the first call of this method if needed.

startDate

Getter for the start date.

Returns:

number - Start date.

transform

Returns tick position ratio by its name.
Note: returns correct values only after anychart.scales.Base#finishAutoCalc or chart.draw().

Params:

NameTypeDescription
value*Value to transform in input scope.

Returns:

number - Value transformed to scope [0, 1].

unit

Getter for the unit interval.

Returns:

anychart.enums.Interval - Unit interval.
See listing
var currentUnit = scale.unit();
Setter for the unit interval.

Params:

NameTypeDefaultDescription
valueanychart.enums.Interval | string
"day"
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

unitPixSize

Getter for the unit size.

Returns:

number | string - Unit size.
See listing
var size = scale.unitPixSize();
Setter for unit size.

Params:

NameTypeDefaultDescription
valuenumber | string
100
Value to set.

Returns:

anychart.scales.DateTimeWithCalendar - Self instance for method chaining.

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

NameTypeDescription
keyObjectThe key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.