rAmCharts - amFloatingBar

Parameters

  • x: a character, column name for x-axis, or a numeric, number of the corresponding column. It is optional if argument data has row names.
  • y_inf: a character, column name for the lower value, or a numeric, number of the corresponding column.
  • y_sup: a character, column name for the lower value, or a numeric, number of the corresponding column.
  • data: a dataframe with values to display. You can add a column “color” (character, colors in hexadecimal). You can also add a column “description” (character) containing the text you want to display when mouse is on the graphic (‘<br>’ for a new line).
  • groups_color: a character, vector of colors in hexadecimal, same length as y.
  • xlab: a character, label for x-axis.
  • ylab: a character, label for y-axis.
  • horiz: a boolean, TRUE for an horizontal chart, FALSE for a vertical one.
  • show_values: a boolean, TRUE ti dosplay values.
  • depth: a numeric. If depth is superior to 0, chart is displayed in 3D. Value between 0 and 100.
  • dataDateFormat: a character, default ‘NULL’. Even if your chart parses dates,you can pass them as strings in your data - all you need to do is to set data date format and the chart will parse dates to date objects. Please note that two-digit years (YY) as well as literal month names (MMM) are NOT supported in this setting.
  • minPeriod: a character. Specifies the shortest period of your data. This should be set only if dataDateFormat is not ‘NULL’. Possible period values: fff - milliseconds, ss - seconds, mm - minutes, hh - hours, DD - days, MM - months, YYYY - years. It’s also possible to supply a number for increments, i.e. ‘15mm’ which will instruct the chart that your data is supplied in 15 minutes increments.
  • : other parameters called in amOptions.

Notice: If the chart has many columns, several labels might be hidden. It depends on the width of the conatainer where the chart is displayed. Zoom on the chart to see if the chart can contain all labels. If not, use the parameter labelRotation. You can also add a cursor to your chart…

Data used in the examples:

data("data_fbar")
head(data_fbar)
##   country visits_inf visits_sup   color
## 1     USA       3000       3025 #FF0F00
## 2   China       1800       1882 #FF6600
## 3   Japan       1000       1809 #FF9E01
## 4 Germany       1300       1322 #FCD202
## 5      UK       1100       1122 #F8FF01
## 6  France       1000       1114 #B0DE09
data("data_gbar")
head(data_gbar)
##   year        day   month income expenses
## 1 2005 01/06/2005 06/2005   23.5     18.1
## 2 2006 02/06/2005 07/2005   26.2     22.8
## 3 2007 03/06/2005 08/2005   30.1     23.9
## 4 2008 04/06/2005 09/2005   29.5     25.1
## 5 2009 05/06/2005 10/2005   24.6     25.0

Reference example

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45)

Horizontal floating bar

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, horiz = TRUE)

3D bar

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45, depth = 15)

Display values

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45, show_values = TRUE)

Change colors

  amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
                data = data_fbar[,1:3], labelRotation = -45, groups_color = "#67b7dc")

Parse dates - default label: first day of each year

pipeR::pipeline(
  amFloatingBar(x = "year", y_inf = "expenses", y_sup = "income", data = data_gbar,
                dataDateFormat = "YYYY", minPeriod = "YYYY"), 
  setChartCursor()
)

Parse dates - default label: first day of each month

pipeR::pipeline(
  amFloatingBar(x = "month", y_inf = "expenses", y_sup = "income", data = data_gbar,
                dataDateFormat = "MM/YYYY", minPeriod = "MM"),
  setChartCursor()
)

amOptions

export

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45, export = TRUE)
#or
amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45) %>>% 
  amOptions(export = TRUE)

exportFormat

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45, export = TRUE,
          exportFormat = "JPG")
#or
amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45) %>>% 
  amOptions(export = TRUE, exportFormat = "CSV")

main and creditsPosition

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45, main = "My Floating Barchart",
              mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")
#or
amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45) %>>% 
  amOptions(main = "My Barchart",
            mainColor = "#68838B", mainSize = 25, creditsPosition = "top-right")

theme

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45,  
              theme = "patterns")
#or
amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45) %>>% 
  amOptions(theme = "patterns")