dygraphs appears in the html

221 Views Asked by At

I use dygraphs on my website, and dygraphs is embedded in the jupyter notebook (ipynb) file as an input for the web HTML. However, it shows the same two dygraphs plots close to each other on the website. enter image description here

The code in my ipynb file is :

dy <- dygraph(cum_etf_re, main = "Return rate of SP500 and others") %>% 
    dyAxis("y", label = "Cum_Return") %>% 
    dyRangeSelector(height = 20) %>%
    dyLegend(width = "500")
htmlwidgets::saveWidget(dy, "m.html")
display_html('<iframe src="m.html" width=100% height=450></iframe>')

Update 2018.1.1:

I try to fix the problem myself and did some tests. I found when I removed the code display_html('<iframe src="m.html" width=100% height=450></iframe>')in the ipynb file, and put the m.html on my terminal, the dygraph plot that appears on the center of code block would disappear. So the problem is this code. And I checked generated html file of the ipynb file, I found the related html code is as following:

<span class="c1">#htmlwidgets::saveWidget(dy, "m.html")</span>
display_html<span class="p">(</span><span class="s">'<iframe src="m.html" width="100%" height="450"></iframe>'</span><span class="p">)</span>
</pre></div>
</div>
</div>
</div>
<div class="output_wrapper">
<div class="output">
<div class="output_area">
<div class="prompt"></div>
<div class="output_html rendered_html output_subarea ">
<iframe height="450" src="m.html" width="100%"></iframe>

Update 2 :

Ok, I figured out what is going on here, the iframe is recognized twice, once in the code block inside the parenthesis, once in the output of the function display_html. The problem is, how can I avoid this?

Any thoughts would be helpful!

0

There are 0 best solutions below