gvisAnnotatedTimeLine 函數圖表上的標題 (Title on chart for gvisAnnotatedTimeLine function)


問題描述

gvisAnnotatedTimeLine 函數圖表上的標題 (Title on chart for gvisAnnotatedTimeLine function)

I am using the gvisAnnotatedTimeLine function from the googleVis package, and was wondering if there was a way of adding in a Title (not an annotation) into the output, as I can't see an argument for it in the function help file.

Thanks in advance


參考解法

方法 1:

Here is a function that should include a title to the chart. The input is either an HTML string or a shiny.tag. 

addGvisATLTitle <- function(gvisATL,title)  {

if (!all(class(gvisATL) == c("gvis","list"))) {
  stop('ERROR in addGvisATLTitle: Incorrect type, expect gvisAnnotatedTimeLine.')
}
if (class(title) == "character") {
  gvisATL$html$chart['divChart'] <- paste(title,gvisATL$html$chart['divChart'],sep="")
} else if (class(title) == "shiny.tag") {
  gvisATL$html$chart['divChart'] <- paste(as.character(title)[1],gvisATL$html$chart['divChart'],sep="")
} else {
  stop('ERROR in addGvisATLTitle: Unknown title type.')
}
return(gvisATL)
}

you can test it out with

 a <- data.frame(date=Sys.Date(),val=20)
 b <- gvisAnnotatedTimeLine(a)
 plot(addTitle(b,"<h1> My chart </h1>"))
 plot(addTitle(b,h1("My chart")))
  • I have updated it to work with gvisMerge

(by h.l.mGeoffrey Absalom)

參考文件

  1. Title on chart for gvisAnnotatedTimeLine function (CC BY-SA 3.0/4.0)

#R #annotatedtimeline #google-visualization #title






相關問題

如何將均值、標準差等函數應用於整個矩陣 (How to apply mean, sd etc. function to a whole matrix)

Tạo các thùng của mỗi hàng trong bảng và vẽ hình thanh ngăn xếp trong R (Make bins of each table row and draw stack bar figure in R)

Reading not quite correct .csv file in R (Reading not quite correct .csv file in R)

包'treemap'中的線條粗細 (Thickness of lines in Package ‘treemap’)

是否需要帶有 awk 的預處理文件,或者可以直接在 R 中完成? (Is preprocessing file with awk needed or it can be done directly in R?)

rpivotTable 選擇元素下拉菜單 (rpivotTable select elements drop down menu)

優化性能 - Shiny 中的大文件輸入 (Optimizing Performance - Large File Input in Shiny)

數值取決於所應用的應用系列,R (Numeric values depending of apply family applied, R)

如何記錄全年的值? (How to note the values across year?)

R中的線性搜索 (Linear search in R)

在 dplyr/purrr 工作流程中動態連接多個數據集 (Dynamically join multiple datasets in a dplyr/purrr workflow)

如何將行值更改為列名 (R) (How change Row values to Column names (R))







留言討論