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

class anychart.core.SeparateChart Improve this Doc

Extends: anychart.core.ChartWithCredits

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

Methods Overview

Specific settings
globalToLocal()Converts the global coordinates to local coordinates.
localToGlobal()Converts the local coordinates to global coordinates.
Chart Coloring
animation()Animation settings
background()Background settings.
Chart Controls
contextMenu()Context menu settings.
credits()Credits settings
label()Label settings.
legend()Legend settings.
title()Title settings.
Data
getSelectedPoints()Getter for the selected points.
getStat()Getter for a statistical value by the key.
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.
saveAsCsv()Saves chart data as CSV file.
saveAsJson()Saves chart config as JSON document.
saveAsXlsx()Saves chart data as Excel document.
saveAsXml()Saves chart config as XML document.
toCsv()Returns CSV string with series data.
Interactivity
enabled()Element state (enabled or disabled).
interactivity()Interactivity settings.
tooltip()Tooltip settings.
Size and Position
bottom()Bottom bound setting.
bounds()Bounds settings.
getPixelBounds()Returns pixel bounds.
height()Height setting.
left()Left bound setting.
margin()Margin settings.
maxHeight()Maximum height.
maxWidth()Maximum width.
minHeight()Minimum height.
minWidth()Minimum width.
padding()Padding settings.
right()Right bound setting.
top()Top bound setting.
width()Width setting.
zIndex()Z-index of the element.
XML/JSON
toJson()Return chart configuration as JSON object or string.
toXml()Return chart configuration as XML string or XMLNode.
Miscellaneous
container()Getter for the element's container.
draw()Drawing of the chart.
saveAsJpg()Saves the current chart as JPEG image.
saveAsPdf()Saves the current chart as PDF image.
saveAsPng()Saves the current chart as PNG image.
saveAsSvg()Saves the current chart as SVG image.
toSvg()Returns SVG string.

Methods Description

animation

Getter for the current animation setting.

Returns:

anychart.core.utils.Animation - Returns true if the animation is enabled.
Setter for the animation setting by one value.

Params:

NameTypeDefaultDescription
valueboolean | Object
false
Whether to enable animation.

Returns:

anychart.core.SeparateChart - Self instance for method chaining.
Setter for the animation settings using several parameters.

Params:

NameTypeDefaultDescription
enabledboolean
false
Whether to enable animation.
durationnumber
1000
Duration in milliseconds.

Returns:

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

background

Getter for the current chart background.

Returns:

anychart.core.ui.Background - The current chart background.
Setter for the chart background.

Params:

NameTypeDefaultDescription
valueObject
{enabled: true, fill: "#fff", stroke: 'none', zIndex: 1}
Background object to set.

Returns:

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

bottom

Getter for element bottom bound setting.

Returns:

number | string | undefined - Current element's bottom bound setting.
Sets element bottom bound setting.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Bottom bound setting for the element.

Returns:

anychart.core.SeparateChart - Returns self for method chaining.

bounds

Getter for the element bounds settings.

Returns:

anychart.core.utils.Bounds - Current bounds of the element.
Sets bounds of the element using one parameter.

Params:

NameTypeDescription
valueanychart.utils.RectObj | anychart.math.Rect | anychart.core.utils.BoundsBounds of element.

Returns:

anychart.core.SeparateChart - Self instance for method chaining.
Setter for the element bounds settings.

Params:

NameTypeDefaultDescription
xnumber | string
null
X-coordinate.
ynumber | string
null
Y-coordinate.
widthnumber | string
null
Width.
heightnumber | string
null
Height.

Returns:

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

container

Getter for the element's container.
Setter for the element's container.

Params:

NameTypeDescription
valueanychart.graphics.vector.Layer | anychart.graphics.vector.Stage | string | ElementThe value to set.

Returns:

anychart.core.SeparateChart - Self instance for method chaining.
Example
// string
 element.container('containerIdentifier');
// DOM-element
 var domElement = document.getElementById('containerIdentifier');
 element.container(domElement);
// Framework-element
 var fwElement = anychart.standalones.title();
 element.container( fwElement.container() );

contextMenu

Getter for the current context menu.

Returns:

anychart.ui.ContextMenu - The current context menu.
Setter for the context menu.

Params:

NameTypeDescription
valueObject | boolean | nullContext menu settings

Returns:

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

credits

Getter for the current credits.

Returns:

anychart.core.ui.ChartCredits - Chart credits.
Setter for the chart credits. Learn more about credits settings.

Params:

NameTypeDefaultDescription
valueObject | boolean | null
true
Credits settings

Returns:

anychart.core.SeparateChart - An instance of the class for method chaining.

draw

Starts the rendering of the chart into the container.

Params:

NameTypeDescription
asyncbooleanWhether do draw asynchronously. If set to true, the chart will be drawn asynchronously.

Returns:

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

enabled

Getter for the current element state (enabled or disabled).

Returns:

boolean - The current element state.
Setter for the element enabled state.

Params:

NameTypeDefaultDescription
valueboolean
true
Value to set.

Returns:

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

getPixelBounds

Returns pixel bounds of the element due to parent bounds and self bounds settings.

Returns:

anychart.math.Rect - Pixel bounds of the element.

getSelectedPoints

Getter for the selected points.

Returns:

Array.<anychart.core.Point> - An array of the selected points.

getStat

Getter for a statistical value by the key.

Params:

NameTypeDescription
keystring | anychart.enums.StatisticsKey.

Returns:

* - Statistics value.

globalToLocal

Converts the global coordinates to local coordinates. Note: Works only after anychart.core.Chart#draw is called.

Params:

NameTypeDescription
xCoordnumberGlobal X coordinate.
yCoordnumberGlobal Y coordinate.

Returns:

Object.<string, number> - Object with XY coordinates.

height

Getter for element height setting.

Returns:

number | string | undefined - Current element's height setting.
Sets element height setting.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Height setting for the element.

Returns:

anychart.core.SeparateChart - Returns self for method chaining.

interactivity

Gets the current interactivity settings for chart.

Returns:

anychart.core.utils.Interactivity - The current interactivity settings.
Sets interactivity settings for chart.

Params:

NameTypeDescription
valueObject | anychart.enums.HoverModeSettings object or boolean value like enabled state.

Returns:

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

label

Getter for chart label.

Params:

NameTypeDefaultDescription
indexstring | number
0
Index of instance.

Returns:

anychart.core.ui.Label - An instance of class.
Setter for chart label.

Params:

NameTypeDefaultDescription
valuenull | boolean | Object | string
false
Chart label instance to add by index 0.

Returns:

anychart.core.SeparateChart - Self instance for method chaining.
Setter for chart label.

Params:

NameTypeDefaultDescription
indexstring | number
Label index.
valuenull | boolean | Object | string
false
Chart label settings.

Returns:

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

left

Getter for element left bound setting.

Returns:

number | string | undefined - Current element's left bound setting.
Sets element left bound setting.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Left bound setting for the element.

Returns:

anychart.core.SeparateChart - Returns self for method chaining.

legend

Getter for the current chart legend.

Returns:

anychart.core.ui.Legend - An instance of the class for method chaining.
Setter for chart legend setting.

Params:

NameTypeDefaultDescription
valueObject | boolean | null
false
Legend settings.

Returns:

anychart.core.SeparateChart - An instance of the class for method chaining.

listen

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
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 }.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

listenOnce

Adds an event listener to an implementing object.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

Object - Unique key for the listener.

localToGlobal

Converts the local coordinates to global coordinates. Note: Works only after anychart.core.Chart#draw is called.

Params:

NameTypeDescription
xCoordnumberLocal X coordinate.
yCoordnumberLocal Y coordinate.

Returns:

Object.<string, number> - Object with XY coordinates.

margin

Setter for the chart margin in pixels using a single complex object.

Params:

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

Returns:

anychart.core.SeparateChart - 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.margin(5, 15));
Setter for the chart margin in pixels using several simple values.

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.SeparateChart - 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);

maxHeight

Getter for maximum height.

Returns:

number | string | null - Current element's maximum height.
Setter for maximum height.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Value to set.

Returns:

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

maxWidth

Getter for maximum width.

Returns:

number | string | null - Current element's maximum width.
Setter for maximum width.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Value to set.

Returns:

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

minHeight

Getter for minimum height.

Returns:

number | string | null - Current element's minimum height.
Setter for minimum height.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Value to set.

Returns:

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

minWidth

Getter for minimum width.

Returns:

number | string | null - Current element's minimum width.
Setter for minimum width.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Value to set.

Returns:

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

padding

Setter for the chart paddings in pixels using a single value.

Params:

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

Returns:

anychart.core.SeparateChart - Self instance for method chaining.
Example.
chart.padding([5, 15]);
or
chart.padding({left: 10, top: 20, bottom: 30, right: "40%"}});
Setter for the chart paddings 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.SeparateChart - 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);

print

Prints all elements on related stage.

Params:

NameTypeDefaultDescription
paperSizeOrOptionsanychart.graphics.vector.PaperSize | Object
Paper size or object with options.
landscapeboolean
false
Flag of landscape.

removeAllListeners

Removes all listeners from an object. You can also optionally remove listeners of some particular type.

Params:

NameTypeDescription
typestringType of event to remove, default is to remove all types.

Returns:

number - Number of listeners removed.
Getter for element right bound setting.

Returns:

number | string | undefined - Current element's right bound setting.
Sets element right bound setting.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Right bound setting for the element.

Returns:

anychart.core.SeparateChart - Returns self for method chaining.

saveAsCsv

Saves chart data as CSV file.

Params:

NameTypeDescription
chartDataExportModestring | anychart.enums.ChartDataExportModeData export mode.
csvSettingsObject.<string, (string|boolean|undefined)>CSV settings.
filenamestringFile name to save.

