基本上我想在javascript数组中编写html代码,该数组包含构建图表的信息,我试图用html图像元素替换js数组中包含的标题,到目前为止我还没有取得多大成功。请记住,如果用字符串替换<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<?php
echo "
<script type=\"text/javascript\">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawVisualization);
var node = '<img src=\"img/email.png\" height=\"40px\" width=\"40px\" id=\"ttt\">';
function drawVisualization() {
// Some raw data (not necessarily accurate)
var data = google.visualization.arrayToDataTable([
['Month', 'Bolivia', 'Ecuador', 'Madagascar', 'Papua New Guinea', 'Rwanda', 'Average'],
[document.write(node), 165, 938, 522, 998, 450, 614.6],
['2005/06', 135, 1120, 599, 1268, 288, 682],
['2006/07', 157, 1167, 587, 807, 397, 623],
['2007/08', 139, 1110, 615, 968, 215, 609.4],
['2008/09', 136, 691, 629, 1026, 366, 569.6]
]);
var options = {
title : 'Monthly Coffee Production by Country',
vAxis: {title: 'Cups'},
hAxis: {title: 'Month'},
seriesType: 'bars',
series: {5: {type: 'line'}}
};
var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>";
?>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
,代码可以工作(如果要测试)。任何见解都会被贬低,谢谢。
注意:如果有必要,我可以删除PHP,我只是使用它,因为我可能需要它以后
{{1}}