Print Dygraph chart

亡梦爱人 提交于 2019-12-11 09:26:10

问题


I'm trying to print a Div, containing a dygraph as follows:

javascript:

<script type="text/javascript">
            function PrintElem(elem)
            {               
                Popup(document.getElementById(elem).innerHTML);
            }

            function Popup(data) 
            {
                var mywindow = window.open('', 'my div', 'height=400,width=800');
                mywindow.document.write('<html><head><title>my div</title>');                
                mywindow.document.write('</head><body >');
                console.log(data);
                mywindow.document.write(data);
                mywindow.document.write('</body></html>');

                mywindow.print();
                mywindow.close();

                return true;
            }    
        </script>

In HTML:

<input type="button" value="Print Div" onclick="PrintElem('divName')" />

Problem statement:

The dygraph ("divName"), contains a script which plots the actual chart in HTML. The print function can not cater for this when trying to print the innerHTML.

Is there another way to do this? Thanks!

来源:https://stackoverflow.com/questions/14400599/print-dygraph-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!