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

class anychart.core.ui.SeriesTooltip Improve this Doc

Extends: anychart.core.VisualBase

Class for series tooltip.

Methods Overview

Specific settings
hide()Hides tooltips with delay.
hideDelay()Hide delay settings.
textFormatter()Function to format content text.
titleFormatter()Function to format title text.
valuePostfix()Postfix settings.
valuePrefix()Prefix settings.
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()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.
offsetX()X offset settings.
offsetY()Y offset settings.
padding()Padding settings.
position()Position settings.
zIndex()Z-index of the element.
Visual settings
background()Background settings.
separator()Separator settings.
title()Position mode settings.
Miscellaneous
textOverflow()Getter/Setter for the text overflow settings.

Methods Description

anchor

Getter for tooltip anchor.

Returns:

anychart.enums.Anchor - Current anchor settings.
See listing
var currentTooltipSettings = series.tooltip();
var currentValue = currentTooltipSettings.anchor();
Setter for tooltip anchor.

Params:

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

Returns:

anychart.core.ui.SeriesTooltip - 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.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.

disablePointerEvents

Getter for the current pointer events setting.

Returns:

number - Current value.
See listing
var currentTooltipSettings = series.tooltip();
var currentValue = currentTooltipSettings.disablePointerEvents();
Setter for the pointer events setting.

Params:

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

Returns:

anychart.core.ui.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.disablePointerEvents(false);

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 the current font color setting.

Returns:

string - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontColor('red');

fontDecoration

Getter for the current font decoration setting.

Returns:

anychart.graphics.vector.Text.Decoration - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontDecoration(0.2);

fontFamily

Getter for the current font family setting.

Returns:

string - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontFamily('Tahoma');

fontOpacity

Getter for the current font opacity setting.

Returns:

number - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontOpacity(0.2);

fontSize

Getter for the current font size setting.

Returns:

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

Params:

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

Returns:

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

Try it:

fontStyle

Getter for the current font style setting.

Returns:

anychart.graphics.vector.Text.FontStyle - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontStyle('italic');

fontVariant

Getter for the current font variant setting.

Returns:

anychart.graphics.vector.Text.FontVariant - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontVariant('small-caps');

fontWeight

Getter for the current font weight setting.

Returns:

string number - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontWeight(600);

hAlign

Getter for the current text horizontal align setting.

Returns:

anychart.graphics.vector.Text.HAlign - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.hAlign(0.2);

hide

Hides tooltips with delay.

Params:

Name Type Description
force boolean Ignore tooltips hide delay.
event anychart.core.MouseEvent Event that initiates 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 - Current hide delay settings.
See listing
var currentTooltipSettings = series.tooltip();
var currentValue = currentTooltipSettings.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.SeriesTooltip - Self instance for method chaining.

Try it:

letterSpacing

Getter for the current text letter spacing setting.

Returns:

number - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.letterSpacing(0.2);

lineHeight

Getter for the current text line height setting.

Returns:

number string - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.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. 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 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 tooltip offsetX.

Returns:

number - Current anchor settings.
See listing
var currentTooltipSettings = series.tooltip();
var currentValue = currentTooltipSettings.offsetX();
Setter for tooltip offsetX.

Params:

Name Type Default Description
value number
Value to set.

Returns:

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

Try it:

offsetY

Getter for tooltip offsetY.

Returns:

number - Current anchor settings.
See listing
var currentTooltipSettings = series.tooltip();
var currentValue = currentTooltipSettings.offsetY();
Setter for tooltip offsetY.

Params:

Name Type Default Description
value number
Value to set.

Returns:

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

Try it:

padding

Getter for the current tooltip padding.

Returns:

anychart.core.utils.Padding - Current label padding.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - 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.SeriesTooltip - Self instance for method chaining.
See listing 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 tooltip position.

Returns:

anychart.enums.Position - Current position settings.
See listing
var currentTooltipSettings = series.tooltip();
var currentValue = currentTooltipSettings.position();
Setter for tooltip position.

Params:

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

Returns:

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

Try it:

print

Prints all elements on related stage.

Params:

Name Type Default Description
paperSize anychart.graphics.vector.PaperSize
Paper size.
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 current text selectable option.

Returns:

boolean - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.selectable(false);

separator

Getter for tooltip separator.

Returns:

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

Try it:

Setter for tooltip separator.

Params:

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

Returns:

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

textDirection

Getter for the current text direction setting.

Returns:

anychart.graphics.vector.Text.Direction - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.fontOpacity('rtl');

textFormatter

Getter for the current formatter content text for union tooltip.

Returns:

function string - Function to format title text.
See listing
var currentTooltipSettings = series.tooltip();
var currentFormatter = currentTooltipSettings.textFormatter();
Setter for formatter content text for union tooltip.

Params:

Name Type Default Description
value string
function() {return this.x+": "+this.valuePrefix+this.value+this.valuePostfix;}
String token to format content text.

Returns:

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

Try it:

Setter for formatter content text using function.

Params:

Name Type Default Description
formatterFunction function
function() {return this.x+": "+this.valuePrefix+this.value+this.valuePostfix;}
Function to format content text. Function that looks like function(){ For discrete series (bar, column etc) and continuous series (area, line etc): // this.index - series index // this.series - current chart series // this.seriesName - series name // this.value - series point value // this.valueLowerError - lower value for the series error // this.valuePostfix - tooltip postfix value // this.valuePrefix - tooltip prefix value // this.valueUpperError - upper value for the series error // this.x - series point x // this.xLowerError - lower x for the series error // this.xUpperError - upper x for the series error For discrete series: // this.clientX - X coordinate of the mouse // this.clientY - Y coordinate of the mouse For SeriesPointContextProvider Series Point Context Provider // this.getDataValue() - data value // this.getSeriesMeta() - series meta // this.getStat() - statistics from data // this.getTokenType() - token type // this.getTokenValue() - token value return textFormatterValue; // type Function or string }.

Returns:

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

Try it:

textIndent

Getter for the current text indent setting.

Returns:

number - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.textIndent(0.2);

textOverflow

Getter/Setter for the text overflow settings.

Params:

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

textSettings

Getter for the full text appearance settings.

Returns:

number - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - 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.SeriesTooltip - Self instance for method chaining.

Try it:

textWrap

Getter for the current text wrap setting.

Returns:

anychart.graphics.vector.Text.TextWrap - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.textWrap('noWrap');

title

Getter for union tooltip title visual settings.

Returns:

anychart.core.ui.Title - An instance of class for method chaining.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.

titleFormatter

Getter for function to format title for union tooltip.

Returns:

function - Function to format title text.
See listing
var currentTooltipSettings = series.tooltip();
var currentFormatter = currentTooltipSettings.titleFormatter();
Setter for function to format title for union tooltip.

Params:

Name Type Default Description
value function
function() {return this.seriesName;}
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.index - series point index // this.series - current chart series // this.seriesName - series name // this.titleText - title text // this.value - series point value // this.valueLowerError - lower value for the series error // this.valueUpperError - upper value for the series error // this.x - series point x // this.xLowerError - lower x for the series error // this.xUpperError - upper x for the series error For SeriesPointContextProvider Series Point Context Provider // this.getDataValue() - data value // this.getSeriesMeta() - series meta // this.getStat() - statistics from data // this.getTokenType() - token type // this.getTokenValue() - token value return titleFormatterValue; // type Function }.

Returns:

anychart.core.ui.SeriesTooltip - 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.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.

Try it:

vAlign

Getter for the current text vertical align setting.

Returns:

anychart.graphics.vector.Text.VAlign - Current value.
See listing
var currentTooltipSettings = series.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.SeriesTooltip - Self instance for method chaining.
See listing
var currentTooltipSettings = series.tooltip();
currentTooltipSettings.vAlign('top');

valuePostfix

Getter for tooltip postfix value.

Returns:

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

Params:

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

Returns:

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

Try it:

valuePrefix

Getter for tooltip prefix value.

Returns:

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

Params:

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

Returns:

anychart.core.ui.SeriesTooltip - 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: