View source: R/amRangeAreaChart.R
| amRangeAreaChart | R Documentation |
Create a HTML widget displaying a range area chart.
amRangeAreaChart( data, data2 = NULL, xValue, yValues, areas = NULL, hline = NULL, vline = NULL, xLimits = NULL, yLimits = NULL, expandX = 0, expandY = 5, Xformatter = ifelse(isDate, "yyyy-MM-dd", "#."), Yformatter = "#.", chartTitle = NULL, theme = NULL, animated = TRUE, draggable = FALSE, tooltip = NULL, bullets = NULL, alwaysShowBullets = FALSE, lineStyle = NULL, backgroundColor = NULL, xAxis = NULL, yAxis = NULL, scrollbarX = FALSE, scrollbarY = FALSE, legend = NULL, caption = NULL, image = NULL, button = NULL, cursor = FALSE, width = NULL, height = NULL, export = FALSE, chartId = NULL, elementId = NULL )
data |
a dataframe |
data2 |
|
xValue |
name of the column of |
yValues |
a character matrix with two columns; each row corresponds to
a range area and provides the names of two columns of |
areas |
an unnamed list of list of settings for the range areas; the
n-th inner list of settings corresponds to the n-th row of the
|
hline |
an optional horizontal line to add to the chart; it must be a
named list of the form |
vline |
an optional vertical line to add to the chart; it must be a
named list of the form |
xLimits |
range of the x-axis, a vector of two values specifying
the left and right limits of the x-axis; |
yLimits |
range of the y-axis, a vector of two values specifying
the lower and upper limits of the y-axis; |
expandX |
if |
expandY |
if |
Xformatter |
a
number formatting string
if |
Yformatter |
a
number formatting string;
it is used to format the values displayed in the cursor tooltips if
|
chartTitle |
chart title, it can be |
theme |
theme, |
animated |
Boolean, whether to animate the rendering of the graphic |
draggable |
|
tooltip |
settings of the tooltips; |
bullets |
settings of the bullets; |
alwaysShowBullets |
logical, whether the bullets should always be visible, or visible on hover only |
lineStyle |
settings of the lines; |
backgroundColor |
a color for the chart background |
xAxis |
settings of the x-axis given as a list, or just a string
for the axis title; the list of settings has five possible fields:
a field |
yAxis |
settings of the y-axis given as a list, or just a string
for the axis title; the list of settings has five possible fields:
a field |
scrollbarX |
logical, whether to add a scrollbar for the x-axis |
scrollbarY |
logical, whether to add a scrollbar for the y-axis |
legend |
|
caption |
|
image |
option to include an image at a corner of the chart;
|
button |
|
cursor |
option to add a cursor on the chart; |
width |
the width of the chart, e.g. |
height |
the height of the chart, e.g. |
export |
logical, whether to enable the export menu |
chartId |
a HTML id for the chart |
elementId |
a HTML id for the container of the chart; ignored if the chart is displayed in Shiny, in which case the id is given by the Shiny id |
A color can be given by the name of a R color, the name of a CSS
color, e.g. "crimson" or "silver", an HEX code like
"#ff009a", a RGB code like "rgb(255,100,39)", or a HSL code
like "hsl(360,11,255)".
set.seed(666)
x <- 1:20
dat <- data.frame(
x = x,
y1 = rnorm(20, sd = 1.5),
y2 = rnorm(20, 10, sd = 1.5),
z1 = rnorm(20, x+5, sd = 1.5),
z2 = rnorm(20, x+15, sd = 1.5)
)
amRangeAreaChart(
data = dat,
width = "700px",
xValue = "x",
yValues = rbind(c("y1", "y2"), c("z1", "z2")),
xLimits = c(1, 20),
draggable = TRUE,
backgroundColor = "#30303d",
tooltip = list(
y1 = amTooltip(
text = "[bold]upper: {openValueY}\nlower: {valueY}[/]",
textColor = "yellow",
backgroundColor = "darkmagenta",
backgroundOpacity = 0.8,
borderColor = "rebeccapurple",
scale = 0.9
),
y2 = amTooltip(
text = "[bold]upper: {valueY}\nlower: {openValueY}[/]",
textColor = "yellow",
backgroundColor = "darkmagenta",
backgroundOpacity = 0.8,
borderColor = "rebeccapurple",
scale = 0.9
),
z1 = amTooltip(
text = "[bold]upper: {openValueY}\nlower: {valueY}[/]",
textColor = "white",
backgroundColor = "darkred",
backgroundOpacity = 0.8,
borderColor = "crimson",
scale = 0.9
),
z2 = amTooltip(
text = "[bold]upper: {valueY}\nlower: {openValueY}[/]",
textColor = "white",
backgroundColor = "darkred",
backgroundOpacity = 0.8,
borderColor = "crimson",
scale = 0.9
)
),
bullets = list(
y1 = amCircle(color = "yellow", strokeColor = "olive"),
y2 = amCircle(color = "yellow", strokeColor = "olive"),
z1 = amCircle(color = "orangered", strokeColor = "darkred"),
z2 = amCircle(color = "orangered", strokeColor = "darkred")
),
alwaysShowBullets = FALSE,
lineStyle = list(
y1 = amLine(color = "yellow", width = 3, tensionX = 0.8, tensionY = 0.8),
y2 = amLine(color = "yellow", width = 3, tensionX = 0.8, tensionY = 0.8),
z1 = amLine(color = "orangered", width = 3, tensionX = 0.8, tensionY = 0.8),
z2 = amLine(color = "orangered", width = 3, tensionX = 0.8, tensionY = 0.8)
),
areas = list(
list(name = "y1-y2", color = "blue", opacity = 0.2),
list(name = "z1-z2", color = "red", opacity = 0.2)
),
cursor = list(
tooltip = amTooltip(
backgroundColor = "silver"
),
extraTooltipPrecision = list(x = 0, y = 2),
modifier = list(y = "text = parseFloat(text).toFixed(2);")
),
chartTitle = amText(text = "Range area chart",
color = "whitesmoke",
fontWeight = "bold"),
xAxis = list(title = amText(text = "Observation",
fontSize = 20,
color = "silver"),
labels = amAxisLabels(color = "whitesmoke",
fontSize = 17),
adjust = 5),
yAxis = list(title = amText(text = "Value",
fontSize = 20,
color = "silver"),
labels = amAxisLabels(color = "whitesmoke",
fontSize = 17),
gridLines = amLine(color = "antiquewhite",
opacity = 0.4, width = 1)),
Xformatter = "#",
Yformatter = "#.00",
image = list(
image = amImage(
href = tinyIcon("react", backgroundColor = "transparent"),
width = 40, height = 40
),
position = "bottomleft", hjust = 2, vjust = -2
),
theme = "dark")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.