Skip to contents

Create a Line Chart

Usage

v_line(
  vc,
  mapping = NULL,
  data = NULL,
  name = NULL,
  line = list(style = list(curveType = "linear", lineDash = 0, stroke = NULL)),
  point = list(visible = FALSE),
  ...,
  serie_id = NULL,
  data_id = NULL
)

Arguments

vc

A chart initialized with vchart().

mapping

Default list of aesthetic mappings to use for chart.

data

Default dataset to use for chart. If not already a data.frame, it will be coerced to with as.data.frame.

name

Name for the serie, only used for single serie (no color/fill aesthetic supplied).

line

Line's options, such as curve interpolation type, see online documentation

point

Options for showing points on lines or not.

...

Additional parameters for the serie.

data_id, serie_id

ID for the data/serie, can be used to further customize the chart with v_specs().

Value

A vchart() htmlwidget object.

Examples


library(vchartr)

# Basic Line Chart
vchart(eco2mix) %>% 
  v_line(aes(date, solar))
# Two lines vchart(tail(eco2mix, 30), aes(date)) %>% v_line(aes(y = solar)) %>% v_line(aes(y = wind))
# Line chart with discrete x axis vchart(data.frame(month = month.abb, value = sample(1:50, 12))) %>% v_line(aes(month, value))
# Stroke color vchart(data.frame(month = month.abb, value = sample(1:50, 12))) %>% v_line( aes(month, value), line = list(style = list(stroke = "firebrick")) )
# Smooth Line Chart vchart(data.frame(month = month.abb, value = sample(1:50, 12))) %>% v_line( aes(month, value), line = list(style = list(curveType = "monotone")) )
# Step Line Chart vchart(data.frame(month = month.abb, value = sample(1:50, 12))) %>% v_line( aes(month, value), line = list(style = list(curveType = "stepAfter")) )
# Dash array vchart(data.frame(month = month.abb, value = sample(1:50, 12))) %>% v_line( aes(month, value), line = list(style = list(lineDash = c(10, 10))) )
# Multiple lines vchart(eco2mix_long) %>% v_line(aes(date, production, color = source))