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.

namespace anychart.graphics Improve this Doc

Drawing core namespace.

Functions Overview

circle()Creates an instance of the anychart.graphics.vector.Circle class
create()Creates and returns a Stage object providing instruments for cross-browser drawing with a commnon interface
ellipse()Creates an instance of the anychart.graphics.vector.Ellipse class.
hatchFill()Creates an instance of theanychart.graphics.vector.HatchFill class in case a fill with such parameters does not
image()Creates an instance of the anychart.graphics.vector.Image class.
layer()Creates an instance of the anychart.graphics.vector.Layer class.
path()Creates an instance of the anychart.graphics.vector.Path class.
patternFill()Creates an instance of theanychart.graphics.vector.PatternFill class.
rect()Creates an instance ot the anychart.graphics.vector.Rect class.
server()Sets and returns an address export server script, which is used to export to an image
text()Creates, depending on the technology used, an instance of the anychart.graphics.vector.Text
type()Returns the Stage type recommended for the current browser (identified by a name and version), which is selected from
validate()Checks the graphics config for conform to graphics JSON scheme.

Enums Overview

anychart.graphics.StageTypeStage types supported by AnyChart Data Visualization Toolkit.

Functions Description

circle

Creates an instance of the anychart.graphics.vector.Circle class
To learn more about working with circles, see: anychart.graphics.vector.Circle Important: When an element is created this way, a parent element is not assigned to it automatically, so it is necessary to set the parent element manually.

Params:

NameTypeDescription
cxnumberThe X-coordinate of the center of the circle in pixels.
cynumberThe Y-coordinate of the center of the circle in pixels.
radiusnumberThe radius of the circle in pixels.

create

Creates and returns a Stage object providing instruments for cross-browser drawing with a commnon interface for all supported technologies.

Params:

NameTypeDescription
containerElement | stringA container where all graphics will be drawn. It can be defined later, for example while rendering.
widthstring | numberThe width of a Stage object in pixels.
heightstring | numberThe height of a Stage object in pixels.

Returns:

anychart.graphics.vector.Stage - A Stage object for cross-browser drawing with a common interface for all supported technologies.

ellipse

Creates an instance of the anychart.graphics.vector.Ellipse class.
Important: When an element is created this way, a parent element is not assigned to it automatically, so it is necessary to set the parent element manually. To learn more about working with ellipses, see: anychart.graphics.vector.Ellipse

Params:

NameTypeDescription
cxnumberThe X-coordinate of the center of the ellipse in pixels.
cynumberThe Y-coordinate of the center of the ellipse in pixels.
rxnumberThe X-axis radius of the ellipse in pixels.
rynumberThe Y-axis radius of the ellipse in pixels.

hatchFill

Creates an instance of theanychart.graphics.vector.HatchFill class in case a fill with such parameters does not exist. If there is already a fill with such parameters, an instance of it is returned.
To learn more about working with hatch fills, see: anychart.graphics.vector.HatchFill

Params:

NameTypeDescription
typeanychart.graphics.vector.HatchFill.HatchFillTypeThe type of the hatch fill.
colorstringThe color of the the hatch combined with opacity.
thicknessnumberThe thickness of the hatch fill.
sizenumberThe size of the hatch fill.

Returns:

anychart.graphics.vector.HatchFill - The instance of the anychart.graphics.vector.HatchFill class for method chaining.

image

Creates an instance of the anychart.graphics.vector.Image class.
Important: anychart.graphics.vector.Stage does not delete the object you have created . You should remove the object after using it.

Params:

NameTypeDescription
srcstringThe IRI (Internationalized Resource Identifier) of the image source.
xnumberThe X-coordinate of the left-top corner of the image.
ynumberThe Y-coordinate of the left-top corner of the image.
widthnumberThe width of the image bounds.
heightnumberThe height of the image bounds.

layer

Creates an instance of the anychart.graphics.vector.Layer class.
Important: When an element is created this way, a parent element is not assigned to it automatically, so it is necessary to set the parent element manually.

path

Creates an instance of the anychart.graphics.vector.Path class.
Important: When an element is created this way, a parent element is not assigned to it automatically, so it is necessary to set the parent element manually. To learn more about working with Path, see: anychart.graphics.vector.Path

patternFill

Creates an instance of theanychart.graphics.vector.PatternFill class.
To learn more about working with pattern fills, see: anychart.graphics.vector.PatternFill

Params:

NameTypeDescription
boundsanychart.graphics.math.RectThe bounds of the pattern. Defines the size and offset of the pattern.

Returns:

anychart.graphics.vector.PatternFill - An instance of the anychart.graphics.vector.PatternFill class for method chaining.

rect

Creates an instance ot the anychart.graphics.vector.Rect class.
Important: When an element is created this way, a parent element is not assigned to it automatically, so it is necessary to set the parent element manually.

Params:

NameTypeDescription
xnumberThe X-coordinate (left) of the top-left corner of the rectangle.
ynumberThe Y-coordinate (left) of the top-left corner of the rectangle.
widthnumberThe width of the rectangle.
heightnumberThe height of the rectangel.

server

Sets and returns an address export server script, which is used to export to an image or PDF.

Params:

NameTypeDescription
addressstringExport server script URL.

Returns:

string - Export server script URL.

text

Creates, depending on the technology used, an instance of the anychart.graphics.vector.Text or theanychart.graphics.vector.vml.Text class.
Important: When an element is created this way, a parent element is not assigned to it automatically, so it is necessary to set the parent element manually.

Params:

NameTypeDescription
xnumberThe X-coordinate (left) of the top-left corner of the text bounds.
ynumberThe Y-coordinate (top) of the top-left corner of the text bounds.
textstringThe text to display.
styleanychart.graphics.vector.TextStyleText style. See more: anychart.graphics.vector.Text#style.

type

Returns the Stage type recommended for the current browser (identified by a name and version), which is selected from the supported Stage types.

Returns:

anychart.graphics.StageType - A Stage type supported by the current browser.

validate

Checks the graphics config for conform to graphics JSON scheme.

Params:

NameTypeDescription
dataObjectJSON config graphics. JSON should be conform to the graphics JSON schema.
callbackfunctionCallback function. First parameter is a validation result.