简体   繁体   English

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

[英]jqplot html not rendering properly in new window

I have an application which uses jqplot to produce some graphs I want to have the ability to print the graph, and only the graph. 我有一个使用jqplot生成一些图的应用程序,我希望能够打印该图,并且仅打印该图。

So I wrote a function a simple function that opens a new window containing the code from the graphdiv in the main page of the application. 因此,我编写了一个简单的函数,它打开了一个新窗口,其中包含应用程序主页中graphdiv的代码。 My problem is that the graph does not display properly in the new window. 我的问题是该图形无法在新窗口中正确显示。 Any ideas?? 有任何想法吗??

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();


}

Thanks. 谢谢。

Create a function like this so that the opened image will have a dataUrl. 创建一个这样的函数,以便打开的图像将具有dataUrl。

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

This jqplot to image can be found in this link https://github.com/lsiden/export-jqplot-to-png 可以在此链接中找到此图像的jqplot https://github.com/lsiden/export-jqplot-to-png

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM