AnyChart html5 charting library allows you to set color of any element of the chart, and moreover - it provides a very user/designer/developer friendly mechanism of color setting. Web-developers usually work with Hexadecimal or Web-Colors, desktop developer use RGB or HSB notation. AnyChart supports all these formats and gives user the way for built-in color transformation.
- Hexadecimal (html-like)
- Red Green Blue
- Web-Color Constants
Hexadecimal notation is widely used in HTML. A hex triplet is a six-digit, three-byte hexadecimal number used in HTML and CSS, and other computing applications, to represent colors. The bytes represent the red, green and blue components of the color. One byte represents a number in the range 00 to FF (in hexadecimal notation). This represents the least (0) to the most (255) intensity of each of the color components. The hex triplet is formed by concatenating three bytes in hexadecimal notation, in the following order: red value; green value; blue value.
When setting color using Hexadecimal notation you should use "#" before hex constant itself, for example, to set font color to blue you should specify:
This format, just as Hexadecimal, sets color using three components: red, green and blue, but uses decimal, not hexadecimal values, for example: RGB(255,255,0) stands for absolutely Yellow. The syntax: RGB(red,green,blue), where red, green and blue – decimal values, that vary from 0 to 255.
Also you can use Web Color constants. For example: "Red", "Gold", "RoyalBlue", etc. Table with full list of color constants, along with their hexadecimal, RGB and HSB you can find on Web Color Constants Table.
To make design easier - AnyChart Provides several color transformation functions. See descriptions below:
|lighten(Color)||Returns Lighter color than given|
|darken(Color)||Returns Darker color than given|
|blend(Color1, Color2, Ratio)||Blend two colors with a given Ratio|
lighten() function is used to return for sure a color that is lighter than a given, for example, if input color is Black - we will get some non-black color, that can be used to highlight an element.
|Input color||Light Color|
darken() function is used to return for sure a color that is darker than a given, for example, if input color is White - we will get some non-white color, that can be used to outline an element.
blend() function allows you to mix two colors with a given ratio.
var color1 = [255, 0, 0]; var color2 = [0, 0, 255]; var mixColor1 = anychart.color.blend(color1, color2, 0.2);
|Input color||Blend color||Ratio||Result Color|
|#FF0000||#008000||0 (full mixture)||#008000|
|#FF0000||#008000||1 (no mixture)||#FF0000|