0

我正在为我的班级做一个项目,我目前在用户进行测验后,会生成数字并创建一个图表。我需要在新窗口中获取此图表。如何将整个图表移动到 window.open 选项卡。

这是我的代码: openwindow = window.open("", "Best Fits","width=600,height=700,")

        openwindow.document.write("Our top recommendation: "+ vare[0][0]+": " + vare[0][2] + "<br /> <br />" + "Our second recommendation:  "+ vare[1][0]+": " + vare[1][2] + "<br /> <br />" + "Our third recommendation: "+ vare[2][0] + ": " + vare[2][2]);



        //alert(Math.min(vare[0],vare[1],vare[2],vare[3],vare[4]))


        alert(vare[0][0] +": " + vare[0][1] + "   " + vare[1][0] +": " + vare[1][1] + "   " + vare[2][0] +": " + vare[2][1] + "   " + vare[3][0] +": " + vare[3][1] + "   " + vare [4][0] +": " + vare[4][1]  + "  " + results[0] + "  " + results[1] + "  " + results[2] + "  " + results[3])
        alert(vare[0][0]+": " + vare[0][1]);
        myData = new Array([vare[0][0],vare[0][1]],[vare[1][0],vare[1][1]],[vare[2][0],vare[2][1]])
        var colors = ['#FACC00', '#FB9900', '#FB6600'];
        var myChart = new JSChart('graph', 'pie');
        myChart.setDataArray(myData);
        myChart.colorizePie(colors);
        myChart.setTitle('Hotel');
        myChart.setTitleColor('#857D7D');
        myChart.setPieUnitsColor('#9B9B9B');
        myChart.setPieValuesColor('#6A0000');
        myChart.draw();

    });
});

}

我需要打开 MyChart 并在新选项卡上保存变量。

谢谢!

4

1 回答 1

0

使用空白 URL 打开它们,然后openwindow.document.write将它们的内容写入其中,例如:


var openwindow = window.open("", "Best Fits","width=600,height=700,")
var chrt = "";
myData = new Array([vare[0][0],vare[0][1]],[vare[1][0],vare[1][1]],[vare[2][0],vare[2][1]])
        var colors = ['#FACC00', '#FB9900', '#FB6600'];
        var myChart = new JSChart('graph', 'pie');
        chrt += myChart.setDataArray(myData);
        chrt += myChart.colorizePie(colors);
        chrt += myChart.setTitle('Hotel');
        chrt += myChart.setTitleColor('#857D7D');
        chrt += myChart.setPieUnitsColor('#9B9B9B');
        chrt += myChart.setPieValuesColor('#6A0000');
        chrt += myChart.draw();
openwindow.document.write(chrt);
于 2012-05-01T08:12:13.797 回答