-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcolor.html
156 lines (135 loc) · 8.59 KB
/
color.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>6.20. Color Functions — Presto 0.202 Documentation</title>
<link rel="stylesheet" href="../_static/presto.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.202',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="top" title="Presto 0.202 Documentation" href="../index.html" />
<link rel="up" title="6. Functions and Operators" href="../functions.html" />
<link rel="next" title="6.21. Session Information" href="session.html" />
<link rel="prev" title="6.19. Geospatial Functions" href="geospatial.html" />
</head>
<body role="document">
<div class="header">
<h1 class="heading"><a href="../index.html">
<span>Presto 0.202 Documentation</span></a></h1>
<h2 class="heading"><span>6.20. Color Functions</span></h2>
</div>
<div class="topnav">
<p class="nav">
<span class="left">
« <a href="geospatial.html">6.19. Geospatial Functions</a>
</span>
<span class="right">
<a href="session.html">6.21. Session Information</a> »
</span>
</p>
</div>
<div class="content">
<div class="section" id="color-functions">
<h1>6.20. Color Functions</h1>
<dl class="function">
<dt id="bar">
<code class="descname">bar</code><span class="sig-paren">(</span><em>x</em>, <em>width</em><span class="sig-paren">)</span> → varchar</dt>
<dd><p>Renders a single bar in an ANSI bar chart using a default
<code class="docutils literal"><span class="pre">low_color</span></code> of red and a <code class="docutils literal"><span class="pre">high_color</span></code> of green. For example,
if <code class="docutils literal"><span class="pre">x</span></code> of 25% and width of 40 are passed to this function. A
10-character red bar will be drawn followed by 30 spaces to create
a bar of 40 characters.</p>
</dd></dl>
<dl class="function">
<dt>
<code class="descname">bar</code><span class="sig-paren">(</span><em>x</em>, <em>width</em>, <em>low_color</em>, <em>high_color</em><span class="sig-paren">)</span> → varchar</dt>
<dd><p>Renders a single line in an ANSI bar chart of the specified
<code class="docutils literal"><span class="pre">width</span></code>. The parameter <code class="docutils literal"><span class="pre">x</span></code> is a double value between [0,1].
Values of <code class="docutils literal"><span class="pre">x</span></code> that fall outside the range [0,1] will be
truncated to either a 0 or a 1 value. The <code class="docutils literal"><span class="pre">low_color</span></code> and
<code class="docutils literal"><span class="pre">high_color</span></code> capture the color to use for either end of
the horizontal bar chart. For example, if <code class="docutils literal"><span class="pre">x</span></code> is 0.5, <code class="docutils literal"><span class="pre">width</span></code>
is 80, <code class="docutils literal"><span class="pre">low_color</span></code> is 0xFF0000, and <code class="docutils literal"><span class="pre">high_color</span></code> is 0x00FF00
this function will return a 40 character bar that varies from red
(0xFF0000) and yellow (0xFFFF00) and the remainder of the 80
character bar will be padded with spaces.</p>
<div class="figure align-center">
<img alt="../_images/functions_color_bar.png" src="../_images/functions_color_bar.png" />
</div>
</dd></dl>
<dl class="function">
<dt id="color">
<code class="descname">color</code><span class="sig-paren">(</span><em>string</em><span class="sig-paren">)</span> → color</dt>
<dd><p>Returns a color capturing a decoded RGB value from a 4-character
string of the format “#000”. The input string should be varchar
containing a CSS-style short rgb string or one of <code class="docutils literal"><span class="pre">black</span></code>,
<code class="docutils literal"><span class="pre">red</span></code>, <code class="docutils literal"><span class="pre">green</span></code>, <code class="docutils literal"><span class="pre">yellow</span></code>, <code class="docutils literal"><span class="pre">blue</span></code>, <code class="docutils literal"><span class="pre">magenta</span></code>, <code class="docutils literal"><span class="pre">cyan</span></code>,
<code class="docutils literal"><span class="pre">white</span></code>.</p>
</dd></dl>
<dl class="function">
<dt>
<code class="descname">color</code><span class="sig-paren">(</span><em>x</em>, <em>low</em>, <em>high</em>, <em>low_color</em>, <em>high_color</em><span class="sig-paren">)</span> → color</dt>
<dd><p>Returns a color interpolated between <code class="docutils literal"><span class="pre">low_color</span></code> and
<code class="docutils literal"><span class="pre">high_color</span></code> using the double parameters <code class="docutils literal"><span class="pre">x</span></code>, <code class="docutils literal"><span class="pre">low</span></code>, and
<code class="docutils literal"><span class="pre">high</span></code> to calculate a fraction which is then passed to the
<code class="docutils literal"><span class="pre">color(fraction,</span> <span class="pre">low_color,</span> <span class="pre">high_color)</span></code> function shown below.
If <code class="docutils literal"><span class="pre">x</span></code> falls outside the range defined by <code class="docutils literal"><span class="pre">low</span></code> and <code class="docutils literal"><span class="pre">high</span></code>
it’s value will be truncated to fit within this range.</p>
</dd></dl>
<dl class="function">
<dt>
<code class="descname">color</code><span class="sig-paren">(</span><em>x</em>, <em>low_color</em>, <em>high_color</em><span class="sig-paren">)</span> → color</dt>
<dd><p>Returns a color interpolated between <code class="docutils literal"><span class="pre">low_color</span></code> and
<code class="docutils literal"><span class="pre">high_color</span></code> according to the double argument <code class="docutils literal"><span class="pre">x</span></code> between 0
and 1.0. The parameter <code class="docutils literal"><span class="pre">x</span></code> is a double value between [0,1].
Values of <code class="docutils literal"><span class="pre">x</span></code> that fall outside the range [0,1] will be
truncated to either a 0 or a 1 value.</p>
</dd></dl>
<dl class="function">
<dt id="render">
<code class="descname">render</code><span class="sig-paren">(</span><em>x</em>, <em>color</em><span class="sig-paren">)</span> → varchar</dt>
<dd><p>Renders value <code class="docutils literal"><span class="pre">x</span></code> using the specific color using ANSI
color codes. <code class="docutils literal"><span class="pre">x</span></code> can be either a double, bigint, or varchar.</p>
</dd></dl>
<dl class="function">
<dt>
<code class="descname">render</code><span class="sig-paren">(</span><em>b</em><span class="sig-paren">)</span> → varchar</dt>
<dd><p>Accepts boolean value <code class="docutils literal"><span class="pre">b</span></code> and renders a green true or a red
false using ANSI color codes.</p>
</dd></dl>
<dl class="function">
<dt id="rgb">
<code class="descname">rgb</code><span class="sig-paren">(</span><em>red</em>, <em>green</em>, <em>blue</em><span class="sig-paren">)</span> → color</dt>
<dd><p>Returns a color value capturing the RGB value of three
component color values supplied as int parameters ranging from 0
to 255: <code class="docutils literal"><span class="pre">red</span></code>, <code class="docutils literal"><span class="pre">green</span></code>, <code class="docutils literal"><span class="pre">blue</span></code>.</p>
</dd></dl>
</div>
</div>
<div class="bottomnav">
<p class="nav">
<span class="left">
« <a href="geospatial.html">6.19. Geospatial Functions</a>
</span>
<span class="right">
<a href="session.html">6.21. Session Information</a> »
</span>
</p>
</div>
<div class="footer" role="contentinfo">
</div>
</body>
</html>