01 | { |
02 | color: "#0000FF" |
03 | } |
AnyChart Stock 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 this formats and gives user the way for built-in color transformation.
As it was said above AnyChart supports the following color setting notation, which means - you can use any of them when setting a value of color attribute in any node:
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.
HSB sets color in Hue-Saturation-Brightness color space. Syntax: HSB(hue,saturation,brightness), where hue – varies from 0 to 360, saturation – from 0 to 100, and brightness - 0 to 100. Sample colors: hsb(0,100,100) – Red color, hsb(60,100,100) – yellow color, hsb(0,0,100) – white, etc.
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, below you will find their reference and a sample of their usage in creation of you own style for Column charts.
Function | Description |
---|---|
LightColor(Color) | Returns Lighter color than given |
DarkColor(Color) | Returns Darker color than given |
LightColor 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 for highlighting element. Input color can be specified in any of the specified above.
Sample: LightColor(Red) = LightColor(RGB(255,0,0)) = LightColor(#FF0000) = #FF5959
Input color | LightColor | ||
---|---|---|---|
#FF0000 | #FF5959 |
DarkColor 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 for outlining an element. Input color can be specified in any of the specified above.
Sample: DarkColor(Red) = DarkColor(RGB(255,0,0)) = DarkColor(#FF0000) = #A50000
Input color | DarkColor | ||
---|---|---|---|
#FF0000 | #A50000 |
By default all series are colored in black, to color series you should set its color explicitly.
Sample syntax to color the series:
The color can be set in different format, it can be hex code, web-constant, RGB or HSB macros, also you can use transform functions, for example: <series color="DarkColor(#FEFE00)"/>.
The color set for the series used to draw the series and other depended elements, such as legend item, tooltip and markers.
Wherever you configure the series you can set either a color constant or %Color token, which will be replaced by the value of color attribute upon rendering.
Here is a sample XML for lines and fill of Area series:
As you can see %Color is used to configure fill and line, but for line color is transformed: DarkColor(%Color), to make border distinct.
Live sample below shows to Area series, two of them use settings from defaults section and the third one uses personal settings with static colors defined: