Programming/Python

plotly offline

빠릿베짱이 2016. 11. 25. 23:20
반응형

 Plotly offline 자동 크기 변환 안되는 경우

 

<div id="5da331c3-3f1f-4331-914e-5ba61259eb35" style="height: 100%; width: 100%;" class="plotly-graph-div"></div>
<script type="text/javascript">window.PLOTLYENV=window.PLOTLYENV || {};window.PLOTLYENV.BASE_URL="https://plot.ly";Plotly.newPlot("5da331c3-3f1f-4331-914e-5ba61259eb35", [{"y": [20, 14, 23], "x": ["giraffes", "orangutans", "monkeys"], "type": "bar"}], {}, {"linkText": "Export to plot.ly", "showLink": true})</script>

<script type="text/javascript">window.removeEventListener("resize", document.getElementById("5da331c3-3f1f-4331-914e-5ba61259eb35"));
window.addEventListener("resize", function(){Plotly.Plots.resize(document.getElementById("5da331c3-3f1f-4331-914e-5ba61259eb35"));});</script>


원본

<script type="text/javascript">window.removeEventListener("resize"); 


변경 후

<script type="text/javascript">window.removeEventListener("resize", document.getElementById("5da331c3-3f1f-4331-914e-5ba61259eb35"));


위의 코드는 python에서 offline으로 div 태그 생성한 결과이다.

헌데, edge에서는 정상 동작하지만, 크롬에서는 해당 코드를 bootstrap 관련된 기존 코드 위에 붙였을 경우

자동 크기 변환이 되지 않았다.

원인을 찾아보니, 위와 같이 removeEventListener에서 객체를 파라미터로 넘겨야 되는데 넘기는 부분이 빠져 있어서였다.

DOM 관련 버전 차이 인 듯 하다.

반응형

'Programming > Python' 카테고리의 다른 글

Tensorflow 설치  (0) 2017.04.04
Python Unit Test  (0) 2016.12.14
Python 유용한 샘플 코드  (0) 2016.10.20
python caffe  (0) 2016.09.17
무료 온라인 파이썬(Python) 교재  (1) 2015.05.18