简体   繁体   中英

highcharter with blogdown casper-two theme

I'm trying to render some graphs with blogdown (in RMarkdown ).

The problem is that I'm not able to render highcharter graphs with casper-two theme. I'v tried this approach and nothing happens.

After select New Post in RStudio addin I do this:

```{r}
library(highcharter)

mtcars <- tibble::rownames_to_column(mtcars)

hchart(mtcars, "point", hcaes(wt, mpg, color = hp))
```

And this is what I get:

在此处输入图片说明


When I execute the same code above (except by the R . Rmd chunk part) I can visualize the graph perfectly:

在此处输入图片说明

Any help is appreciate.

So the output that you get looks like is the preview of your post on the home page. I can see that when you do go to the post itself, the code retains its pretty output but it's not loading the plot. Some other js/css might be messing with it.

A way to fix this is to wrap the plot in iframe like this:

```{r}
library(highcharter)
library(widgetframe)
mtcars <- tibble::rownames_to_column(mtcars)

frameWidget(hchart(mtcars, "point", hcaes(wt, mpg, color = hp)))
```

To fix the preview section, in your post yaml you can add

description: "Your description"

so that the preview doesn't look so ugly. Another way is to modify the layout of the preview. This is tricky so I would not recommend it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM