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

class anychart.core.ui.Tooltip Improve this Doc

Extends: anychart.core.VisualBase

Class for the tooltip.

Methods Overview

Specific settings
allowLeaveChart()Tooltip allowLeaveChart settings.
allowLeaveScreen()Tooltip allowLeaveScreen settings.
allowLeaveStage()Tooltip allowLeaveStage settings.
displayMode()Display mode settings.
format()Function to format content text.
hide()Hides tooltips with delay.
hideDelay()Hide delay settings.
titleFormat()Function to format title text.
unionFormat()Function to format content text.
valuePostfix()Postfix settings.
valuePrefix()Prefix settings.
Content Text Settings
disablePointerEvents()Pointer events settings.
fontColor()Font color settings.
fontDecoration()Font decoration setting.
fontFamily()Font family settings.
fontOpacity()Font opacity settings.
fontSize()Font size settings.
fontStyle()Font style settings.
fontVariant()Font variant settings.
fontWeight()Font weight settings.
hAlign()Text horizontal align settings.
letterSpacing()Text letter spacing settings.
lineHeight()Text line height setting.
selectable()Text selectable option.
textDirection()Text direction settings.
textIndent()Text indent settings.
textOverflow()Text overflow settings.
textSettings()Font opacity setting.
textWrap()Text wrap setting.
useHtml()Use HTML option.
vAlign()Text vertical align 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.
Export
print()Prints all elements.
Interactivity
enabled()Element state (enabled or disabled).
Size and Position
anchor()Anchor settings.
height()Tooltip height.
offsetX()X offset settings.
offsetY()Y offset settings.
padding()Padding settings.
position()Position settings.
positionMode()Position mode settings.
width()Tooltip width.
zIndex()Z-index of the element.
Text Settings
adjustFontSize()Adjusting settings.
maxFontSize()Maximum font size settings.
minFontSize()Minimum font size settings.
Visual settings
background()Background settings.
separator()Separator settings.
title()Title settings.

Methods Description

adjustFontSize

Getter for the adjusting font size.

Returns:

number - An adjusted font size.
See listing
var tooltip = chart.tooltip();
var adjustFontSize = tooltip.adjustFontSize();
Setter for the adjusting font size.

Params:

NameTypeDescription
adjustOrAdjustByWidthboolean | Array.<boolean> | ObjectIs font needs to be adjusted in case of 1 argument and adjusted by width in case of 2 arguments.
adjustByHeightbooleanIs font needs to be adjusted by height.

Returns:

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

allowLeaveChart

Getter for the allowLeaveChart tooltip mode.

Returns:

boolean - Boolean value.
Example
var tooltipSettings = chart.tooltip();
var value = tooltipSettings.allowLeaveChart();
Setter for the allowLeaveChart tooltip mode.

Params:

NameTypeDefaultDescription
valueboolean
true
Allow or forbid tooltip to leave chart when moving.

Returns:

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

allowLeaveScreen

Getter for the allowLeaveScreen tooltip mode.

Returns:

boolean - Boolean value.
Example
var tooltipSettings = chart.tooltip();
var value = tooltipSettings.allowLeaveScreen();
Setter for the allowLeaveScreen tooltip mode.

Params:

NameTypeDefaultDescription
valueboolean
false
Allow or forbid tooltip to leave screen when moving.

Returns:

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

allowLeaveStage

Getter for the allowLeaveStage tooltip mode.

Returns:

boolean - Boolean value.
Example
var tooltipSettings = chart.tooltip();
var value = tooltipSettings.allowLeaveStage();
Setter for the allowLeaveStage tooltip mode.

Params:

NameTypeDefaultDescription
valueboolean
false
Allow or forbid tooltip to leave stage when moving.

Returns:

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

anchor

Getter for the tooltip anchor.

Returns:

anychart.enums.Anchor | string - Tooltip anchor settings.
Example
var tooltip = chart.tooltip();
var anchor = tooltip.anchor();
Setter for the tooltip anchor.

Params:

NameTypeDefaultDescription
valueanychart.enums.Anchor | string
"centerBottom"
Value to set.

Returns:

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

background

Getter for tooltip background settings.

Returns:

anychart.core.ui.Background - An instance of the class for method chaining.
See listing
var tooltip = chart.tooltip();
var background = tooltip.background();
Setter for tooltip background settings.

Params:

NameTypeDescription
valuenull | boolean | Object | stringBackground settings.

Returns:

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

disablePointerEvents

Getter for the pointer events settings.

Returns:

boolean - The pointer events settings.
See listing
var tooltip = chart.tooltip();
var disablePointerEvents = tooltip.disablePointerEvents();
Setter for the pointer events setting.

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

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

displayMode

Getter for display mode settings.

Returns:

anychart.enums.TooltipDisplayMode - Display mode.
See listing
var tooltip = chart.tooltip();
var displayMode = tooltip.displayMode();
Setter for display mode settings. Note: Works only for the chart tooltip.

Params:

NameTypeDefaultDescription
valueanychart.enums.TooltipDisplayMode | string
"single"
Value to set.

Returns:

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

enabled

Getter for the current element state (enabled or disabled).

Returns:

boolean - The current element state.
Setter for the element enabled state.

Params:

NameTypeDefaultDescription
valueboolean
true
Value to set.

Returns:

anychart.core.ui.Tooltip - Self instance for method chaining.
Example.
if (!element.enabled())
   element.enabled(true);

fontColor

Getter for font color settings.

Returns:

string - Font color settings.
Example
var tooltip = chart.tooltip();
var fontColor = tooltip.fontColor();
Setter for font color settings.

Params:

NameTypeDescription
valuestringValue to set.

Returns:

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

fontDecoration

Getter for font decoration settings.

Returns:

anychart.graphics.vector.Text.Decoration - Font decoration settings.
Example
var tooltip = chart.tooltip();
var fontDecoration = tooltip.fontDecoration();
Setter for font decoration settings.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.Decoration | stringValue to set.

Returns:

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

fontFamily

Getter for font family settings.

Returns:

string - Font family settings.
See listing
var tooltip = chart.tooltip();
var fontFamily = tooltip.fontFamily();
Setter for font family settings.

Params:

NameTypeDescription
valuestringValue to set.

Returns:

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

fontOpacity

Getter for font opacity settings.

Returns:

number - Font opacity settings.
Example
var tooltip = chart.tooltip();
var fontOpacity = tooltip.fontOpacity();
Setter for font opacity settings.

Params:

NameTypeDescription
valuenumberValue to set.

Returns:

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

fontSize

Getter for font size settings.

Returns:

number - Font size settings.
Example
var tooltip = chart.tooltip();
var fontSize = tooltip.fontSize();
Setter for font size settings.

Params:

NameTypeDescription
valuenumber | stringValue to set.

Returns:

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

fontStyle

Getter for font style settings.

Returns:

anychart.graphics.vector.Text.FontStyle - Font style settings.
Example
var tooltip = chart.tooltip();
var fontStyle = tooltip.fontStyle();
Setter for font style settings.

Params:

NameTypeDescription
valuestring | anychart.graphics.vector.Text.FontStyleValue to set.

Returns:

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

fontVariant

Getter for font variant settings.

Returns:

anychart.graphics.vector.Text.FontVariant - Font variant settings.
Example
var tooltip = chart.tooltip();
var fontVariant = tooltip.fontVariant();
Setter for font variant settings.

Params:

NameTypeDescription
valuestring | anychart.graphics.vector.Text.FontVariantValue to set.

Returns:

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

fontWeight

Getter for font weight settings.

Returns:

string | number - Font weight settings.
Example
var tooltip = chart.tooltip();
var fontWeight = tooltip.fontWeight();
Setter for font weight settings.

Params:

NameTypeDescription
valuestring | numberValue to set.

Returns:

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

format

Getter for function content text for the tooltip.

Returns:

function | string - Function to format title text.
Example
var tooltipSettings = chart.tooltip();
var formatter = tooltipSettings.textFormatter();
Setter for function content text for the tooltip.
Learn more about using format() method.

Params:

NameTypeDescription
valuefunction | stringFunction or string token to format content text.

Returns:

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

hAlign

Getter for text horizontal align settings.

Returns:

anychart.graphics.vector.Text.HAlign - Horizontal align settings.
Example
var tooltip = chart.tooltip();
var hAlign = tooltip.hAlign();
Setter for the text horizontal align settings.

Params:

NameTypeDescription
valuestring | anychart.graphics.vector.Text.HAlignValue to set.

Returns:

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

height

Getter for the tooltip height.

Returns:

string | number - Tooltip height.
Example
var tooltipSettings = chart.tooltip();
var height = tooltipSettings.height();
Setter for the tooltip height.

Params:

NameTypeDescription
valuestring | numberValue to set.

Returns:

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

hide

Hides tooltips with delay.

Params:

NameTypeDescription
forcebooleanIgnore tooltips hide delay.
eventanychart.core.MouseEventEvent that initiate tooltip hiding.

Returns:

boolean - Returns true if the tooltip was hidden.

hideDelay

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

Returns:

