A few helper functions for the formatStyle() function to
calculate CSS styles for table cells based on the cell values. Under the
hood, they just generate JavaScript and CSS code from the values specified in
R.
a character vector of data values to be mapped (one-to-one) to
CSS values
data
the numeric vector to be represented as color bars (in fact, only
its range, i.e. min and max, is needed here)
color
the color of the bars
Details
The function styleInterval() maps intervals to CSS values. Its
argument values must be of length n + 1 where n =
length(cuts). The right-closed interval (cuts[i - 1], cuts[i]] is
mapped to values[i] for i = 2, 3, ..., n; values[1] is
for the interval (-Inf, cuts[1]], and values[n + 1] is for
(cuts[n], +Inf). You can think of the order of cuts and
values using this diagram: -Inf -> values[1] -> cuts[1] ->
values[2] -> cuts[2] -> ... -> values[n] -> cuts[n] -> values[n + 1] ->
+Inf.
The function styleEqual() maps data values to CSS values in the
one-to-one manner, i.e. values[i] is used when the table cell value is
levels[i].
The function styleColorBar() can be used to draw background color bars
behind table cells in a column, and the width of bars is proportional to the
column values.