-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzoogvisLineChart.R
More file actions
47 lines (40 loc) · 2.01 KB
/
zoogvisLineChart.R
File metadata and controls
47 lines (40 loc) · 2.01 KB
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
zoogvisLineChart<-function(z, ...){
suppressPackageStartupMessages(require(googleVis, quietly = TRUE))
suppressPackageStartupMessages(require(dplyr, quietly = TRUE))
op <- options(gvis.plot.tag=NULL)
if(is.zoo(z)){
df<-data.frame(t=index(z), coredata(z))
tagnames<-names(df)
n<-NCOL(df)-1
#names(df)<-c('t', paste0('v', 1:n))
h1<-gvisLineChart(xvar='t', yvar=tagnames[2:(n+1)], data = df, chartid = 'ZooSeries',
options = list(
crosshair ="{trigger:'both', orientation:'vertical'}",
explorer = "{axis:'horizontal', actions:['dragToZoom', 'rightClickToReset'], maxZoomIn: .01 }",
hAxis = "{title:'Fecha'}",
focusTarget = 'category',
legend = "{position: 'top', textStyle: {color: 'black', fontSize: 15}, maxLines: 10}",
series="[{targetAxisIndex:0, color:'blue', lineWidth: '1'},
{targetAxisIndex:1, color:'red', lineWidth: '1'},
{targetAxisIndex:0, color:'blue', lineWidth: '0.5'},
{targetAxisIndex:1, color:'red', lineWidth: '0.5'}]",
vAxes="[{title:'',
titleTextStyle: {color: 'blue'},
textStyle:{color: 'blue'},
textPosition: 'out',
direction: '1'},
{title:'',
titleTextStyle: {color: 'red'},
textStyle:{color: 'red'},
textPosition: 'out',
direction: '1'}]",
width=1200,
height=600,
title = 'PI Time series',
titleTextStyle = "{position: 'in', textStyle: {color: 'black', fontSize: 18}, maxLines: 10}"
)
)
h1$html$footer<-NULL
h1
}else{print('not a zoo object!!!')}
}