Skip to content

Percent

Type class

Represents a relative value (percent).

The Percent object, can be instantiated using two ways:

  • Via new Percent(X).

  • Via am4core.percent(X).

Percent type objects can be used in a number of dual-measuring or positioning properties, like width. E.g.:

chart.paddingRight = new Percent(10);
// or
chart.paddingRight = am4core.percent(10);
chart.paddingRight = new Percent(10);
// or
chart.paddingRight = am4core.percent(10);
{
  // ...
  "paddingRight": "10%"
}

Sources

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

/**
* Import from: "core.ts"
* Use like: am4core.Percent
*/
import * as am4core from "@amcharts/amcharts4/core";

Inheritance

Percent does not extend any other symbol.

Percent is not extended by any other symbol.

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 am4core.Percent(50);
console.log(value * percent.value); // outputs 128
var value = 256;
var percent = new am4core.Percent(50);
console.log(value * percent.value); // outputs 128

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

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

Methods

constructor(percent: number)

Returns Percent

Constructor.

toString()

Returns string

Events

Percent does not have any events.