amFloatingBar: Plotting floating bar chart using rAmCharts

View source: R/chart_amFloatingBar.R

amFloatingBarR Documentation

Plotting floating bar chart using rAmCharts

Description

amFloatingBar computes a floating bar chart of the given values.

Usage

amFloatingBar(
  x,
  y_inf,
  y_sup,
  data,
  xlab = "",
  ylab = "",
  groups_color = NULL,
  horiz = FALSE,
  show_values = FALSE,
  depth = 0,
  dataDateFormat = NULL,
  minPeriod = ifelse(!is.null(dataDateFormat), "DD", ""),
  ...
)

Arguments

x

character, column name for x-axis or numeric value of the corresponding column. It is optional if argument data has row names.

y_inf

character, column name for the lower value or numeric vector of the corresponding column.

y_sup

character, column name for the upper value or numeric vector of the corresponding column.

data

data.frame, 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). See data_fbar.

xlab

character, label for x-axis.

ylab

character, label for y-axis.

groups_color

character, vector of colors in hexadecimal, same length as y_inf or y_sup.

horiz

logical, TRUE for an horizontal chart, FALSE for a vertical one If 'horiz' is set to TRUE, the setting 'labelRotation' will be ignored.

show_values

logical, TRUE to display values.

depth

numeric, if > 0, chart is displayed in 3D. Value between 0 and 100.

dataDateFormat

character, default set to NULL. Even if your chart parses dates, you can pass them as strings in your dataframe - all you need to do is to set data date format and the chart will parse dates to date objects. Check this page for available formats. Please note that two-digit years (YY) as well as literal month names (MMM) are NOT supported in this setting.

minPeriod

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 minute increments.

...

see amOptions for more options.

Details

Notice about labels: 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. You can also add a cursor to your chart...

Value

An object of class AmChart.

References

See online documentation https://datastorm-open.github.io/introduction_ramcharts/ and amChartsAPI

See Also

amOptions, amBarplot, amBoxplot, amHist, amPie, amPlot, amTimeSeries, amStockMultiSet, amBullet, amRadar, amWind, amFunnel, amAngularGauge, amSolidGauge, amMekko, amCandlestick, amFloatingBar, amOHLC, amWaterfall

Examples

# Load data
data(data_fbar)
data(data_gbar)

amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45)
              
amFloatingBar(x = "year", y_inf = "expenses", y_sup = "income", data = data_gbar,
              dataDateFormat = "YYYY", minPeriod = "YYYY", zoom = TRUE)
              
## Not run: 
# Other examples available which can be time consuming depending on your configuration.
library(pipeR)

# Reference example : column chart
amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -45)

# Label rotation modification
amFloatingBar(x = "country", y_inf = "visits_inf", y_sup = "visits_sup",
              data = data_fbar, labelRotation = -90)

# Horizontal 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 = -90, 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")


# Grouped columns
# Parse dates

# Default label: firt day of each year

amFloatingBar(x = "year", y_inf = "expenses", y_sup = "income", data = data_gbar,
              dataDateFormat = "YYYY", minPeriod = "YYYY", zoom = TRUE)

# Default label: first day of each month

amFloatingBar(x = "month", y_inf = "expenses", y_sup = "income", data = data_gbar,
              dataDateFormat = "MM/YYYY", minPeriod = "MM", zoom = TRUE)


amFloatingBar(x = "day", y_inf = "expenses", y_sup = "income", data = data_gbar,
              dataDateFormat = "DD/MM/YYYY", zoom = TRUE)


## End(Not run)



DataKnowledge/rAmCharts documentation built on Oct. 3, 2022, 5:42 a.m.