From 76b5dd1fd9b698d8016407695df570400fe8e96b Mon Sep 17 00:00:00 2001 From: Eric Hung Date: Wed, 3 Aug 2016 16:53:10 +0800 Subject: [PATCH] Refactor zooom to zoom new chartSeries object As S4 method used by chartSeries is deprecated, xdata and xsubset should be obtained from .plotxtsEnv environment. plot object is printed if users want to select period more than once (n>1). --- R/zoomChart.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/R/zoomChart.R b/R/zoomChart.R index 9269fdfb..6fb3765e 100644 --- a/R/zoomChart.R +++ b/R/zoomChart.R @@ -23,8 +23,8 @@ function (n = 1, eps = 2) } else { usr <- par("usr") - xdata <- get.chob()[[2]]@xdata - xsubset <- get.chob()[[2]]@xsubset + xdata <- current.chob()$Env$xdata + xsubset <- current.chob()$Env$xsubset sq <- floor(seq(usr[1], usr[2], 1)) st <- which(floor(points$x[1]) == sq)/length(sq) * NROW(xdata[xsubset]) @@ -33,9 +33,10 @@ function (n = 1, eps = 2) sorted <- sort(c(st, en)) st <- sorted[1] en <- sorted[2] * 1.05 - zoomChart(paste(index(xdata[xsubset])[max(1, floor(st), - na.rm = TRUE)], index(xdata[xsubset])[min(ceiling(en), - NROW(xdata[xsubset]), na.rm = TRUE)], sep = "::")) + cs <- zoomChart(subset = paste(index(xdata[xsubset])[max(1, floor(st), + na.rm = TRUE)], index(xdata[xsubset])[min(ceiling(en), + NROW(xdata[xsubset]), na.rm = TRUE)], sep = "::")) + print(cs) } } cat("done\n")