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
- [false, false] - do not adjust (adjust is off )
- [true, false] - adjust width
- [false, true] - adjust height
- [true, true] - adjust the first suitable value.
Returns:
number - An adjusted font size.var tooltip = chart.tooltip(); var adjustFontSize = tooltip.adjustFontSize();
Note: anychart.core.ui.Tooltip#fontSize does not work when adjusting is enabled.
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
Returns:
boolean - Boolean value.var tooltipSettings = chart.tooltip(); var value = tooltipSettings.allowLeaveChart();
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
Returns:
boolean - Boolean value.var tooltipSettings = chart.tooltip(); var value = tooltipSettings.allowLeaveScreen();
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
Returns:
boolean - Boolean value.var tooltipSettings = chart.tooltip(); var value = tooltipSettings.allowLeaveStage();
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
Returns:
anychart.enums.Anchor | string - Tooltip anchor settings.var tooltip = chart.tooltip(); var anchor = 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
Returns:
anychart.core.ui.Background - An instance of the class for method chaining.var tooltip = chart.tooltip(); var background = tooltip.background();
- null/boolean - disable background.
- object - sets background settings.
- string - sets fill settings.
Params:
Name | Type | Description |
---|---|---|
value | null | boolean | Object | string | Background settings. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.disablePointerEvents
Returns:
boolean - The pointer events settings.var tooltip = chart.tooltip(); var disablePointerEvents = tooltip.disablePointerEvents();
Params:
Name | Type | Default | Description |
---|---|---|---|
value | boolean | false | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.displayMode
Returns:
anychart.enums.TooltipDisplayMode - Display mode.var tooltip = chart.tooltip(); var displayMode = tooltip.displayMode();
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
Returns:
boolean - The current element state.Try it:
Params:
Name | Type | Default | Description |
---|---|---|---|
value | boolean | true | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.if (!element.enabled()) element.enabled(true);
Try it:
fontColor
Returns:
string - Font color settings.var tooltip = chart.tooltip(); var fontColor = tooltip.fontColor();
Params:
Name | Type | Description |
---|---|---|
value | string | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
fontDecoration
Returns:
anychart.graphics.vector.Text.Decoration - Font decoration settings.var tooltip = chart.tooltip(); var fontDecoration = tooltip.fontDecoration();
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
Returns:
string - Font family settings.var tooltip = chart.tooltip(); var fontFamily = tooltip.fontFamily();
Params:
Name | Type | Description |
---|---|---|
value | string | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
fontOpacity
Returns:
number - Font opacity settings.var tooltip = chart.tooltip(); var fontOpacity = tooltip.fontOpacity();
Params:
Name | Type | Description |
---|---|---|
value | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
fontSize
Returns:
number - Font size settings.var tooltip = chart.tooltip(); var fontSize = tooltip.fontSize();
Params:
Name | Type | Description |
---|---|---|
value | number | string | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
fontStyle
Returns:
anychart.graphics.vector.Text.FontStyle - Font style settings.var tooltip = chart.tooltip(); var fontStyle = tooltip.fontStyle();
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
Returns:
anychart.graphics.vector.Text.FontVariant - Font variant settings.var tooltip = chart.tooltip(); var fontVariant = tooltip.fontVariant();
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
Returns:
string | number - Font weight settings.var tooltip = chart.tooltip(); var fontWeight = tooltip.fontWeight();
Params:
Name | Type | Description |
---|---|---|
value | string | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
format
Returns:
function | string - Function to format title text.var tooltipSettings = chart.tooltip(); var formatter = tooltipSettings.textFormatter();
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.Try it:
hAlign
Returns:
anychart.graphics.vector.Text.HAlign - Horizontal align settings.var tooltip = chart.tooltip(); var hAlign = tooltip.hAlign();
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
Returns:
string | number - Tooltip height.var tooltipSettings = chart.tooltip(); var height = tooltipSettings.height();
Params:
Name | Type | Description |
---|---|---|
value | string | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
hide
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
Returns:
number - Hide delay settings.var tooltip = chart.tooltip(); var hideDelay = tooltip.hideDelay();
Params:
Name | Type | Default | Description |
---|---|---|---|
value | number | 0 | Delay in milliseconds. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
letterSpacing
Returns:
number - Letter spacing settings.var tooltip = chart.tooltip(); var letterSpacing = tooltip.letterSpacing();
Params:
Name | Type | Description |
---|---|---|
value | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
lineHeight
Returns:
number | string - Line height settings.var tooltip = chart.tooltip(); var lineHeight = tooltip.lineHeight();
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
Note Notice that if the existing listener is one-off (added using listenOnce), it will cease to be such after calling the listen() method.
Params:
Name | Type | Default | 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 | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
Object - Unique key for the listener.Try it:
listenOnce
If the event handler being added already exists, listenOnce will do nothing.
Note In particular, if the handler is already registered using listen(), listenOnce() will not make it one-off. Similarly, if a one-off listener already exists, listenOnce will not change it (it wil remain one-off).
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
Object - Unique key for the listener.Try it:
maxFontSize
Returns:
number - Maximum font size.var tooltip = chart.tooltip(); var maxFontSize = tooltip.maxFontSize();
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
Returns:
number - Minimum font size.var tooltip = chart.tooltip(); var minFontSize = tooltip.minFontSize();
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
Returns:
number - Tooltip offset by X.var tooltip = chart.tooltip(); var offsetX = tooltip.offsetX();
Params:
Name | Type | Description |
---|---|---|
value | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
offsetY
Returns:
number - Tooltip offset by Y.var tooltip = chart.tooltip(); var offsetY = tooltip.offsetY();
Params:
Name | Type | Description |
---|---|---|
value | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
padding
Returns:
anychart.core.utils.Padding - Tooltip padding.Try it:
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:
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.// 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
Returns:
anychart.enums.Position | string - Tooltip position.var tooltip = chart.tooltip(); var position = 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
Returns:
string - Position mode.var tooltip = chart.tooltip(); var positionMode = tooltip.positionMode();
Params:
Name | Type | Description |
---|---|---|
value | string | anychart.enums.TooltipPositionMode | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
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
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
Returns:
boolean - Text selectable value.var tooltip = chart.tooltip(); var selectable = tooltip.selectable();
Params:
Name | Type | Default | Description |
---|---|---|---|
value | boolean | false | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
separator
Returns:
anychart.core.ui.Separator - An instance of the class for method chaining.Try it:
- null/boolean - disables separator.
- object - sets separator settings.
Params:
Name | Type | Description |
---|---|---|
value | null | boolean | Object | Separator settings. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
textDirection
Returns:
anychart.graphics.vector.Text.Direction - Text direction settings.var tooltip = chart.tooltip(); var fontOpacity = tooltip.fontOpacity();
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
Returns:
number - Text indent settings.var tooltip = chart.tooltip(); var textIndent = tooltip.textIndent();
Params:
Name | Type | Description |
---|---|---|
value | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
textOverflow
Returns:
anychart.graphics.vector.Text.TextOverflow - Text overflow settingsParams:
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
Returns:
Object | string | number | boolean - Text settings.var tooltip = chart.tooltip(); var textSettings = tooltip.textSettings();
Params:
Name | Type | Description |
---|---|---|
value | Object | Few text settings. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
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
Returns:
anychart.graphics.vector.Text.TextWrap - Text wrap settings.var tooltip = chart.tooltip(); var textWrap = tooltip.textWrap();
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
Returns:
anychart.core.ui.Title - An instance of the class for method chaining.var tooltip = chart.tooltip(); var title = tooltip.title();
- null/false - disable title.
- object - Setter for title settings.
Params:
Name | Type | Description |
---|---|---|
value | null | boolean | Object | Title settings. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
titleFormat
Returns:
function | string - Function to format title text.var tooltipSettings = chart.tooltip(); var formatter = tooltipSettings.titleFormat();
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
Returns:
function | string - Function to format title text.var tooltipSettings = chart.tooltip(); var formatter = tooltipSettings.unionFormat();
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.Try it:
unlisten
Params:
Name | Type | Default | Description |
---|---|---|---|
type | string | The event type id. | |
listener | function | Callback method. | |
useCapture | boolean | false | Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing |
listenerScope | Object | Object in whose scope to call the listener. |
Returns:
boolean - Whether any listener was removed.Try it:
unlistenByKey
Params:
Name | Type | Description |
---|---|---|
key | Object | The key returned by listen() or listenOnce(). |
Returns:
boolean - Whether any listener was removed.Try it:
useHtml
Returns:
boolean - UseHTML flag.var tooltip = chart.tooltip(); var useHtml = tooltip.useHtml();
Params:
Name | Type | Description |
---|---|---|
value | boolean | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
vAlign
Returns:
anychart.graphics.vector.Text.VAlign - Vertical align.var tooltip = chart.tooltip(); var vAlign = tooltip.vAlign();
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
Returns:
string - Postfix settings.var tooltip = series.tooltip(); var valuePostfix = tooltip.valuePostfix();
Params:
Name | Type | Default | Description |
---|---|---|---|
value | string | '' | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
valuePrefix
Returns:
string - Current prefix settings.var tooltip = series.tooltip(); var valuePrefix = tooltip.valuePrefix();
Params:
Name | Type | Default | Description |
---|---|---|---|
value | string | '' | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
width
Returns:
string | number - Tooltip width.var tooltipSettings = chart.tooltip(); var width = tooltipSettings.width();
Params:
Name | Type | Description |
---|---|---|
value | string | number | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it:
zIndex
Returns:
number - The current zIndex.Try it:
Params:
Name | Type | Default | Description |
---|---|---|---|
value | number | 0 | Value to set. |
Returns:
anychart.core.ui.Tooltip - Self instance for method chaining.Try it: