AnyChart
API Reference
Still have questions?
Contact support
Top

class anychart.core.ui.Title Improve this Doc

Extends: anychart.core.Text

Title element class.
Title can be a part of an other complex element, such as a chart, a legend or an axis, as well a self-sufficient element.
A title have a orientation, text alignment and a background.

Title occupies the whole part of a container (depending on the orientation by the width or the height).

Methods Overview

Specific settings
text()Title text.
Advanced Text Settings
fontVariant()Font variant settings.
letterSpacing()Text letter spacing settings.
textDirection()Text direction settings.
textIndent()Text indent settings.
textOverflow()Text overflow settings.
useHtml()Text useHtml settings.
wordBreak()Word break mode.
wordWrap()Word-wrap mode.
Base Text Settings
fontColor()Font color settings.
fontDecoration()Font decoration settings.
fontFamily()Font family settings.
fontOpacity()Font opacity settings.
fontSize()Font size settings.
fontStyle()Font style settings.
fontWeight()Font weight settings.
hAlign()Text horizontal align settings.
lineHeight()Text line height settings.
maxLength()Maximum text length.
textShadow()Text shadow settings.
vAlign()Text vertical align settings.
Coloring
background()Background settings.
Events
disablePointerEvents()Pointer events settings.
Interactivity
enabled()Element state (enabled or disabled).
selectable()Text selectable option.
Size and Position
align()Align settings.
getRemainingBounds()Returns the remaining (after title placement) part of the container.
height()Height settings.
margin()Margin settings.
orientation()Orientation settings.
padding()Padding settings.
rotation()Rotation settings.
width()Width settings.
zIndex()Z-index of the element.
Text Settings
adjustFontSize()Adjusting settings.
maxFontSize()Maximum font size settings.
minFontSize()Minimum font size settings.
textSettings()Text settings.

Methods Description

adjustFontSize

Getter for the adjusting font size.

Returns:

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

Params:

NameTypeDefaultDescription
adjustOrAdjustByWidthboolean | Array.<boolean> | Object
true
Font needs to be adjusted in case of 1 argument and adjusted by width in case of 2 arguments.
adjustByHeightboolean
Font needs to be adjusted by height.

Returns:

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

align

Getter for the title align.

Returns:

anychart.enums.Align | string - Title align.
Setter for the title align.

Params:

NameTypeDefaultDescription
alignanychart.enums.Align | string
'center'
Value to set.

Returns:

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

background

Getter for the title background.

Returns:

anychart.core.ui.Background - Returns the background.
Setter for the title background.

Params:

NameTypeDefaultDescription
settingsstring | Object | null | boolean
false
Background settings to set.

Returns:

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

disablePointerEvents

Getter for the pointer events.

Returns:

boolean - Flag of the state.
Setter for the pointer events.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

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

enabled

Getter for the title state (enabled or disabled).

Returns:

boolean - Element state.
See listing
var enabled = title.enabled();
Setter for the title enabled state.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

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

fontColor

Getter for the text font color.

Returns:

string - Font color.
See listing
var fontColor = title.fontColor();
Setter for the text font color.
https://www.w3schools.com/html/html_colors.asp

Params:

NameTypeDescription
colorstringValue to set.

Returns:

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

fontDecoration

Getter for the text font decoration.

Returns:

anychart.graphics.vector.Text.Decoration | string - Font decoration.
Setter for the text font decoration.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.Decoration | string
'none'
Font decoration to set.

Returns:

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

fontFamily

Getter for the font family.

Returns:

string - Font family.
Setter for the font family.

Params:

NameTypeDefaultDescription
familystring
'Verdana', Helvetica, Arial, sans-serif
Font family to set.

Returns:

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

fontOpacity

Getter for the text font opacity.

Returns:

number - Font opacity.
Setter for the text font opacity. Double value from 0 to 1.

Params:

NameTypeDefaultDescription
opacitynumber
1
Value to set.

Returns:

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

fontSize

Getter for the title font size.

Returns:

string | number - Font size.
Setter for the title font size.

Params:

NameTypeDefaultDescription
sizestring | number
16
Font size to set.

Returns:

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

fontStyle

Getter for the text font style.

Returns:

anychart.graphics.vector.Text.FontStyle | string - Font style.
Setter for the text font style.

Params:

NameTypeDefaultDescription
styleanychart.graphics.vector.Text.FontStyle | string
'normal'
Font style to set.

Returns:

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

fontVariant

Getter for the text font variant.

Returns:

anychart.graphics.vector.Text.FontVariant | string - Font variant.
Setter for the text font variant.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.FontVariant | string
'normal'
Font variant to set.

Returns:

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

fontWeight

Getter for the text font weight.

Returns:

string | number - Font weight.
See listing
var fontWeight = title.fontWeight();

Params:

NameTypeDefaultDescription
weightstring | number
'normal'
Font weight to set.

Returns:

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

getRemainingBounds

Returns the remaining (after title placement) part of the container.

Returns:

anychart.math.Rect - Parent bounds without the space used by the title.

hAlign

Getter for the title horizontal align.

Returns:

anychart.graphics.vector.Text.HAlign | string - Text horizontal align.
Setter for the title horizontal align.

Params:

NameTypeDefaultDescription
alignanychart.graphics.vector.Text.HAlign | string
'center'
Value to set.

Returns:

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

height

Getter for the title height.

Returns:

number | string | null - Title height.
Setter for the title height.

Params:

NameTypeDefaultDescription
heightnumber | string
null
Title height to set.

Returns:

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

letterSpacing

Getter for the text letter spacing.

Returns:

string | number - Letter spacing.

Params:

NameTypeDefaultDescription
spacingstring | number
'normal'
Value to set.

Returns:

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

lineHeight

Getter for the text line height.

Returns:

string | number - Text line height.

Params:

NameTypeDefaultDescription
heightstring | number
'normal'
Value to set.

Returns:

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

margin

Returns:

anychart.core.utils.Margin - The title margin.
Setter for the title margin in pixels using one complex value.

Params:

NameTypeDefaultDescription
allValuesstring | number | Array.<(number|string)> | Object
{top: 0, right: 0, bottom: 2, left: 0}
Value to set.

Returns:

anychart.core.ui.Title - Self instance for method chaining.
Setter for the title margin in pixels using several numbers.

Params:

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

Returns:

anychart.core.ui.Title - Self instance for method chaining.
Example.
// 1) all 10px
title.margin(10);
// 2) top and bottom 10px, left and right 15px
title.margin(10, '15px');
// 3) top 10px, left and right 15px, bottom 5px
title.margin(10, '15px', 5);
// 4) top 10px, right 15px, bottom 5px, left 12px
title.margin(10, '15px', '5px', 12);

maxFontSize

Getter for maximum font size settings for adjust text from.

Returns:

number - Maximum font size.
See listing
var maxFontSize = title.maxFontSize();
Setter for maximum font size settings for adjust text from.

Params:

NameTypeDescription
sizenumber | stringMaximum font size to set.

Returns:

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

maxLength

Getter for maximum text length.

Returns:

number | null - Maximum length of text.
See listing
var maxLengthValue = chart.title().maxLength(); // null by default.
Setter for maximum text length.

Params:

NameTypeDefaultDescription
maxLengthnumber | null
null
Maximum text length to set.

Returns:

anychart.core.ui.Title - Self instance for method chaining.
Example
chart.title().maxLength(10); // Limit title characters count.

minFontSize

Getter for minimum font size settings for adjust text from.

Returns:

number - Minimum font size.
See listing
var minFontSize = title.minFontSize();
Setter for minimum font size settings for adjust text from.

Params:

NameTypeDescription
sizenumber | stringMinimum font size to set.

Returns:

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

orientation

Getter for the title orientation.

Returns:

anychart.enums.Orientation | string - Title orientation.
Setter for the title orientation.

Params:

NameTypeDefaultDescription
orientationanychart.enums.Orientation | string
'top'
Value to set.

Returns:

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

padding

Setter for the title padding in pixels using single value.

Params:

NameTypeDefaultDescription
paddingestring | number | Array.<(number|string)> | Object
{top: 0, right: 0, bottom: 2, left: 0}
Padding to set.

Returns:

anychart.core.ui.Title - Self instance for method chaining.
Setter for the title padding in pixels using several numbers.

Params:

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

Returns:

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

rotation

Getter for the title rotation.

Returns:

number - Title rotation.
Setter for the title rotation.

Params:

NameTypeDescription
rotationnumberRotation to set.

Returns:

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

selectable

Getter for the text selectable option.

Returns:

boolean - The text selectable option.
Setter for the text selectable.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

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

text

Getter for the text content for the title.

Returns:

string - Text content of the title.
Setter for the text content for the title.

Params:

NameTypeDefaultDescription
textstring
'Title text'
Value to set.

Returns:

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

textDirection

Getter for the text direction.

Returns:

anychart.graphics.vector.Text.Direction | string - Text direction.
Setter for the text direction.

Params:

NameTypeDefaultDescription
directionanychart.graphics.vector.Text.Direction | string
'ltr'
Text direction to set.

Returns:

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

textIndent

Getter for the text indent.

Returns:

number - Text indent.
Setter for the text indent.

Params:

NameTypeDefaultDescription
indentnumber
0
Text indent to set.

Returns:

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

textOverflow

Getter for the text overflow settings.

Returns:

anychart.graphics.vector.Text.TextOverflow | string - Text overflow settings.
See listing
var title = chart.title();
var textOverflow = title.textOverflow();
Setter for the text overflow settings.

Params:

NameTypeDefaultDescription
valueanychart.graphics.vector.Text.TextOverflow | string
""
Text overflow settings to set.

Returns:

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

textSettings

Getter for the full text appearance settings.

Returns:

Object - A copy of settings object.
Getter for all text appearance settings.

Params:

NameTypeDescription
namestringSetting name.

Returns:

string | number | boolean | undefined - Value of settings.
Setter for text appearance settings.

Params:

NameTypeDescription
objectWithSettingsObjectSettings object. Complete object looks like this:
   {
     'fontSize': smth,
     'fontFamily': smth,
     'fontColor': smth,
     'fontOpacity': smth,
     'fontDecoration': smth,
     'fontStyle': smth,
     'fontVariant': smth,
     'fontWeight': smth,
     'letterSpacing': smth,
     'textDirection': smth,
     'lineHeight': smth,
     'textIndent': smth,
     'vAlign': smth,
     'hAlign': smth,
     'wordWrap': smth,
     'wordBreak': smth,
     'textOverflow': smth,
     'selectable': smth,
     'useHtml': smth
     'textShadow':smth
   }

Returns:

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

Params:

NameTypeDescription
namestringSetting name.
settingsstring | number | boolean | functionText settings.

Returns:

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

textShadow

Getter for the text shadow.

Returns:

string - String representation of text shadow.
See listing
var textShadow = title.textShadow();
Setter for the text shadow.

Params:

NameTypeDefaultDescription
textShadowanychart.graphics.vector.TextShadow | string
'none'
Text shadow to set.

Returns:

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

useHtml

Getter for HTML formatted text.

Returns:

boolean - Value of useHTML flag.
See listing
var useHtml = title.useHtml();
Setter for HTML formatted text.

Params:

NameTypeDefaultDescription
enabledboolean
false
Enabled state to set.

Returns:

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

vAlign

Getter for the text vertical align.

Returns:

anychart.graphics.vector.Text.VAlign | string - Text vertical align.
Setter for the text vertical align.

Params:

NameTypeDefaultDescription
alignanychart.graphics.vector.Text.VAlign | string
'top'
Value to set.

Returns:

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

width

Getter for the title width.

Returns:

number | string | null - Title width.
Setter for the title width.

Params:

NameTypeDefaultDescription
widthnumber | string
null
Title width to set.

Returns:

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

wordBreak

Getter for the word-break mode.

Returns:

anychart.enums.WordBreak | string - Word-break mode.
Setter for the word-break mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.WordBreak | string
"normal"
Word-break mode to set.

Returns:

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

wordWrap

Getter for the word-wrap mode.

Returns:

anychart.enums.WordWrap | string - Word-wrap mode.
Setter for the word-wrap mode.

Params:

NameTypeDefaultDescription
modeanychart.enums.WordWrap | string
'normal'
Word-wrap mode to set.

Returns:

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

zIndex

Getter for the Z-index of the element.

Returns:

number - Z-index.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
zIndexnumber
0
Value to set.

Returns:

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