Color
chartjs: Color
A color or a list of colors for a Chart.js chart.
Every dataset property that takes a color, such as backgroundColor,
holds a Color object.
See also: BarChart, BarData, BubbleChart, BubbleData, DoughnutChart, DoughnutData, LineChart, LineData, PieChart, PieData, PolarAreaChart, PolarAreaData, RadarChart, RadarData, ScatterChart, ScatterData
Source Code: Color
The Color class contains the following properties:
The value passed to the Color constructor, unchanged: a
color name or hexadecimal code, a cellstring array of them, an RGB or
RGBA matrix, or a cell array of color space names and values.
The Color class offers the following public methods:
Color: obj = Color (value)
When value is character vector, it can define a single color either
by using one of the acceptable color names given below or by using
hexadecimal string values in the forms #FFFFFF and
#FFFFFFFF. The former defines an RGB color space,
whereas the later defines an RGBA color space that includes
transparency.
Valid color names are:
beige
black
blue, lightblue, darkblue
brown
coral, lightcoral
cyan, darkcyan
green, lightgreen, darkgreen
gray, grey, lightgray, lightgrey,
darkgray, darkgrey
magenta, darkmagenta
pink
red, darkred
white
yellow, lightyellow
If you want to apply multiple colors to a given dataset, then you can use a cellstring array whose elements follow the requirements for character vector values described above. The cellstring array must be a vector and its elements can interchangeably contain known color names or hexadecimal color values.
If value is a numeric, it follows Octave’s native RGB
tripplet syntax. An RGB triplet is a 1x3 vector where
each value is between 0 and 1 inclusive. The first value represents the
percentage of Red, the second value the percentage of Green, and the
third value the percentage of Blue. This syntax is also extended to
support RGBA quadruplets, in which case the fourth value (also
between 0 and 1 inclusive) of the 1x4 vector represents the
transparency. If you want to apply multiple colors to a given dataset,
then you can pass a numeric matrix of Nx3 or Nx4 size with
each row representing a distinct RGB tripplet or RGBA
quadruplet, respectively.
Alternatively you can define value as a cell array with two
elements or an Nx2 cell matrix in case you need to specify
multiple colors in the same dataset. The first element of each row
represents a color space name, which can be any of the four available
choices: rgb, rgba, hsl, and hsla. The
second element of each row must be a numeric 1x3 vector for
rgb and hsl color spaces, or a numeric 1x4 vector
for rgba and hsla color spaces. When assigning color
value(s) as a cell array, the RGB values must be between 0 and
255 inclusive, the hue value must be between 0 and 360 inclusive,
the saturation and lightness values must be percentages
between 0 and 100 inclusive, whereas the alpha value must be
between 0 and 1 inclusive. All numeric values except for the
transparency are expected to be integer values, otherwise they are
rounded to the nearest integer.