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

class anychart.core.Chart Improve this Doc

Extends: anychart.core.VisualBaseWithBounds

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

Methods Overview

Miscellaneous
animation()Getter for the current animation setting.
background()Getter for the current chart background.
draw()Starts the rendering of the chart into the container.
label()Getter for chart label.
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

animation

Getter for the current animation setting.

Returns:

anychart.core.utils.Animation - Returns true if the animation is enabled.

Try it:

Setter for the animation setting by one value.

Params:

Name Type Default Description
value boolean | Object
false
Whether to enable animation.

Returns:

anychart.core.Chart - Self instance for method chaining.
Setter for the animation setting.

Params:

Name Type Description
enabled boolean Whether to enable animation.
duration number Duration in milliseconds.

Returns:

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

Try it:

background

Getter for the current chart background.

Returns:

anychart.core.ui.Background - The current chart background.

Try it:

Setter for the chart background.

Params:

Name Type Description
value Object Background object to set.

Returns:

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

Try it:

draw

Starts the rendering of the chart into the container.

Returns:

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

label

Getter for chart label.

Params:

Name Type Default Description
index string | number
0
Index of instance.

Returns:

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

Try it:

Setter for chart label.

Params:

Name Type Description
value null | boolean | Object | string Chart label instance to add by index 0.

Returns:

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

Try it:

Setter for chart label.

Params:

Name Type Description
index string | number Index of instance.
value null | boolean | Object | string Chart label instance.

Returns:

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

Try it:

margin

Getter for the current chart margin.

Returns:

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

Params:

Name Type Description
value Array.<(number|string)> | Object Value to set.

Returns:

anychart.core.Chart - Self instance for method chaining.
Example
// all margins 15px
chart.margin(15);
// all margins 15px
chart.margin('15px');
// top and bottom 5px ,right and left 15px
chart.margin(anychart.utils.space(5,15) );

Try it:

Setter for the chart margin in pixels using several simple values.

Params:

Name Type Description
value1 string | number Top or top-bottom space.
value2 string | number Right or right-left space.
value3 string | number Bottom space.
value4 string | number Left space.

Returns:

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

Try it:

padding

Getter for the current chart padding.

Returns:

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

Params:

Name Type Description
value Array.<(number|string)> | Object Value to set.

Returns:

anychart.core.Chart - Self instance for method chaining.
Example
chart.padding([5, 15]);
Example
chart.padding({left: 10, top: 20, bottom: 30, right: '40%'}});

Try it:

Setter for the chart paddings in pixels using several numbers.

Params:

Name Type Description
value1 string | number Top or top-bottom space.
value2 string | number Right or right-left space.
value3 string | number Bottom space.
value4 string | number Left space.

Returns:

anychart.core.Chart - Self instance for method chaining.
Example
// 1) all 10px
chart.padding(10);
// 2) top and bottom 10px, left and right 15px
chart.padding(10, '15px');
// 3) top 10px, left and right 15px, bottom 5px
chart.padding(10, '15px', 5);
// 4) top 10px, right 15%, bottom 5px, left 12px
chart.padding(10, '15%', '5px', 12);

Try it:

title

Getter for chart title.

Returns:

anychart.core.ui.Title - The current chart title.

Try it:

Setter for the chart title.

Params:

Name Type Description
value null | boolean | Object | string Chart title text or title instance for copy settings from.

Returns:

anychart.core.Chart - Self instance 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:

Name Type Description
stringify string Return as JSON as string.

Returns:

* - Chart JSON.

toXml

Return chart configuration as XML string or XMLNode.

Params:

Name Type Description
asXmlNode boolean Return XML as XMLNode.

Returns:

string Node - Chart configuration.