| lineChart {Rnvd3} | R Documentation | 
Line chart
Description
Create a HTML widget displaying a line chart.
Usage
lineChart(
  data,
  xAxisTitle = "x",
  yAxisTitle = "y",
  margins = list(l = 90),
  duration = 500,
  useInteractiveGuideline = TRUE,
  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
 | 
| 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  | 
| 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,  | 
| interpolate | interpolation type, a string among  | 
| xRange | the x-axis range, a length two vector of the same type as the
x-values, or  | 
| yRange | the y-axis range, a numeric vector of length 2, or
 | 
| 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  
 | 
| 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.
Examples
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)
lineChart(dat)
# with a date x-axis ####
dat1 <-
  lineChartData(
    x = ~ Sys.Date() + 1:100, y = ~ sin(1:100/10), key = "Sine wave", color = "lime"
  )
dat2 <-
  lineChartData(x = ~ Sys.Date() + 1:100, y = ~ sin(1:100/10)*0.25 + 0.5,
                key = "Another sine wave", color = "darkred")
dat <- list(dat1, dat2)
lineChart(
  dat,
  margins = list(t = 100, r = 100, b = 100, l = 100),
  xAxisTickFormat = "%Y-%m-%d"
)
# with a datetime x-axis
dat <- data.frame(
  x  = Sys.time() + (1:300),
  y1 = sin(1:300/10),
  y2 = sin(1:300/10)*0.25 + 0.5
)
dat1 <-
  lineChartData(x = ~x, y = ~y1, data = dat, key = "Sine wave", color = "lime")
dat2 <-
  lineChartData(x = ~x, y = ~y2, data = dat,
                key = "Another sine wave", color = "darkred")
dat12 <- list(dat1, dat2)
lineChart(
  dat12,
  margins = list(t = 100, r = 100, b = 100, l = 100),
  xAxisTickFormat = "%H:%M:%S",
  xAxisTitle = "Time", yAxisTitle = "Energy"
)