This example showed how to add a tooltip using javascript to rPlot: rPlot tooltip problems This example showed how to add a click event to an hPlot (highcharts): https://github.com/ramnathv/rCharts/blob/master/inst/libraries/highcharts/examples.R
I would like to get rPlot to do a similar on.click event as hPlot, but haven't been able to figure out the proper way to assign it using rPlot/polycharts.
Polychart Example (successfully applies tooltip):
require(rCharts)
set.seed(1)
test1 <- data.frame(x = rnorm(100), y = rnorm(100), id = 1:100)
p <- rPlot(y ~ x, data = test1,
type = 'point',
point = list(events = list(click = "#!function(item){ alert( 'x: ' + item.x +
' y: ' + item.y + ' id: ' + item.id); }!#")),
tooltip = "#!function(item){ return 'x: ' + item.x +
' y: ' + item.y + ' id: ' + item.id }!#")
p
HighCharts Example (successfully creates alarm popup):
require(rCharts)
a <- hPlot(freq ~ Exer, data = plyr::count(MASS::survey, c('Sex','Exer')), type = 'bar', group = 'Sex', group.na = 'NA\'s')
a$plotOptions(bar = list(cursor = 'pointer', point = list(events = list(click = "#! function() { alert ('Category: '+ this.category +', value: '+ this.y); } !#"))))
a
Below is my current code that plots but does not trigger the clicking event:
require(rCharts)
set.seed(1)
test1 <- data.frame(x = rnorm(100), y = rnorm(100), id = 1:100)
p <- rPlot(y ~ x, data = test1,
type = 'point',
point = list(events = list(click = "#! function() {alert('testMessagePleaseWork');} !#")),
tooltip = "#!function(item){ return 'x: ' + item.x + ' y: ' + item.y + ' id: ' + item.id }!#")
p
Currently using rCharts v0.4.2: Package: rCharts Type: Package Title: Interactive Charts using Polycharts.js Version: 0.4.2 Date: 2013-04-09