Javascript openWindow和我的图表

时间:2012-05-01 08:01:29

标签: javascript charts window.open

我正在为我的课程开展项目,目前我在用户进行测验后,会生成数字并创建图表。我需要在新窗口中获取此图表。我如何将这个整个图表移到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到新标签页。

谢谢!

1 个答案:

答案 0 :(得分:0)

使用空白网址和 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);