问题描述
我使用以下代码创建了带有Google图表的图形:
<script>
var holderarray = [
['Question','% scores'],['Question 1',67],['Question 2',18],['Question 3',40],['Question 4',66],['Question 5',37],['Question 6',98],['Question 7',50],['Question 8',75],['Question 9',['Question 10',37]
];
google.charts.load('current',{packages: ['corechart','bar']});
google.charts.setonLoadCallback(drawMaterial);
function drawMaterial() {
var data = google.visualization.arrayToDataTable(holderarray);
var materialOptions = {
colors: ['#15e01b'],chart: {
title: 'Value selected'
},hAxis: {
title: '% score',minValue: 0,maxValue: 100
},vAxis: {
title: 'Questions'
},bars: 'horizontal'
};
var chart_div = document.getElementById('chart_div');
var chart = new google.visualization.BarChart(chart_div);
// Wait for the chart to finish drawing before calling the getimageURI() method.
google.visualization.events.addListener(chart,'ready',function () {
chart_div.innerHTML = '<img src="' + chart.getimageURI() + '">';
//console.log(chart_div.innerHTML);
});
chart.draw(data,google.charts.Bar.convertOptions(materialOptions));
}
<div id='chart_div' style='height:300px;'></div>
这很好,现在尝试使用MPDF导出该图,我将DIV放在$ html变量中显示该图以导出为PDF,如下所示:
include("mpdf/mpdf.PHP");
$mpdf=new mPDF();
$html = "
Testing PDF Creator<br>
<div id='chart_div' style='height:300px;'></div>
";
echo "$html";
$mpdf->WriteHTML($html);
$mpdf->Output();
$mpdf->debug = true;
exit
回声仍然显示图形,但是生成的PDF仅包含“ Test PDF Creator”,而没有图形。我已经搜索了很多修复程序,但根本无法正常工作...请修复
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)