2

我正在将内部仪表板从 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>
4

0 回答 0