grattan-waterfall: Create waterfall charts

Description Usage Arguments Examples

Description

Create waterfall charts

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
grattan_waterfall(.data = NULL, values, labels,
  rect_text_labels = values, rect_text_size = 7.14,
  rect_text_labels_anchor = "centre",
  put_rect_text_outside_when_value_below = 0.05 * (max(cumsum(values)) -
  min(cumsum(values))), calc_total = FALSE, total_axis_text = "Total",
  total_rect_text = sum(values), total_rect_color = gpal(6)[1],
  total_rect_text_color = "white",
  fill_colours = gpalx(length(values)), fill_by_sign = TRUE,
  dark = FALSE, rect_width = 0.7, rect_border = NA_character_,
  draw_lines = TRUE, lines_anchors = c("right", "left"),
  linetype = "dashed", draw_axis.x = "behind", x_axis_labels = TRUE,
  theme_text_family = "", print_plot = TRUE,
  ggplot_object_name = "mywaterfall")

Arguments

.data

a data frame containing two columns, one with the values, the other with the labels

values

a numeric vector making up the heights of the rectangles in the waterfall

labels

the labels corresponding to each vector, marked on the x-axis

rect_text_labels

(character) a character vector of the same length as values that are placed on the rectangles

rect_text_size

size of the text in the rectangles

rect_text_labels_anchor

(character) How should rect_text_labels be positioned. In future releases, we might have support for north or south anchors, or for directed positioning (negative down, positive up) etc. For now, only centre is supported.

put_rect_text_outside_when_value_below

(numeric) the text labels accompanying a rectangle of this height will be placed outside the box: below if it's negative; above if it's positive.

calc_total

(logical) should the final pool of the waterfall be calculated (and placed on the chart)

total_axis_text

(character) the text appearing on the axis underneath the total rectangle

total_rect_text

(character) the text in the middle of the rectangle of the total rectangle

total_rect_color

the color of the final rectangle

total_rect_text_color

the color of the final rectangle's label text

fill_colours

Colours to be used to fill the rectangles, in order. Disregarded if fill_by_sign is TRUE (the default).

fill_by_sign

(logical) should positive and negative values each have the same colour?

dark

(logical) (only for fill_by_sign) should the dark palette be used?

rect_width

(numeric) the width of the rectangle, relative to the space between each label factor

rect_border

the border around each rectangle. Choose NA if no border is desired.

draw_lines

(logical) should lines be drawn between successive rectangles

lines_anchors

a character vector of length two specifying the horizontal placement (left, centre, right) of the drawn lines relative to the preceding and successive rectangles, respectively.

linetype

the linetype for the draw_lines

draw_axis.x

(character) one of "none", "behind", "front" whether to draw an x.axis line and whether to draw it behind or in front of the rectangles, default is behind

x_axis_labels

Whether or not to draw x-axis labels.

theme_text_family

(character) Passed to the text argument in ggplot2::theme.

print_plot

(logical) Whether or not the plot should be printed. By default, TRUE, which means it cannot be assigned.

ggplot_object_name

(character) A quoted valid object name to which ggplot layers may be addded after the function has run. Ignored if print is FALSE.

Examples

1
2
3
4
## Not run: 
grattan_waterfall(values = round(rnorm(5), 2), labels = LETTERS[1:5])

## End(Not run)

HughParsonage/grattanCharts documentation built on May 8, 2019, 10:52 a.m.