saveAsJpg

Saves the current chart as JPEG image.

Params:

NameTypeDescription
widthnumber | ObjectImage width or object with options.
heightnumberImage height.
qualitynumberImage quality in ratio 0-1.
forceTransparentWhitebooleanForce transparent to white or not.
filenamestringFile name to save.

saveAsJson

Saves chart config as JSON document.

Params:

NameTypeDescription
includeThemebooleanIf the current theme properties should be included into the result.
filenamestringFile name to save.

saveAsPdf

Saves the current chart as PDF image.

Params:

NameTypeDescription
paperSizeOrWidthOrOptionsnumber | string | ObjectAny paper format like 'a0', 'tabloid', 'b4', etc or width, or object with options.
landscapebooleanDefine, is landscape.
xnumberOffset X.
ynumberOffset Y.
filenamestringFile name to save.

saveAsPng

Saves the current chart as PNG image.

Params:

NameTypeDescription
widthnumber | ObjectImage width or object with options.
heightnumberImage height.
qualitynumberImage quality in ratio 0-1.
filenamestringFile name to save.

saveAsSvg

Saves the current chart as SVG image.

Params:

NameTypeDescription
paperSizestring | ObjectPaper Size or object with options.
landscapebooleanLandscape.
filenamestringFile name to save.
Saves the stage as SVG image using width and height.

Params:

NameTypeDescription
widthnumberImage width.
heightnumberImage height.

saveAsXlsx

Saves chart data as Excel document.

Params:

NameTypeDescription
chartDataExportModestring | anychart.enums.ChartDataExportModeData export mode.
filenamestringFile name to save.

saveAsXml

Saves chart config as XML document.

Params:

NameTypeDescription
includeThemebooleanIf the current theme properties should be included into the result.
filenamestringFile name to save.

title

Getter for chart title.

Returns:

anychart.core.ui.Title - The current chart title.
Setter for the chart title.

Params:

NameTypeDefaultDescription
valuenull | boolean | Object | string
false
Chart title text or title instance for copy settings from.

Returns:

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

toCsv

Returns CSV string with series data.

Params:

NameTypeDescription
chartDataExportModestring | anychart.enums.ChartDataExportModeData export mode.
csvSettingsObject.<string, (string|boolean|undefined)>CSV settings.

Returns:

string - CSV string.

toJson

Return chart configuration as JSON object or string.

Params:

NameTypeDefaultDescription
stringifyboolean
false
Returns JSON as string.
includeThemeboolean
false
If the current theme properties should be included into the result.

Returns:

Object | string - Chart configuration.

toSvg

Returns SVG string with paper size and landscape.

Params:

NameTypeDescription
paperSizestring | ObjectPaper Size or object of options.
landscapebooleanLandscape.

Returns:

string - SVG content or empty string.
Returns SVG string with with determined the width and height.

Params:

NameTypeDescription
widthnumberImage width.
heightnumberImage height.

Returns:

string - SVG content or empty string.

toXml

Return chart configuration as XML string or XMLNode.

Params:

NameTypeDefaultDescription
asXmlNodeboolean
false
Return XML as XMLNode.
includeThemeboolean
false
If the current theme properties should be included into the result.

Returns:

string | Node - Chart configuration.

tooltip

Getter for current chart tooltip.

Returns:

anychart.core.ui.Tooltip - An instance of the class for method chaining.
Example
var tooltipSettings = chart.tooltip();
Setter for chart tooltip.

Params:

NameTypeDescription
valueObject | boolean | null

Returns:

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

top

Getter for element top bound setting.

Returns:

number | string | undefined - Current element's top bound setting.
Sets element top bound setting.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Top bound setting for the element.

Returns:

anychart.core.SeparateChart - Returns self for method chaining.

unlisten

Removes a listener added using listen() or listenOnce() methods.

Params:

NameTypeDefaultDescription
typestring
The event type id.
listenerfunction
Callback method.
useCaptureboolean
false
Whether to fire in capture phase. Learn more about capturing https://javascript.info/bubbling-and-capturing
listenerScopeObject
Object in whose scope to call the listener.

Returns:

boolean - Whether any listener was removed.

unlistenByKey

Removes an event listener which was added with listen() by the key returned by listen() or listenOnce().

Params:

NameTypeDescription
keyObjectThe key returned by listen() or listenOnce().

Returns:

boolean - Whether any listener was removed.

width

Getter for element width setting.

Returns:

number | string | undefined - Current element's width setting.
Sets element width setting.

Params:

NameTypeDefaultDescription
valuenumber | string | null
null
Width setting for the element.

Returns:

anychart.core.SeparateChart - Returns self for method chaining.

zIndex

Getter for the current Z-index of the element.

Returns:

number - The current zIndex.
Setter for the Z-index of the element.

Params:

NameTypeDefaultDescription
valuenumber
0
Value to set.

Returns:

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