yihui / animation

A gallery of animations in statistics and utilities to create animations
https://yihui.org/animation/
206 stars 60 forks source link

How to embed in Markdown&html outside Rmd and shiny #109

Open huyingjie opened 6 years ago

huyingjie commented 6 years ago

My blog uses hexo, which is a static website generator. Each blog post is a Markdown file. blogdown developed by Yihui Xie has a lot of errors and I do not have the knowledge to fix them. I do not use shiny.

How to embed the animation plot generated in a Markdown file? Do you have javascript link similar to bootstrap<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>?

How to get the javascript code containing data which generates the animation plot?

Thank you.

yulijia commented 6 years ago

I am not familiar with hexo. But you can generate the animation figure on your local computer, and upload it to online storage platform. Then you can embed the figure with markdown syntax ![GitHub Logo](/images/logo.png).

Animation is not a javascript library, if you want to generate animation picture with javascript, please take a look at D3.js and ployly, there are a lot of ways to produce dynamic, interactive data visualizations in web browsers.

huyingjie commented 6 years ago

@yulijia Thank you for your reply. My definition of animation is not clear. It is not an animated gif file. I want to embed graphs generated from ployly r package. Yes, there are a lot of r packages generating interactive visualization graph. But none of them supply the raw codes of javascript. Thus, it is impossible for me to embed them in hexo.

Hexo will automatically convert a html which has interactive grah into a post. But I want to embed them in a post, not to create a graph as a whole post.

yulijia commented 6 years ago

This is maybe what you need: Data Visualization Using Plotly in Hexo, and here is the raw html code of that post.

Hexo cannot convert any r code (in Markdown file) to figure (in html static website). Please use blogdown, also Yihui provides a simple example at blogdown-hexo.

If you have any question when using blogdown, please ask them on StackOverflow with the blogdown tag.