在RHTML

时间:2018-02-16 17:01:56

标签: r knitr r-markdown r-highcharter

我正在将内部仪表板从rmarkdown转换为rhtml。当我编写html时,我的所有htmlwidgets图形都呈现为静态图像。这不会发生在本文档的rmarkdown版本中。

这是一个可重复性最低的例子。

<html>
<head>
<title>Highcharter in R HTML</title>
</head>
<body>

<!--begin.rcode setup, echo=FALSE, warning=FALSE
library(tidyverse)
library(htmlwidgets)
library(highcharter)
library(dygraphs)
library(leaflet)
end.rcode-->

<p>This base plot works:</p>
<!--begin.rcode fig.width=7, fig.height=6
plot(cars)
end.rcode-->

<p>Unfortunately, this Highcharter chart renders as a static image and cuts off most of the data:
<!--begin.rcode
highchart() %>% 
  hc_xAxis(categories = citytemp$month) %>% 
  hc_add_series(name = "Tokyo", data = citytemp$tokyo) %>% 
  hc_add_series(name = "New York", data = citytemp$new_york) 
end.rcode-->

<p>Here's an example chart using dygraphs instead of highcharter:</p>
<!--begin.rcode
dygraph(nhtemp, main = "New Haven Temperatures") %>% 
  dyRangeSelector(dateWindow = c("1920-01-01", "1960-01-01"))
end.rcode-->

<p>And here's leaflet:</p>
<!--begin.rcode dev = 'svg'
leaflet() %>% addTiles() %>% setView(0,0,1)
end.rcode-->

</body>
</html>

0 个答案:

没有答案