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

class anychart.Chart Improve this Doc

Extends: anychart.VisualBaseWithBounds

Base class for all charts, contains the margins, the background and the title.

Methods Overview

Miscellaneous
background()Getter for the current chart background.
credits()Getter for current chart credits settings.
draw()Starts the rendering of the chart into the container.
label()Getter for chart label.
legend()Getter for current chart legend.
margin()Getter for the current chart margin.
padding()Getter for the current chart padding.
title()Getter for chart title.
toJson()Return chart configuration as JSON object or string.
toXml()Return chart configuration as XML string or XMLNode.

Methods Description

background

Getter for the current chart background.

Returns:

anychart.elements.Background - The current chart background.
Setter for the chart background.

Params:

NameTypeDescription
valueanychart.elements.BackgroundBackground object to set.

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.

credits

Getter for current chart credits settings.

Returns:

anychart.elements.Credits - An instance of anychart.elements.Credits class for method chaining.
Setter for chart credits settings.

Params:

NameTypeDescription
valueanychart.elements.Credits | Object | boolean

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.

draw

Starts the rendering of the chart into the container.

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.

label

Getter for chart label.

Params:

NameTypeDefaultDescription
indexstring | null
0
Index of instance.

Returns:

anychart.elements.Label - An instance of anychart.elements.Label for method chaining.
Setter for chart label.

Params:

NameTypeDescription
valueanychart.elements.Label | Object | string | nullChart label instance to add by index 0.

Returns:

anychart.Chart - An instance of anychart.Chart for method chaining.
Setter for chart label.

Params:

NameTypeDescription
indexstring | nullIndex of instance.
valueanychart.elements.Label | Object | string | nullChart label instance.

Returns:

anychart.Chart - An instance of anychart.Chart for method chaining.

legend

Getter for current chart legend.

Returns:

anychart.elements.Legend - An instance of anychart.elements.Legend for method chaining.
Setter for chart legend setting.

Params:

NameTypeDescription
valuenull | string | Object | anychart.elements.LegendLegend settings.

Returns:

anychart.Chart - An instance of anychart.Chart for method chaining.

margin

Getter for the current chart margin.

Returns:

anychart.utils.Margin - The current chart margin.
Setter for the chart margin in pixels using a single value.

Params:

NameTypeDescription
valuestring | number | anychart.utils.SpaceValue to set.

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.
Setter for the chart margin in pixels using several numbers.

Params:

NameTypeDescription
value1string | numberTop or top-bottom space.
value2string | numberRight or right-left space.
value3string | numberBottom space.
value4string | numberLeft space.

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.

padding

Getter for the current chart padding.

Returns:

anychart.utils.Padding - Current chart padding.
Setter for the chart paddings in pixels using a single value.

Params:

NameTypeDescription
valuestring | number | anychart.utils.SpaceValue to set.

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.
Setter for the chart paddings in pixels using several numbers.

Params:

NameTypeDescription
value1string | numberTop or top-bottom space.
value2string | numberRight or right-left space.
value3string | numberBottom space.
value4string | numberLeft space.

Returns:

anychart.Chart - An instance of anychart.Chart class for method chaining.

title

Getter for chart title.

Returns:

anychart.elements.Title - The current chart title.
Setter for the chart title.

Params:

NameTypeDescription
valuestring | anychart.elements.TitleChart title text or title instance for copy settings from.

Returns:

anychart.Chart - An instance of anychart.Chart for method chaining.

toJson

Return chart configuration as JSON object or string. Note for documentation writers!: Google compiler thinks that "Object" has "toJSON" method that must accept string and return *. To avoid this we have to put in the "wrong" params. In external documentation parameter must be boolean, and method must return Object|string. For the moment we have no way around this "nice feature" of the compiler.

Params:

NameTypeDescription
stringifystringReturn as JSON as string.

Returns:

* - Chart JSON.

toXml

Return chart configuration as XML string or XMLNode.

Params:

NameTypeDescription
asXmlNodebooleanReturn XML as XMLNode.

Returns:

string | Node - Chart configuration.