AnyChart
API Reference
Still have questions?
Contact support
Top

namespace anychart.color Improve this Doc

Color utility namespace.

Functions Overview

bipolarHueProgression()Multiple bipolar hue progression.
blend()Blend two colors together, using the specified factor to indicate the weight given to the first color.
blendedHueProgression()Multiple blended hue progression.
darken()Makes color darker by a factor.
lighten()Makes color lighter by a factor.
setThickness()Sets opacity to stroke.
singleHueProgression()Single-hue progression.

Functions Description

bipolarHueProgression

Multiple bipolar hue progression.

Params:

NameTypeDefaultDescription
color1string
'blue'
Color in rgb, named or hex string representation like 'rgb(255, 0, 0)', 'red' or '#ff0000' accordingly.
color2string
'red'
Color in rgb, named or hex string representation like 'rgb(255, 0, 0)', 'red' or '#ff0000' accordingly.
countnumber
7
Count of progression colors.

Returns:

Array.<string> - Multiple bipolar hue progression. Array of colors.

blend

Blend two colors together, using the specified factor to indicate the weight given to the first color.

Params:

NameTypeDescription
rgb1Array.<number>The first color represented as RGB array of 3 numbers.
rgb2Array.<number>The second color represented as RGB array of 3 numbers.
factornumberThe weight of the first color over the second one rgb2. Values should be in the [0, 1] range. If set to a value less than 0, the factor will be set to 0. If greater than 1, the factor will be set to 1.

blendedHueProgression

Multiple blended hue progression.

Params:

NameTypeDefaultDescription
color1string
'#ffff00'
Color in rgb, named or hex string representation like 'rgb(255, 0, 0)', 'red' or '#ff0000' accordingly.
color2string
'#a52a2a'
Color in rgb, named or hex string representation like 'rgb(255, 0, 0)', 'red' or '#ff0000' accordingly.
countnumber
7
Count of progression colors.

Returns:

Array.<string> - Multiple blended hue progression. Array of colors.

darken

Makes color darker by a factor.

Params:

NameTypeDefaultDescription
fillOrStrokeanychart.graphics.vector.Fill | anychart.graphics.vector.Stroke
Fill or stroke to be darkened.
factornumber
0.3
Black color blending factor.

Returns:

string | anychart.graphics.vector.Fill | anychart.graphics.vector.Stroke - Hex representation of the darkened color, or Color if color can't be darkened.

lighten

Makes color lighter by a factor.

Params:

NameTypeDefaultDescription
fillOrStrokeanychart.graphics.vector.Fill | anychart.graphics.vector.Stroke
Fill or stroke to be lightened.
factornumber
0.3
White color blending factor.

Returns:

string | anychart.graphics.vector.Fill | anychart.graphics.vector.Stroke - Hex representation of the lightened color, or Color if color cannot be lightened.

setThickness

Sets opacity to stroke.

Params:

NameTypeDescription
strokeanychart.graphics.vector.StrokeStroke.
thicknessnumberThickness to set.
opacitynumberOpacity to set.

Returns:

anychart.graphics.vector.Stroke - Normalized color with new thickness.

singleHueProgression

Single-hue progression.

Params:

NameTypeDefaultDescription
colorstring
'black'
Color in rgb, named or hex string representation like 'rgb(255, 0, 0)', 'red' or '#ff0000' accordingly.
countnumber
7
Count of progression colors.
startOrTargetLightnessnumber
0.95
Source lightness. Number in [0, 1]. 1 - very light (white), 0 - vere dark (black). If opt_startOrTargetLightness and opt_endLightness don't defined, then lightness progression starts from 0.95 and ends to lightness of passed color.
endLightnessnumber
from passed color
Target lightness. Number in [0, 1]. 1 - very light (white), 0 - vere dark (black).

Returns:

Array.<string> - Single hue progression. Array of colors.