gWidgets - 我如何更新特定gnotebook页面上的ggraphics小部件

时间:2013-06-19 12:43:28

标签: r gwidgets

有关如何更新特定gnotebook页面上的ggraphics窗口小部件的任何建议。

我有多个gnotebook页面(标签)使用Quantmod的charSeries来填充ggraphics。我正在尝试更新各个gnotebook页面。但是,任何更改都只应用于最后一页而不是我想要的页面。以下相关代码示例。我已尝试使用svalue< - 或focus< - 在更新之前将焦点放在相关页面上,但这不起作用。

library("quantmod")
library ( gWidgets )
options ( guiToolkit="RGtk2" )
w <- gwindow("notebook example")
group <- ggroup(horizontal= FALSE, container = w)
notebook <- gnotebook(container=group)

symbol<-"EBT.AX"
getSymbols(symbol)

gg1<-ggraphics(cont=notebook, expand = TRUE, label="Trends")
   chartSeries(get(symbol),subset="last 2 months", name="Trends")
gg2<-ggraphics(cont=notebook, expand = TRUE, label="Momentum") 
   chartSeries(get(symbol),subset="last 2 months", name="Momentum")
gg3<-ggraphics(cont=notebook, expand = TRUE, label="Volatility") 
   chartSeries(get(symbol),subset="last 2 months",name="Volatile")

gbutton("update",container = group, handler = function(h,...) {
gg2 <- reChart(subset = "last 4 month", theme = "white")})

1 个答案:

答案 0 :(得分:2)

您可以在绘图前致电visible(ggXXX) <- TRUE。这将使ggraphics设备成为当前设备。