我正在为我的班级做一个项目,目前在用户参加测验后,生成数字并创建一个图表。我需要在新窗口中获取此图表。如何将整个图表移动到窗口.打开选项卡。
这是我的代码: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,并将保存的变量放在新选项卡上。
谢谢!
使用空白 URL 打开它们,然后打开 window.document.将它们的内容写入其中,例如:
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);