この例では、JavaScript を使用して rPlot にツールチップを追加する方法 を示しました 。ライブラリ/ハイチャート/examples.R
rPlot に hPlot と同様の on.click イベントを実行させたいのですが、rPlot/polycharts を使用してそれを割り当てる適切な方法を見つけられませんでした。
ポリチャートの例 (ツールチップの適用に成功):
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 の例 (アラーム ポップアップの作成に成功):
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
以下は、プロットするがクリックイベントをトリガーしない現在のコードです。
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
現在 rCharts v0.4.2 を使用しています: パッケージ: rCharts タイプ: パッケージ タイトル: Polycharts.js を使用したインタラクティブ チャート バージョン: 0.4.2 日付: 2013-04-09