Top
You are looking at an outdated 7.9.0 version of this document. Switch to the 7.14.3 version to see the up to date information.

class anychart.core.utils.Space Improve this Doc

Extends: anychart.core.Base

Stores space info for 4 sides. Can accept numbers and strings as side spaces. For initializing values meaning see set() method.

Methods Overview

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.
Size and Position
bottom()Gets or sets bottom space. Returns previously set space, not the derived pixel value.
left()Gets or sets left space. Returns previously set space, not the derived pixel value.
right()Gets or sets right space. Returns previously set space, not the derived pixel value.
top()Gets or sets top space. Returns previously set space, not the derived pixel value.
Specific settings Can accept other Space object or from 0 to 4 values (numbers or percent strings). Space values are applied just as in CSS: 1) set(25, 50, 75, 100): top space is 25 right space is 50 bottom space is 75 left space is 100 2) set(25, 50, 75): top space is 25 right and left spaces are 50 bottom space is 75 3) set(25, 50): top and bottom spaces are 25 right and left spaces are 50 4) set(25): all four spaces are 25 Also can accept arrays (applied, like it is an apply) and objects with 'left', 'top', 'right' and 'bottom' fields. NOTE: set(): all four spaces are 0
set()Resets all offsets using values passed.

Methods Description

bottom

Gets or sets bottom space. Returns previously set space, not the derived pixel value.

Params:

Name Type Description
value number | string | null Value to set.

Returns:

number string anychart.core.utils.Space - Value or itself for chaining.

left

Gets or sets left space. Returns previously set space, not the derived pixel value.

Params:

Name Type Description
value number | string | null Value to set.

Returns:

number string anychart.core.utils.Space - Value, or itself for chaining.

listen

Adds an event listener to an implementing object.

Params:

Name Type Description
type string The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope scope Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

Try it:

listenOnce

Adds an event listener to an implementing object.

Params:

Name Type Description
type string The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope scope Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

Try it:

removeAllListeners

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

Params:

Name Type Description
type string Type of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.

Try it:

Gets or sets right space. Returns previously set space, not the derived pixel value.

Params:

Name Type Description
value number | string | null Value to set.

Returns:

number string anychart.core.utils.Space - Value or itself for chaining.

set

Resets all offsets using values passed.

Params:

Name Type Description
spaceOrTopOrTopAndBottom string | number | Array.<(number|string)> | Object Space object or top or top and bottom space.
rightOrRightAndLeft string | number Right or right and left space.
bottom string | number Bottom space.
left string | number Left space.

Returns:

anychart.core.utils.Space - Returns itself for chaining.

top

Gets or sets top space. Returns previously set space, not the derived pixel value.

Params:

Name Type Description
value number | string | null Value to set.

Returns:

number string anychart.core.utils.Space - Value or itself for method chaining.

unlisten

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

Params:

Name Type Description
type string The event type id.
listener function Callback method.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope scope Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

Try it:

unlistenByKey

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

Params:

Name Type Description
key Object The key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

Try it: