jqplot html在新窗口中无法正确呈现

时间:2012-02-28 00:10:38

标签: javascript jquery html jqplot

我有一个应用程序,它使用jqplot生成一些我希望能够打印图形的图形,只有图形。

所以我写了一个函数一个简单的函数,它打开一个新窗口,其中包含应用程序主页面中graphdiv的代码。我的问题是图形无法在新窗口中正确显示。任何想法??

function newwindow() {

    var windowObject = window.open('', 'windowObject', 'arguments...');
    windowObject.document.write("<html> <head><link rel='stylesheet' type='text/css' href='jquery.jqplot.css' /></head> <body onload=''><div class='jqplot-target'>" + $('#chartdiv').html() + "</div></body></html>");
    windowObject.document.close();


}

感谢。

1 个答案:

答案 0 :(得分:0)

创建一个这样的函数,以便打开的图像具有dataUrl。

var img = $('#chartdiv').jqplotToImage(50, 0);
  if (img) {
    open(img.toDataURL("image/png"));
  } 

此jqplot to image可在此链接中找到 https://github.com/lsiden/export-jqplot-to-png

相关问题