Percent

Type class

Represents a relative value (percent).

The Percent object, can be instantiated using two ways:

  • Via new Percent(X).
  • Via am5.percent(X).

You can also use shortcut functions for 0%, 50%, and 100%:

  • am5.p0
  • am5.p50
  • am5.p1000

Sources

Percent can be used (imported) via one of the following packages.

// Percent is available in all of the following modules.
// You only need to import one of them.

/**
 * --------------------------------------------------------
 * Import from: "index.ts"
 * Use like: am5.Percent
 * --------------------------------------------------------
 */
import * as am5 from "@amcharts/amcharts5";

// Percent is available in all of the following modules.
// You only need to import one of them.

/**
 * --------------------------------------------------------
 * Include via: <script src="index.js"></script>
 * Access items like: am5.Percent
 * --------------------------------------------------------
 */

Inheritance

Percent does not extend any other symbol.

Percent is not extended by any other symbol.

Settings

Percent does not have any settings.

Private settings

Percent does not have any private settings.

Properties

percent
#

Type number

Value in percent.

value
#

Type number

Relative value.

E.g. 100% is 1, 50% is 0.5, etc.

This is useful to apply transformations to other values. E.g.:

let value = 256;
let percent = new am5.p50;
console.log(value * percent.value); // outputs 128
var value = 256;
var percent = new am5.p50;
console.log(value * percent.value); // outputs 128

Alternatively, you can use am5.percent() helper function:

let value = 256;
let percent = am5.p50;
console.log(value * percent.value); // outputs 128
var value = 256;
var percent = am5.p50;
console.log(value * percent.value); // outputs 128

@readonly

Methods

constructor(

percent: number

)

#

Returns Percent

Constructor.

interpolate(

min: number,
max: number

)

#

Returns number

normalize(

percent: Percent | number,
min: number,
max: number

)

#

Static

Returns Percent

toString()

#

Returns string

Events

Percent does not have any events.