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

class anychart.core.ui.ChartTooltip Improve this Doc

Extends: anychart.core.Base

Class for the chart tooltip.

Methods Overview

Specific settings
allowLeaveChart()Leaving chart settings.
displayMode()Display mode settings.
enabled()Disable or enable tooltip.
hideDelay()Hide delay settings.
textFormatter()Function to format content text.
titleFormatter()Function to format title text.
Content Text Settings
disablePointerEvents()Pointer events setting.
fontColor()Font color setting.
fontDecoration()Font decoration setting.
fontFamily()Font family setting.
fontOpacity()Font opacity setting.
fontSize()Font size setting.
fontStyle()Font style setting.
fontVariant()Font variant setting.
fontWeight()Font weight setting.
hAlign()Text horizontal align setting.
letterSpacing()Text letter spacing setting.
lineHeight()Text line height setting.
selectable()Text selectable option.
textDirection()Text direction setting.
textIndent()Text indent setting.
textSettings()Font opacity setting.
textWrap()Text wrap setting.
useHtml()Use HTML option.
vAlign()Text vertical align setting.
Events
listen()Adds an event listener.
listenOnce()Adds a single time event listener.
removeAllListeners()Remove all listeners.
unlisten()Remove of the listener.
unlistenByKey()Remove of the listener by the key.
Size and Position
anchor()Anchor settings.
offsetX()X offset settings.
offsetY()Y offset settings.
padding()Padding settings.
position()Position settings.
positionMode()Position mode settings.
Visual settings
background()Background settings.
separator()Separator settings.
title()Title settings.

Methods Description

allowLeaveChart

Getter for tooltip leaving chart settings.

Returns:

boolean - Current settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.allowLeaveChart();
Setter for tooltip leaving chart settings.

Params:

Name Type Default Description
value boolean
true
Allow or disallow tooltip to leave chart when moving.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

anchor

Getter for union tooltip anchor.

Returns:

anychart.enums.Anchor - Current position settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.anchor();
Setter for union tooltip anchor.

Params:

Name Type Default Description
value anychart.enums.Anchor | string
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

background

Getter for union tooltip background settings.

Returns:

anychart.core.ui.Background - An instance of class for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.background();
Setter for union tooltip background settings.

Params:

Name Type Default Description
value null | boolean | Object | string
depends on theme
Background settings.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

disablePointerEvents

Getter for the pointer events setting.

Returns:

boolean - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.disablePointerEvents();
Setter for the pointer events setting.

Params:

Name Type Default Description
value boolean
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.disablePointerEvents(false);

displayMode

Getter for display mode settings for tooltip.

Returns:

anychart.enums.TooltipDisplayMode - Current display mode.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.displayMode();
Setter for display mode settings for tooltip.

Params:

Name Type Default Description
value anychart.enums.TooltipDisplayMode | string
'single'
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

enabled

Getter for all tooltips state.

Returns:

boolean - Current hide delay settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.enabled();
Setter for all tooltips state.

Params:

Name Type Default Description
value boolean
0
Disable or enable tooltip.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

fontColor

Getter for the current font color setting.

Returns:

string - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontSize();
Setter for the font color setting.

Params:

Name Type Default Description
value string
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontColor('red');

fontDecoration

Getter for the current font decoration setting.

Returns:

anychart.graphics.vector.Text.Decoration - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontDecoration();
Setter for the font decoration setting.

Params:

Name Type Default Description
value anychart.graphics.vector.Text.Decoration | string
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontDecoration(0.2);

fontFamily

Getter for the current font family setting.

Returns:

string - Current value.
See listing
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontSize();
Setter for the font family setting.

Params:

Name Type Default Description
value string
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontFamily('Tahoma');

fontOpacity

Getter for the current font opacity setting.

Returns:

number - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontOpacity();
Setter for the font opacity setting.

Params:

Name Type Default Description
value number
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontOpacity(0.2);

fontSize

Getter for the current font size setting.

Returns:

number - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontSize();
Setter for the font size setting.

Params:

Name Type Default Description
value number | string
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

fontStyle

Getter for the current font style setting.

Returns:

anychart.graphics.vector.Text.FontStyle - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontStyle();
Setter for the font style setting.

Params:

Name Type Default Description
value string | anychart.graphics.vector.Text.FontStyle
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontStyle('italic');

fontVariant

Getter for the current font variant setting.

Returns:

anychart.graphics.vector.Text.FontVariant - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontVariant();
Setter for the font variant setting.

Params:

Name Type Default Description
value string | anychart.graphics.vector.Text.FontVariant
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontVariant('small-caps');

fontWeight

Getter for the current font weight setting.

Returns:

string number - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontWeight();
Setter for the font weight setting.

Params:

Name Type Default Description
value string | number
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontWeight(600);

hAlign

Getter for the current text horizontal align setting.

Returns:

anychart.graphics.vector.Text.HAlign - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.hAlign();
Setter for the text horizontal align setting.

Params:

Name Type Default Description
value string | anychart.graphics.vector.Text.HAlign
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.hAlign(0.2);

hideDelay

Getter for delay in milliseconds before union tooltip item becomes hidden.

Returns:

number - Current hide delay settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.hideDelay();
Setter for delay in milliseconds before union tooltip item becomes hidden.

Params:

Name Type Default Description
value number
0
Delay in milliseconds.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

