【问题标题】:highcharter markdown presentationhighcharter 降价演示
【发布时间】:2016-02-26 00:26:18
【问题描述】:

我正在尝试在reveal.js 演示文稿中构建一些Highchart(包HighCharter)。 现在我正在根据page 改编蜘蛛网图表。
这是我的代码:

 ```{r, echo=FALSE, message=FALSE, results = 'asis', comment = NA}
library("highcharter")
library(magrittr)

gg<- highchart() %>% 
  hc_chart(polar = TRUE, type = "line") %>% 
  hc_title(text = "Where do you usually buy solar protection products? (%)") %>% 
  hc_subtitle(text = "Move the mouse pointer on the spiderweb chart to view the data") %>% 
  hc_xAxis(categories = c('Supermarket',
                      'Department Store',
                      'Pharmacy',
                      'Perfumery',
                      'Herbalist',
                      'Internet',
                      'Shop for Personal Care'
  ),
  tickmarkPlacement = 'on',
  lineWidth = 0) %>% 
hc_yAxis(gridLineInterpolation = 'polygon',
       lineWidth = 0,
       min = 0) %>% 
  hc_series(
    list(
      name = "Male (%)",
      data = c(14.3,
           9.1,
           35.8,
           26.3,
           4.9,
           4.6,
           4.1
  ),
  pointPlacement = 'on', color="#88C425"
  ),
 list(
  name = "Female (%)",
  data = c(17.0,
           7.0,
           40.2,
           28.8,
           18.3,
           2.2,
           3.6
  ),
  pointPlacement = 'on', color="#A8DBA8"
  )
  )


gg$show("inline", include_assets = TRUE)


```

好吧,代码在正常的 sintax 中可以正常工作,但是我将它包含在 RMarkdown sintax 中,结果是一个错误:

Error in eval(expr, envir, enclos) : 
tentativo di applicare una non-funzione
Calls: <Anonymous> ... handle -> withCallingHandlers -> withVisible -> eval -> eval

有人可以帮忙吗?

【问题讨论】:

  • 嗨!为什么使用 gg$show() 而不是 gg? Highcharter没有show方法!编辑:我现在看到我也不能在 r 演示文稿中使用图表。我会检查
  • 嗨@jbkunst,实际上我尝试了'gg'并且没有创建任何对象......但是这些解决方案在演示文稿中不起作用。感谢您的帮助
  • 嗨@jbkunst,你有没有机会看看你是否可以在演示文稿中放置一个Highchart?如果我们不能因为它们看起来很好,那就太可惜了。提前致谢

标签: r highcharts r-markdown reveal.js


【解决方案1】:

好吧,我的朋友!这项工作(在我的环境中)。

结果在这里http://jkunst.com/highcharter/presentation/

首先你必须使用下一个函数来代替打印 htmlwidget 将它保存在一个 html 文件中,然后放置一个 iframe html 标记来调用这个 html。

knit_print.htmlwidget <- function(x, ..., options = NULL){

  options(pandoc.stack.size = "2048m")

  wdgtclass <- setdiff(class(x), "htmlwidget")[1]
  wdgtrndnm <- paste0(sample(letters, size = 7), collapse = "")
  wdgtfname <- sprintf("wdgt_%s_%s.html", wdgtclass, wdgtrndnm)

  htmlwidgets::saveWidget(x, file = wdgtfname, selfcontained = TRUE, background = "transparent")

  iframetxt <- sprintf("<iframe  frameBorder=\"0\" src=\"%s\" width=\"100%%\"   height=\"600\"></iframe>", wdgtfname)

  knitr::asis_output(iframetxt)
}

基本上实现这里@9​​87654322@和这里https://github.com/ramnathv/slidify/issues/414提到的partials解决方案

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-04-19
  • 1970-01-01
  • 2021-09-26
  • 2015-07-21
  • 2021-11-14
  • 2022-11-13
  • 1970-01-01
相关资源
最近更新 更多