View source: R/amHorizontalDumbbellChart.R
amHorizontalDumbbellChart | R Documentation |
Create a HTML widget displaying a horizontal Dumbbell chart.
amHorizontalDumbbellChart( data, data2 = NULL, category, values, seriesNames = NULL, vline = NULL, xLimits = NULL, expandX = 5, valueFormatter = "#.", chartTitle = NULL, theme = NULL, animated = TRUE, draggable = FALSE, tooltip = NULL, segmentsStyle = NULL, bullets = 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 |
|
category |
name of the column of |
values |
a character matrix with two columns; each row corresponds to
a series and provides the names of two columns of |
seriesNames |
a character vector providing the names of the series
to appear in the legend; its length must equal the number of rows of the
|
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; |
expandX |
if |
valueFormatter |
a
number formatting string;
it is used to format the values displayed in the cursor tooltips,
the labels of the x-axis unless you specify
your own formatter in the |
chartTitle |
chart title, it can be |
theme |
theme, |
animated |
Boolean, whether to animate the rendering of the graphic |
draggable |
|
tooltip |
settings of the tooltips; |
segmentsStyle |
settings of the segments; |
bullets |
settings of the bullets; |
backgroundColor |
a color for the chart background; it can be
given by the name of a R color, the name of a CSS color, e.g.
|
xAxis |
settings of the value 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 category axis given as a list, or just a string
for the axis title; the list of settings has four possible fields:
a field |
scrollbarX |
logical, whether to add a scrollbar for the value axis |
scrollbarY |
logical, whether to add a scrollbar for the category axis |
legend |
either a logical value, whether to display the legend, or
a list of settings for the legend created with |
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 |
set.seed(666) lwr <- rpois(20, 5) dat <- data.frame( comparison = paste0("Ctrl vs. ", LETTERS[1:20]), lwr = lwr, upr = lwr + rpois(20, 10) ) amHorizontalDumbbellChart( width = "500px", height = "450px", data = dat, draggable = TRUE, category = "comparison", values = rbind(c("lwr", "upr")), xLimits = c(0, 30), segmentsStyle = amSegment(width = 1, color = "darkred"), bullets = amCircle(strokeWidth = 0, color = "darkred"), tooltip = amTooltip("left: {valueX}\nright: {openValueX}", scale = 0.75), xAxis = list( title = amText( "difference", fontSize = 17, fontWeight = "bold", fontFamily = "Helvetica" ), gridLines = amLine("darkblue", width = 2, opacity = 0.8, dash = "2,2"), breaks = amAxisBreaks(c(0,10,20,30)) ), yAxis = list( title = amText( "comparison", fontSize = 17, fontWeight = "bold", fontFamily = "Helvetica" ), labels = amAxisLabels(fontSize = 15), gridLines = amLine(color = "red", width = 1, opacity = 0.6, dash = "1,3") ), backgroundColor = "lightsalmon" )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.