letterSpacing

Getter for the current text letter spacing setting.

Returns:

number - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.letterSpacing();
Setter for the text letter spacing setting.

Params:

Name Type Default Description
value number
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.letterSpacing(0.2);

lineHeight

Getter for the current text line height setting.

Returns:

number string - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.lineHeight();
Setter for the text line height setting.

Params:

Name Type Default Description
value number | string
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.lineHeight(1.1);

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:

offsetX

Getter for union tooltip offsetX.

Returns:

number - Current offsetX settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.offsetX();
Setter for union tooltip offsetX.

Params:

Name Type Default Description
value number
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

offsetY

Getter for union tooltip offsetY.

Returns:

number - Current offsetY settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.offsetY();
Setter for union tooltip offsetY.

Params:

Name Type Default Description
value number
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

padding

Getter for the current tooltip padding.

Returns:

anychart.core.utils.Padding - Current label padding.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.padding();
Setter for tooltip padding in pixels by one value.

Params:

Name Type Default Description
value Array.<(number|string)> | Object
{top: 5, right: 10, bottom: 5, left: 10}
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

Setter for tooltip padding in pixels.

Params:

Name Type Default Description
value1 string | number
5
Top or top-bottom space.
value2 string | number
10
Right or right-left space.
value3 string | number
5
Bottom space.
value4 string | number
10
Left space.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
// 1) top and bottom 10px, left and right 15px
label.padding(10, '15px');
// 2) top 10px, left and right 15px, bottom 5px
label.padding(10, '15px', 5);
// 3) top 10px, right 15px, bottom 5px, left 12px
label.padding(10, '15px', '5px', 12);

Try it:

position

Getter for union tooltip position.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.position();
Setter for union tooltip position.
Note: Do not works with position mode FLOAT.

Params:

Name Type Default Description
value anychart.enums.Position | string
Value to set.

Try it:

positionMode

Getter for all tooltips position mode.

Returns:

string - Current offsetY settings.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.positionMode();
Setter for all tooltips position mode.

Params:

Name Type Default Description
value string | anychart.enums.TooltipPositionMode
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

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:

selectable

Getter for the current text selectable option.

Returns:

boolean - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.selectable();
Setter for the text selectable option.

Params:

Name Type Default Description
value boolean
false
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.selectable(false);

separator

Getter for union tooltip separator.

Returns:

anychart.core.ui.Separator - An instance of class for method chaining.

Try it:

Setter for union tooltip separator.

Params:

Name Type Default Description
value null | boolean | Object
Separator settings.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

textDirection

Getter for the current text direction setting.

Returns:

anychart.graphics.vector.Text.Direction - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.fontOpacity();
Setter for the text direction setting.

Params:

Name Type Default Description
value string | anychart.graphics.vector.Text.Direction
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.fontOpacity('rtl');

textFormatter

Getter for function content text for union tooltip.

Returns:

function - Function to format title text.
Example
var currentTooltipSettings = chart.tooltip();
var currentFormatter = currentTooltipSettings.textFormatter();
Setter for function content text for union tooltip.

Params:

Name Type Default Description
value function
function() {return this['formattedValues'].join('\n');}
Function to format content text.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

textIndent

Getter for the current text indent setting.

Returns:

number - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.textIndent();
Setter for the text indent setting.

Params:

Name Type Default Description
value number
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.textIndent(0.2);

textSettings

Getter for the full text appearance settings.

Returns:

number - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.textSettings();
Setter for the full text appearance settings.

Params:

Name Type Description
value Object Few text settings.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

Setter for the custom text appearance settings.

Params:

Name Type Description
name string Settings Text settings name.
value string | number | boolean Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

textWrap

Getter for the current text wrap setting.

Returns:

anychart.graphics.vector.Text.TextWrap - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.textWrap();
Setter for the text wrap setting.

Params:

Name Type Default Description
value string | anychart.graphics.vector.Text.TextWrap
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.textWrap('noWrap');

title

Getter for union tooltip title visual settings.

Returns:

anychart.core.ui.Title - An instance of class for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.title();
Setter for union tooltip title visual settings.

Params:

Name Type Default Description
value null | boolean | Object
Title settings.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

titleFormatter

Getter for function to format title for union tooltip.

Returns:

function - Function to format title text.
Example
var currentTooltipSettings = chart.tooltip();
var currentFormatter = currentTooltipSettings.titleFormatter();
Setter for function to format title for union tooltip. Note: use method anychart.core.ui.ChartTooltip#title to set title visual settings.

Params:

Name Type Default Description
value function
function() {return 'Union Tooltip';}
Function to format title text.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

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:

useHtml

Getter for the current the useHTML flag.

Returns:

boolean - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.useHtml();
Setter for the useHTML flag.

Params:

Name Type Default Description
value boolean
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.

Try it:

vAlign

Getter for the current text vertical align setting.

Returns:

anychart.graphics.vector.Text.VAlign - Current value.
Example
var currentTooltipSettings = chart.tooltip();
var currentValue = currentTooltipSettings.vAlign();
Setter for the text vertical align setting.

Params:

Name Type Default Description
value string | anychart.graphics.vector.Text.VAlign
depends on theme
Value to set.

Returns:

anychart.core.ui.ChartTooltip - Self instance for method chaining.
Example
var currentTooltipSettings = chart.tooltip();
currentTooltipSettings.vAlign('top');