number - Hide delay settings.
Example
var tooltip = chart.tooltip();
var hideDelay = tooltip.hideDelay();
Setter for the delay in milliseconds before a tooltip becomes hidden.

Params:

NameTypeDefaultDescription
valuenumber
0
Delay in milliseconds.

Returns:

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

letterSpacing

Getter for text letter spacing settings.

Returns:

number - Letter spacing settings.
Example
var tooltip = chart.tooltip();
var letterSpacing = tooltip.letterSpacing();
Setter for text letter spacing settings.

Params:

NameTypeDescription
valuenumberValue to set.

Returns:

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

lineHeight

Getter for text line height settings.

Returns:

number | string - Line height settings.
Example
var tooltip = chart.tooltip();
var lineHeight = tooltip.lineHeight();
Setter for text line height settings.

Params:

NameTypeDefaultDescription
valuenumber | string
"normal"
Value to set.

Returns:

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

listen

Adds an event listener to an implementing object.

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback 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 }.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeObjectObject in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener to an implementing object.

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeObjectObject in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

maxFontSize

Getter for maximum font size settings for adjust text from.

Returns:

number - Maximum font size.
Example
var tooltip = chart.tooltip();
var maxFontSize = tooltip.maxFontSize();
Setter for maximum font size settings for adjust text from.

Params:

NameTypeDefaultDescription
valuenumber | string
9
Value to set.

Returns:

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

minFontSize

Getter for minimum font size settings for adjust text from.

Returns:

number - Minimum font size.
Example
var tooltip = chart.tooltip();
var minFontSize = tooltip.minFontSize();
Setter for minimum font size settings for adjust text from.

Params:

NameTypeDefaultDescription
valuenumber | string
9
Value to set.

Returns:

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

offsetX

Getter for the tooltip offset by X.

Returns:

number - Tooltip offset by X.
Example
var tooltip = chart.tooltip();
var offsetX = tooltip.offsetX();
Setter for union tooltip offsetX.

Params:

NameTypeDescription
valuenumberValue to set.

Returns:

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

offsetY

Getter for the tooltip offset by Y.

Returns:

number - Tooltip offset by Y.
Example
var tooltip = chart.tooltip();
var offsetY = tooltip.offsetY();
Setter for the tooltip offset by Y.

Params:

NameTypeDescription
valuenumberValue to set.

Returns:

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

padding

Setter for tooltip padding in pixels by one value.

Params:

NameTypeDefaultDescription
valueArray.<(number|string)> | Object
{top: 5, right: 10, bottom: 5, left: 10}
Value to set.

Returns:

anychart.core.ui.Tooltip - Self instance for method chaining.
Setter for tooltip padding in pixels.

Params:

NameTypeDefaultDescription
value1string | number
5
Top or top-bottom space.
value2string | number
10
Right or right-left space.
value3string | number
5
Bottom space.
value4string | number
10
Left space.

Returns:

anychart.core.ui.Tooltip - 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);

position

Getter for union tooltip position.

Returns:

anychart.enums.Position | string - Tooltip position.
Example
var tooltip = chart.tooltip();
var position = tooltip.position();
Setter for union tooltip position.
Note: Do not works with position mode FLOAT.

Params:

NameTypeDescription
valueanychart.enums.Position | stringValue to set.

Returns:

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

positionMode

Getter for all tooltips position mode.

Returns:

string - Position mode.
Example
var tooltip = chart.tooltip();
var positionMode = tooltip.positionMode();
Setter for all tooltips position mode.

Params:

NameTypeDescription
valuestring | anychart.enums.TooltipPositionModeValue to set.

Returns:

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

print

Prints all elements on related stage.

Params:

NameTypeDefaultDescription
paperSizeOrOptionsanychart.graphics.vector.PaperSize | Object
Paper size or object with options.
landscapeboolean
false
Flag of landscape.

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.

selectable

Getter for the text selectable option.

Returns:

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

Params:

NameTypeDefaultDescription
valueboolean
false
Value to set.

Returns:

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

separator

Getter for union tooltip separator.

Returns:

anychart.core.ui.Separator - An instance of the class for method chaining.
Setter for union tooltip separator.

Params:

NameTypeDescription
valuenull | boolean | ObjectSeparator settings.

Returns:

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

textDirection

Getter for the text direction settings.

Returns:

anychart.graphics.vector.Text.Direction - Text direction settings.
Example
var tooltip = chart.tooltip();
var fontOpacity = tooltip.fontOpacity();
Setter for text direction settings.

Params:

NameTypeDescription
valuestring | anychart.graphics.vector.Text.DirectionValue to set.

Returns:

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

textIndent

Getter for text-indent settings.

Returns:

number - Text indent settings.
Example
var tooltip = chart.tooltip();
var textIndent = tooltip.textIndent();
Setter for text-indent settings.

Params:

NameTypeDescription
valuenumberValue to set.

Returns:

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

textOverflow

Getter for text overflow settings.

Returns:

anychart.graphics.vector.Text.TextOverflow - Text overflow settings
Setter for text overflow settings.

Params:

NameTypeDescription
valueanychart.graphics.vector.Text.TextOverflow | stringValue to set

Returns:

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

textSettings

Getter for the full text appearance settings.

Returns:

Object | string | number | boolean - Text settings.
Example
var tooltip = chart.tooltip();
var textSettings = tooltip.textSettings();
Setter for the full text appearance settings.

Params:

NameTypeDescription
valueObjectFew text settings.

Returns:

anychart.core.ui.Tooltip - Self instance for method chaining.
Setter for the custom text appearance settings.

Params:

NameTypeDescription
namestringText settings name.
valuestring | number | booleanValue to set.

Returns:

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

textWrap

Getter for text wrap settings.

Returns:

anychart.graphics.vector.Text.TextWrap - Text wrap settings.
Example
var tooltip = chart.tooltip();
var textWrap = tooltip.textWrap();
Setter for text wrap settings.

Params:

NameTypeDescription
valuestring | anychart.graphics.vector.Text.TextWrapValue to set.

Returns:

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

title

Getter for union tooltip title visual settings.

Returns:

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

Params:

NameTypeDescription
valuenull | boolean | ObjectTitle settings.

Returns:

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

titleFormat

Getter for the function to format title.

Returns:

function | string - Function to format title text.
Example
var tooltipSettings = chart.tooltip();
var formatter = tooltipSettings.titleFormat();
Setter for the function to format title.
Note: Use anychart.core.ui.Tooltip#title method to set title visual settings.

Params:

NameTypeDefaultDescription
valuefunction | string
function() {return 'Tooltip';}
Function to format title text. Function that looks like function(){ // this.clientX - X coordinate of the mouse // this.clientY - Y coordinate of the mouse // this.formattedValues - array of the formatted values for the tooltip // this.points - array of the series points // this.allPoints - array of the all points // this.titleText - tooltip title text return titleFormatValue; // type Function }.

Returns:

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

unionFormat

Getter for function content text for union tooltip.

Returns:

function | string - Function to format title text.
Example
var tooltipSettings = chart.tooltip();
var formatter = tooltipSettings.unionFormat();
Setter for function content text for union tooltip.
Learn more about using unionFormat() method.

Params:

NameTypeDescription
valuefunction | stringFunction or string token to format content text.

Returns:

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

unlisten

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

Params:

NameTypeDescription
typestringThe event type id.
listenerfunctionCallback method.
useCapturebooleanWhether to fire in capture phase (defaults to false).
listenerScopeObjectObject 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.

useHtml

Getter for the useHTML flag.

Returns:

boolean - UseHTML flag.
Example
var tooltip = chart.tooltip();
var useHtml = tooltip.useHtml();
Setter for the useHTML flag.

Params:

NameTypeDescription
valuebooleanValue to set.

Returns:

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

vAlign

Getter for text vertical align settings.

Returns:

anychart.graphics.vector.Text.VAlign - Vertical align.
Example
var tooltip = chart.tooltip();
var vAlign = tooltip.vAlign();
Setter for text vertical align settings.

Params:

NameTypeDescription
valuestring | anychart.graphics.vector.Text.VAlignValue to set.

Returns:

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

valuePostfix

Getter for tooltip postfix value.

Returns:

string - Postfix settings.
See listing
var tooltip = series.tooltip();
var valuePostfix = tooltip.valuePostfix();
Setter for tooltip postfix value.

Params:

NameTypeDefaultDescription
valuestring
''
Value to set.

Returns:

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

valuePrefix

Getter for tooltip prefix value.

Returns:

string - Current prefix settings.
See listing
var tooltip = series.tooltip();
var valuePrefix = tooltip.valuePrefix();
Setter for tooltip prefix value.

Params:

NameTypeDefaultDescription
valuestring
''
Value to set.

Returns:

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

width

Getter for the tooltip width.

Returns:

string | number - Tooltip width.
Example
var tooltipSettings = chart.tooltip();
var width = tooltipSettings.width();
Setter for the tooltip width.

Params:

NameTypeDescription
valuestring | numberValue to set.

Returns:

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

zIndex

Getter for the current Z-index of the element.

Returns:

number - The current zIndex.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
valuenumber
0
Value to set.

Returns:

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