1、 dygraphs 是一個開源的Javascript庫,它可以產生一個可交互式的,可縮放的的曲線表。其可以用來顯示大密度的數據集(比如股票,氣溫,等等),並且可以讓用戶來瀏覽和解釋這個曲線圖。
2、 R中的時間序列格式有好多種,如ts, xts, zoo,但dygraphs只支持xts格式的。
3、zoo作爲時間序列的基礎庫,是面向通用的設計,可以用來定義股票數據,也可以分析天氣數據。xts擴展了zoo,提供更多的數據處理和數據變換的函數。實際上,xts類型繼承了zoo類型,豐富了時間序列數據處理的函數,API定義更貼近使用者,更實用,更簡單!
4、 Xts時間序列的數據是matrix型,
5、 xts(1:10, Sys.Date()+1:10), Sys.time(), Sys.Date()
dygraph(gas_climate1314.xts[,c(10,11)], main = "2013~2014 Industry Vs. Warming Gas") %>%
dyRangeSelector() %>%
dyAxis("y", label = "Industry Gas") %>%
dyAxis("y2", label = "Warming Gas", independentTicks = TRUE) %>%
dyOptions(axisLineWidth = 1.5, fillGraph = TRUE, drawGrid = TRUE) %>%
dyOptions(includeZero = TRUE, axisLineColor = "navy", gridLineColor = "lightblue") %>%
dyOptions(colors = RColorBrewer::brewer.pal(3, "Set2")) %>%
dyOptions(fillGraph = TRUE, fillAlpha = 0.4) %>%
dyOptions(drawPoints = TRUE, pointSize = 2) %>%
dyHighlight(highlightCircleSize = 5, highlightSeriesBackgroundAlpha = 0.2, hideOnMouseOut = FALSE) %>%
dyHighlight(highlightSeriesOpts = list(strokeWidth = 3)) %>%
dySeries("Warming Gas(10KNm3)", axis = 'y2')
6、好的栗子
【Kaggle代碼(R):基於dygraph的Rossmann Store銷量(預測)交互可視化】
https://www.kaggle.com/shearerp/rossmann-store-sales/interactive-sales-visualization/code
http://rstudio.github.io/dygraphs/gallery-shaded-regions.html