Top
You are looking at an outdated 7.13.1 version of this document. Switch to the 7.14.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:

Name Type Description
adjustOrAdjustByWidth boolean | Array.<boolean> | Object Is font needs to be adjusted in case of 1 argument and adjusted by width in case of 2 arguments.
adjustByHeight boolean Is font needs to be adjusted by height.

Returns:

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

Try it:

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:

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

Returns:

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

Try it:

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:

Name Type Default Description
value boolean
false
Allow or forbid tooltip to leave screen when moving.

Returns:

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

Try it:

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:

Name Type Default Description
value boolean
false
Allow or forbid tooltip to leave stage when moving.

Returns:

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

Try it:

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:

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

Returns:

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

Try it:

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:

Name Type Description
value null | boolean | Object | string Background 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:

Name Type Default Description
value boolean
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:

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

Returns:

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

Try it:

enabled

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

Returns:

boolean - The current element state.

Try it:

Setter for the element enabled state.

Params:

Name Type Default Description
value boolean
true
Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string Value to set.

Returns:

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

Try it:

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:

Name Type Description
value anychart.graphics.vector.Text.Decoration | string Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string Value to set.

Returns:

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

Try it:

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:

Name Type Description
value number Value to set.

Returns:

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

Try it:

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:

Name Type Description
value number | string Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string | anychart.graphics.vector.Text.FontStyle Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string | anychart.graphics.vector.Text.FontVariant Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string | number Value to set.

Returns:

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

Try it:

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:

Name Type Description
value function | string Function 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:

Name Type Description
value string | anychart.graphics.vector.Text.HAlign Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string | number Value to set.

Returns:

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

Try it:

hide

Hides tooltips with delay.

Params:

Name Type Description
force boolean Ignore tooltips hide delay.
event anychart.core.MouseEvent Event that initiate tooltip hiding.

Returns:

boolean - Returns true if the tooltip was hidden.

Try it:

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:

Name Type Default Description
value number
0
Delay in milliseconds.

Returns:

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

Try it:

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:

Name Type Description
value number Value to set.

Returns:

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

Try it:

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:

Name Type Default Description
value number | string
"normal"
Value to set.

Returns:

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

Try it:

listen

Adds an event listener to an implementing object.

Params:

Name Type Description
type string The event type id.
listener function 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 }.
useCapture boolean Whether to fire in capture phase (defaults to false).
listenerScope Object 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 Object Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

Try it:

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:

Name Type Default Description
value number | string
9
Value to set.

Returns:

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

Try it:

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:

Name Type Default Description
value number | string
9
Value to set.

Returns:

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

Try it:

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:

Name Type Description
value number Value to set.

Returns:

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

Try it:

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:

Name Type Description
value number Value to set.

Returns:

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

Try it:

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

Try it:

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:

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

Returns:

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

Try it:

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:

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

Returns:

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

Try it:

print

Prints all elements on related stage.

Params:

Name Type Default Description
paperSizeOrOptions anychart.graphics.vector.PaperSize | Object
Paper size or object with options.
landscape boolean
false
Flag of landscape.

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 text selectable option.

Returns:

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

Params:

Name Type Default Description
value boolean
false
Value to set.

Returns:

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

Try it:

separator

Getter for union tooltip separator.

Returns:

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

Try it:

Setter for union tooltip separator.

Params:

Name Type Description
value null | boolean | Object Separator 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:

Name Type Description
value string | anychart.graphics.vector.Text.Direction Value to set.

Returns:

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

Try it:

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:

Name Type Description
value number Value to set.

Returns:

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

Try it:

textOverflow

Getter for text overflow settings.

Returns:

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

Params:

Name Type Description
value anychart.graphics.vector.Text.TextOverflow | string Value to set

Returns:

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

Try it:

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:

Name Type Description
value Object Few text settings.

Returns:

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

Try it:

Setter for the custom text appearance settings.

Params:

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

Returns:

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

Try it:

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:

Name Type Description
value string | anychart.graphics.vector.Text.TextWrap Value to set.

Returns:

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

Try it:

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:

Name Type Description
value null | boolean | Object Title 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:

Name Type Default Description
value function | 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.

Try it:

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:

Name Type Description
value function | string Function 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:

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 Object 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 useHTML flag.

Returns:

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

Params:

Name Type Description
value boolean Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string | anychart.graphics.vector.Text.VAlign Value to set.

Returns:

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

Try it:

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:

Name Type Default Description
value string
''
Value to set.

Returns:

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

Try it:

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:

Name Type Default Description
value string
''
Value to set.

Returns:

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

Try it:

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:

Name Type Description
value string | number Value to set.

Returns:

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

Try it:

zIndex

Getter for the current Z-index of the element.

Returns:

number - The current zIndex.

Try it:

Setter for the Z-index of the element.

Params:

Name Type Default Description
value number
0
Value to set.

Returns:

anychart.core.VisualBase - Self instance for method chaining.

Try it: