6.23. Color Functions
bar
(x, width) → varcharRenders a single bar in an ANSI bar chart using a default
low_color
of red and ahigh_color
of green. For example,ifx
of 25% and width of 40 are passed to this function. A10-character red bar will be drawn followed by 30 spaces to createa bar of 40 characters.bar
(x, width, low_color, high_color) → varchar- Renders a single line in an ANSI bar chart of the specified
width
. The parameterx
is a double value between [0,1].Values ofx
that fall outside the range [0,1] will betruncated to either a 0 or a 1 value. Thelow_color
andhigh_color
capture the color to use for either end ofthe horizontal bar chart. For example, ifx
is 0.5,width
is 80,low_color
is 0xFF0000, andhigh_color
is 0x00FF00this function will return a 40 character bar that varies from red(0xFF0000) and yellow (0xFFFF00) and the remainder of the 80character bar will be padded with spaces.
color
(string) → colorReturns a color capturing a decoded RGB value from a 4-characterstring of the format “#000”. The input string should be varcharcontaining a CSS-style short rgb string or one of
black
,red
,green
,yellow
,blue
,magenta
,cyan
,white
.color
(x, low, high, low_color, high_color) → colorReturns a color interpolated between
low_color
andhigh_color
using the double parametersx
,low
, andhigh
to calculate a fraction which is then passed to thecolor(fraction, low_color, high_color)
function shown below.Ifx
falls outside the range defined bylow
andhigh
it’s value will be truncated to fit within this range.color
(x, low_color, high_color) → colorReturns a color interpolated between
low_color
andhigh_color
according to the double argumentx
between 0and 1.0. The parameterx
is a double value between [0,1].Values ofx
that fall outside the range [0,1] will betruncated to either a 0 or a 1 value.render
(x, color) → varcharRenders value
x
using the specific color using ANSIcolor codes.x
can be either a double, bigint, or varchar.render
(b) → varcharAccepts boolean value
b
and renders a green true or a redfalse using ANSI color codes.rgb
(red, green, blue) → color- Returns a color value capturing the RGB value of threecomponent color values supplied as int parameters ranging from 0to 255:
red
,green
,blue
.