hMultiBarChart {Rnvd3} | R Documentation |
Horizontal multibar chart
Description
HTMLwidget displaying a horizontal multibar chart.
Usage
hMultiBarChart(
data,
formula,
by,
palette = "viridis",
xAxisTitle = NULL,
yAxisTitle = NULL,
margins = list(b = 100, l = 100),
duration = 1300,
groupSpacing = 0.1,
xAxisTitleDistance = 25,
yAxisTitleDistance = -5,
yAxisShowMaxMin = FALSE,
yAxisTickFormat = ".0f",
nticks = 5,
xLabelsFontSize = "1rem",
yLabelsFontSize = "1rem",
showValues = FALSE,
tooltipFormatters = list(value = NULL, header = NULL, key = NULL),
tooltipTransitions = TRUE,
tooltipShadow = TRUE,
width = "100%",
height = NULL,
elementId = NULL
)
Arguments
data |
dataframe containing the data used for the chart |
formula |
a two-sided formula like |
by |
string, the "by" variable; must be a column name of |
palette |
this can be either the name of a viridis color palette, e.g.
|
xAxisTitle |
a title for the x-axis; if |
yAxisTitle |
a title for the y-axis; if |
margins |
a named list defining the margins, with names |
duration |
duration of the transition, a number of milliseconds |
groupSpacing |
a number, controls the distance between groups of bars |
xAxisTitleDistance |
a number, controls the distance between the x-axis and its title |
yAxisTitleDistance |
a number, controls the distance between the y-axis and its title |
yAxisShowMaxMin |
Boolean, whether to show the min and the max on the y-axis |
yAxisTickFormat |
a d3 formatting string for the y-axis; see d3.format |
nticks |
integer, the number of ticks on the y-axis |
xLabelsFontSize |
a CSS measure, the font size of the labels on the x-axis |
yLabelsFontSize |
a CSS measure, the font size of the labels on the y-axis |
showValues |
Boolean, whether to show the values next to the bars |
tooltipFormatters |
formatters for the tooltip; each formatter must
be
|
tooltipTransitions |
Boolean, whether to style the tooltip with a fade effect |
tooltipShadow |
Boolean, whether to style the tooltip with a shadow |
width |
width of the chart container, must be a valid CSS measure |
height |
height of the chart container, must be a valid CSS measure |
elementId |
an id for the chart container; commonly useless |
Value
A htmlwidget displaying a grouped/stacked bar chart.
Examples
library(Rnvd3)
dat <- aggregate(breaks ~ wool + tension, data = warpbreaks, mean)
levels(dat[["tension"]]) <- c("Low", "Medium", "High")
hMultiBarChart(
dat, breaks ~ wool, "tension", yAxisShowMaxMin = TRUE,
yAxisTitle = "Mean of breaks", yAxisTickFormat = ".01f"
)
# the axis titles are small, let's make them bigger
library(htmltools)
CSS <- HTML(
".nvd3 .nv-axis.nv-x text.nv-axislabel,
.nvd3 .nv-axis.nv-y text.nv-axislabel {
font-size: 1rem;
}"
)
prependContent(
hMultiBarChart(
dat, breaks ~ wool, "tension", yAxisShowMaxMin = TRUE,
yAxisTitle = "Mean of breaks", yAxisTickFormat = ".01f"
),
tags$style(CSS)
)