Color
Type class
A color. Every color setting takes a Color object, usually created with am5.color(), e.g. am5.color(0xff0000).
More info: Colors, gradients, and patterns
Sources
Color can be used (imported) via one of the following packages.
// Import Colorimport * as am5 from "@amcharts/amcharts5";
// Create Coloram5.Color.new(root, { // ... config if applicable});<!-- Load Color --><script src="index.js"></script>
<script>// Create Coloram5.Color.new(root, { // ... config if applicable});</script>Inheritance
Color does not extend any other symbol.
Color is not extended by any other symbol.
Properties
bType
numberThe blue channel, from
0to255.gType
numberThe green channel, from
0to255.hexType
numberThe color as a number, such as
0xff0000.rType
numberThe red channel, from
0to255.
Methods
alternative(color:Color,
lightAlternative?:Color,
darkAlternative?:Color)StaticReturns
ColorReturns
lightAlternativeordarkAlternative, whichever contrasts more withcolor: the dark one for a light color, the light one for a dark.brighten(color:Color,
percent:number)StaticReturns
ColorReturns a new
Colorbrightened bypercent, from-1to1. Unlikelighten(), it adds the same amount to every channel. A negative value dims the color.fromAny(s:string|number|Color)StaticReturns
ColorReturns a new
Colorfrom a hex number, a hex,rgb()orrgba()string, or anotherColor. Throws an error for anything else.fromCSS(s:string)StaticReturns
ColorReturns a new
Colorfrom a CSSrgb()orrgba()string. The alpha part is ignored, and a string it can't read gives black.Color.fromCSS("rgba(255, 0, 0, 1)") // redColor.fromCSS("rgba(255, 0, 0, 1)") // redfromHex(hex:number)StaticReturns
ColorReturns a new
Colorfrom a hex number.Color.fromHex(0xff0000) // redColor.fromHex(0xff0000) // redfromHSL(h:number,
s:number,
l:number)StaticReturns
ColorReturns a new
Colorfrom hue, saturation and lightness.fromRGB(r:number,
g:number,
b:number)StaticReturns
ColorReturns a new
Colorfrom red, green and blue channels.fromString(s:string)StaticReturns
ColorReturns a new
Colorfrom a hex string, such as"#ff0000"or"#f00".Color.fromString("#ff0000") // redColor.fromString("#ff0000") // redinterpolate(diff:Time,
from:Color,
to:Color,
mode:"rgb"|"hsl")StaticReturns
ColorReturns a color between
fromandto.interpolateColors(position:number,
colors:Array,
mode:"rgb"|"hsl")StaticReturns
ColorReturns a color on a scale through
colors, spread evenly: with three colors,0.5is the middle one. For example, from bad to good:[negative, warning, positive]from the interface colors.lighten(color:Color,
percent:number)StaticReturns
ColorReturns a new
Colorlightened bypercent, from-1to1:0.2moves each channel 20% of the way to white. A negative value darkens it toward black.saturate(color:Color,
percent:number)StaticReturns
ColorReturns a new
Colorwith its saturation set topercent, from0(grey) to1. The value replaces the color's saturation rather than adjusting it;1returns the color unchanged.toCSS(alpha:number)Returns
stringReturns the color as a CSS
rgba(r, g, b, a)string.toCSSHex()Returns
stringReturns the color as a CSS hex string, such as
"#ff0000".toHSL(alpha:number)Returns
iHSLReturns the color's hue, saturation and lightness, each from
0to1.toString()Returns
string
Events
Color does not have any events.