Plotters: Employ a dygraph plotter on a series, a group of series, or...

Description Usage Arguments Value Available plotters Examples

Description

Plotters provide variuos ways to customize how your data appears on the dygraph. Series-based plotters allow users to mix-and-match different plotters on a per-series or (with dyGroup) a per-group basis. See dyPlotter for additional detail.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

Arguments

dygraph

Dygraph to add plotter to

compress

(For dyCandlestick) If true, compress data yearly, quarterly, monthly, weekly or daily according to overall amount of bars and/or current zoom level.

name

name - or chrarcter vector of names - of (the) series within the data set

...

additional options to pass to dySeries

Value

A dygraph with the specified plotter(s) employed.

Available plotters

Currently the dygraphs package provides the following plotters:

dyBarChart()

Draws a bar plot rather than a line plot. If the provided dygraph features more than one series, dyBarChart will call dyMultiColumn instead.

dyStackedBarChart()

Draws a bar chart stacking all the underlying series.

dyMultiColumn()

Draws multiple column bar chart.

dyBarSeries()

Draws a single set of bars for just the provided series.

dyStemSeries()

Draws a single set of stems for just the provided series.

dyShadow()

An extraction of the _fillplotter from dygraph-combined-dev.js, drawing the filled area without the line.

dyFilledLIne()

An extraction of the _fillplotter and _lineplotter combo from dygraph-combined-dev.js. dyFilledLine allows users to fill only a single series.

dyMultiColumnGroup()

The multicolumn plotter, but on a subset of the series, leaving the others for other plotters.

dyCandlestick()

Draw a candlestick chart.

dyCandleStickGroup()

Employed on the provided series, but still plotting the others.

dyStackerBarGroup()

Return the data group as stacked bars

dyStackerRibbonGroup()

Return the data group as stacked ribbons

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## The following two examples will results in the same dygraph:

dygraph(mdeaths) %>% 
  dyBarChart()
 
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyMultiColumn()
  

## Per-series plotters:

lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyBarSeries('fdeaths')

lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyStemSeries('fdeaths')
  
lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyShadow('fdeaths')

lungDeaths <- cbind(mdeaths, fdeaths)
dygraph(lungDeaths) %>%
  dyFilledLine('fdeaths')

## A bunch of different plotters together:

lungDeaths <- cbind(fdeaths, mdeaths, ldeaths, foo = fdeaths/2, bar = fdeaths/3)
dygraph(lungDeaths) %>%
  dyRangeSelector() %>%
  dyBarSeries('bar') %>% 
  dyStemSeries('mdeaths') %>% 
  dyShadow('foo') %>% 
  dyFilledLine('fdeaths')

## Group-based plotters:
  

## Candlestick plotters:
  
library(xts)
data(sample_matrix)
library(dygraphs)
dygraph(sample_matrix) %>%
  dyCandlestick()
  
sample<-data.frame(sample_matrix)
sample_2<-sample*2
names(sample_2)<-c('O', 'H', 'L', 'C')
sample<-cbind(sample, sample_2)
dygraph(sample) %>% 
  dyOptions(stackedGraph = TRUE) %>% 
  dyCandlestickGroup(c('Open', 'High', 'Low', 'Close')) %>% 
  dyCandlestickGroup(c('O', 'H', 'L', 'C'))

## Stacked Bar and Ribbon Graphs:  

dygraph(lungDeaths) %>% 
  dySeries('mdeaths', axis = 'y2') %>%
  dyAxis('y', valueRange = c(-100, 1000)) %>% 
  dyStackedBarGroup(c('ldeaths', 'fdeaths'))
  
lungDeaths <- cbind(ldeaths, fdeaths, mdeaths, 
                    additive = rep.int(200, length(ldeaths)),
                    line = rep.int(3000, length(ldeaths)))
dygraph(lungDeaths) %>% 
  dySeries('line', strokePattern = 'dashed') %>% 
  dySeries('ldeaths', stepPlot = TRUE) %>% 
  dyStackedBarGroup(c('additive', 'mdeaths')) %>% 
  dyStackedRibbonGroup(c('fdeaths', 'ldeaths'))

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Warning message:
In dyGroup(dygraph = list(x = list(attrs = list(labels = c("day",  :
  dyGroup is incompatible with stackedGraph... stackedGraph now FALSE

dygraphs documentation built on May 2, 2019, 3:34 p.m.

Related to Plotters in dygraphs...