Color
Type class
Represents a color.
Color accepts value only in iRGB object format. To create Color object by parsing it from any supported string-based formats, use helper color function:
am4core.color("#ff0000");
am4core.color("#f00");
am4core.color("rgb(255, 0, 0)");
am4core.color("rgba(255, 0, 0, 0.5)");
am4core.color({ r: 255, g: 0, b: 0 });
am4core.color("red");
am4core.color("#ff0000");
am4core.color("#f00");
am4core.color("rgb(255, 0, 0)");
am4core.color("rgba(255, 0, 0, 0.5)");
am4core.color({ r: 255, g: 0, b: 0 });
am4core.color("red");
More info: Colors, Gradients, Patterns for color-related info
Sources
Color can be used (imported) via one of the following packages.
/** * Import from: "core.ts" * Use like: am4core.Color */import * as am4core from "@amcharts/amcharts4/core";/** * Include via: <script src="core.js"></script> * Access items like: am4core.Color */Inheritance
Color does not extend any other symbol.
Color is not extended by any other symbol.
Properties
alphaType
numberSet alpha (transparency) of the color.
Returns current transparency.
alternativeType
ColorReturns a either light or dark color that contrasts specifically with this color.
Uses properties
darkColor(default black) andlightColor(default white).Useful when determining which color label should be on a colored background, so that it stands out.
darkColorType
ColorSets "dark" color. Used when determining contrasting color.
Returns current dark color setting.
hexType
stringReturns color hex value string, e.g. "#FF0000".
lightColorType
ColorSets "light" color. Used when determining contrasting color.
Returns current light color setting.
rgbType
$type.Optional<iRGB>Returns
iRGBrepresentation of the color.rgbaType
stringReturns an
rgba()representation of the color, e.g.:rgba(255, 0, 0, 0.5).
Methods
brighten(percent:number)Returns
ColorReturns a new
Colorwhich is percent brighter (positive value), or darker (negative value).Parameter is in the scale of -1 to 1.
constructor(color:$type.Optional<iRGB>)Returns
ColorConstructor
lighten(percent:number)Returns
ColorReturns a new
Colorwhich is percent lighter (positive value), or darker (negative value).Parameter is in the scale of -1 to 1.
saturate(saturation:number)Returns
ColorReturns a new
Colorbased on current color with specific saturation applied.saturationcan be in the range of 0 (fully desaturated) to 1 (fully saturated).
Events
Color does not have any events.