lineFocusChart: Line chart with focus

Description Usage Arguments Value Examples

View source: R/rnvd3.R

Description

Create a HTML widget displaying a line chart with a focus tool.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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
)

Arguments

data

data used for the chart; it must be a list created with lineChartData, or a list of such lists (for multiple lines)

xAxisTitle

string, the title of the x-axis

yAxisTitle

string, the title of the y-axis

margins

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

duration

transition duration in milliseconds

useInteractiveGuideline

Boolean, a guideline and synchronized tooltips

xAxisTickFormat

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

yAxisTickFormat

a d3 formatting string for the 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

legendPosition

string, the legend position, "top" or "right"

interpolate

interpolation type, a string among "linear", "step-before", "step-after", "basis", "basis-open", "basis-closed", "bundle", "cardinal", "cardinal-open", "cardinal-closed", "monotone"

xRange

the x-axis range, a length two vector of the same type as the x-values, or NULL to derive it from the data

yRange

the y-axis range, a numeric vector of length 2, or NULL to derive it from the data

rightAlignYaxis

Boolean, whether to put the y-axis on the right side instead of the left

tooltipFormatters

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):

value

formatter for the y-value displayed in the tooltip

header

formatter for the tooltip header (this is the x-value)

key

formatter for the value of the 'by' variable

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, usually useless

Value

A HTML widget displaying a line chart with a focus tool.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
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)

Rnvd3 documentation built on Sept. 5, 2021, 5:18 p.m.