File: EventListener.R

package info (click to toggle)
r-cran-googlevis 0.7.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,404 kB
  • sloc: makefile: 5
file content (34 lines) | stat: -rw-r--r-- 1,121 bytes parent folder | download | duplicates (4)
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
## The parameter gvis.listener.jscode embeds code inside
## a select event listener.
## It is possible to add javascript code and access the build in
## method getSelection().
##
## The following code shows two examples:

jscode <- "window.open('https://en.wikipedia.org/wiki/'+data.getValue(chart.getSelection()[0].row,0));  "
J1 <- gvisGeoMap(Exports, locationvar='Country', numvar='Profit',
                 options=list(dataMode="regions",gvis.listener.jscode=jscode))

plot(J1)
## Similarly the code can also be used for other charts, e.g. org chart and line chart

plot(gvisOrgChart(Regions,  options=list(gvis.listener.jscode=jscode)))

plot(gvisLineChart(Regions[,c(1,3)],  options=list(gvis.listener.jscode=jscode)))


jscode <- "
       var sel = chart.getSelection();
       var row = sel[0].row;
       var text = data.getValue(row,1);
       alert(text);
"

J2 <- gvisTable(Population,options=list(gvis.listener.jscode=jscode))

plot(J2)

## For more details see
## https://developers.google.com/chart/interactive/docs/reference?csw=1#addlistener

## See demo(package='googleVis') for other available demos.