Create a HTML widget displaying a line chart with a focus tool.
lineFocusChart(
data,
xAxisTitle = "x",
yAxisTitle = "y",
margins = list(l = 90),
duration = 500,
useInteractiveGuideline = FALSE,
xAxisTickFormat = ".0f",
yAxisTickFormat = ".02f",
xLabelsFontSize = "0.75rem",
yLabelsFontSize = "0.75rem",
legendPosition = "top",
interpolate = "linear",
xRange = NULL,
yRange = NULL,
rightAlignYaxis = FALSE,
tooltipFormatters = list(value = NULL, header = NULL, key = NULL),
tooltipTransitions = TRUE,
tooltipShadow = TRUE,
width = "100%",
height = NULL,
elementId = NULL
)
data used for the chart; it must be a list created with
lineChartData
, or a list of such lists (for multiple lines)
string, the title of the x-axis
string, the title of the y-axis
a named list defining the margins, with names "t"
,
"r"
, "b"
and "l"
, for "top", "right", "bottom"
and "left" respectively; you can specify only certain margins in the list
to change just those parts
transition duration in milliseconds
Boolean, a guideline and synchronized tooltips
a d3 formatting string for the ticks on the x-axis; a d3 time formatting string if the x-values are dates, see d3.time.format
a d3 formatting string for the ticks on the y-axis
a CSS measure, the font size of the labels on the x-axis
a CSS measure, the font size of the labels on the y-axis
string, the legend position, "top"
or
"right"
interpolation type, a string among "linear"
,
"step-before"
, "step-after"
, "basis"
,
"basis-open"
, "basis-closed"
, "bundle"
,
"cardinal"
, "cardinal-open"
, "cardinal-closed"
,
"monotone"
the x-axis range, a length two vector of the same type as the
x-values, or NULL
to derive it from the data
the y-axis range, a numeric vector of length 2, or
NULL
to derive it from the data
Boolean, whether to put the y-axis on the right side instead of the left
formatters for the tooltip; each formatter must
be NULL
for the default formatting, otherwise a JavaScript function
created with JS
; there are three possible formatters
(see the example):
formatter for the y-value displayed in the tooltip
formatter for the tooltip header (this is the x-value)
formatter for the value of the 'by' variable
Boolean, whether to style the tooltip with a fade effect
Boolean, whether to style the tooltip with a shadow
width of the chart container, must be a valid CSS measure
height of the chart container, must be a valid CSS measure
an id for the chart container, usually useless
A HTML widget displaying a line chart with a focus tool.
# NOT RUN {
library(Rnvd3)
dat1 <-
lineChartData(x = ~ 1:100, y = ~ sin(1:100/10), key = "Sine wave", color = "lime")
dat2 <-
lineChartData(x = ~ 1:100, y = ~ sin(1:100/10)*0.25 + 0.5,
key = "Another sine wave", color = "red")
dat <- list(dat1, dat2)
lineFocusChart(dat)
# }
Run the code above in your browser using DataLab