Math

Type module

Sources

Items from Math can be imported/included and used via following ways.

/**
 * --------------------------------------------------------
 * Import via main package: core.ts
 * Access items like: am5.math.myVariable
 *                    am5.math.myFunction()
 * --------------------------------------------------------
 */
import * as am5 from "@amcharts/amcharts5";

/**
 * --------------------------------------------------------
 * Import via: Math.ts
 * Access items like: $math.myVariable
 *                    $math.myFunction()
 * --------------------------------------------------------
 */
import * as $math from "@amcharts/amcharts5/Math";

/**
 * --------------------------------------------------------
 * Include via "index.js"
 * E.g.: "https://cdn.amcharts.com/lib/5/index.js"
 * Access items like: am5.math.myVariable
 *                    am5.math.myFunction()
 * --------------------------------------------------------
 */

Variables

RADIANS
#

Type number

Default PI / 180

HALFPI
#

Type number

Default PI / 2

DEGREES
#

Type number

Default 180 / PI

Functions

boundsOverlap(

bounds1: IBounds,
bounds2: IBounds

)

#

Returns boolean

Returns true if bounds overlap

ceil(

value: number,
precision: number

)

#

Returns number

Ceils the numeric value to whole number or specific precision of set.

circlesOverlap(

circle1: { radius: number,
  x: number,
  y: number }
,
circle2: { radius: number,
  x: number,
  y: number }

)

#

Returns boolean

Returns true if circles overlap

closest(

values: number[],
referenceValue: number

)

#

Returns number

Returns the closest value from the array of values to the reference value.

cos(

angle: number

)

#

Returns number

Returns cosine of an angle specified in degrees.

fitAngleToRange(

value: number,
startAngle: number,
endAngle: number

)

#

Returns number

fitToRange(

value: number,
min: number,
max: number

)

#

Returns number

getAngle(

point1: IPoint,
point2?: IPoint

)

#

Returns number

getArcBounds(

cx: number,
cy: number,
startAngle: number,
endAngle: number,
radius: number

)

#

Returns IBounds

getArcPoint(

radius: number,
arc: number

)

#

Returns { x: number,
  y: number }

Returns point on arc

getPointOnLine(

pointA: IPoint,
pointB: IPoint,
position: number

)

#

Returns IPoint

inBounds(

point: IPoint,
bounds: IBounds

)

#

Returns boolean

mergeBounds(

bounds: IBounds[]

)

#

Returns IBounds

normalizeAngle(

value: number

)

#

Returns number

round(

value: number,
precision?: undefined | number,
floor?: undefined | false | true

)

#

Returns number

"Rounds" the date to specific time unit.

sin(

angle: number

)

#

Returns number

Returns sine of an angle specified in degrees.

spiralPoints(

cx: number,
cy: number,
radius: number,
radiusY: number,
innerRadius: number,
step: number,
radiusStep: number,
startAngle: number,
endAngle: number

)

#

Returns IPoint[]

Generates points of a spiral

tan(

angle: number

)

#

Returns number

Returns tan of an angle specified in degrees.