我正在使用amcharts来创建图表。我也使用prototype.js为图表动态获取dataProvider。但是当我尝试使用amCharts的导出功能下载图表时,我收到以下错误:
无法读取属性' _calcWidth'未定义的
现在,当我删除prototype.js脚本然后再次执行下载时,它运行正常。
这是下载功能:
//charts[] contains all the amcharts.
function downloadReport() {
// iterate through all of the charts and prepare their images for export
var images = [];
var pending = charts.length;
for (var i = 0; i < charts.length; i++) {
var chart = charts[i];
var content = [];
chart.export.capture({}, function () {
var dataArray = this.toArray({
withHeader: true
});
var columns = dataArray[0].length;
var columnWidths = (Array(columns).join("auto,") + "*").split(","); // ["auto", ... "*"]
//
// EXTRA LOGS TO CHECK THE NUMBER OF COLUMNS (ALL SHOULD BE THE SAME)
console.log("header: ", columns);
console.log("widths: ", columnWidths.length);
for (var i2 = 0; i2 < dataArray.length; i2++) {
console.log("columns: ", dataArray[i2].length);
}
// GENERATE IMAGE
this.toJPG({}, function (data) {
// ADD IMAGE
content.push({
"image": data,
"fit": [523.28, 769.89] // A4 Dimensions less 20px because of the page margins
});
// ADD TABLE
content.push({
layout: 'headerLineOnly',
margin: [0, 20, 0, 0], // [left, top, right, bottom]
table: {
headerRows: 1,
widths: columnWidths,
body: dataArray
}
});
pending--;
if (pending === 0) {
// all done - construct PDF
chart.export.toPDF({
content: content
}, function (data) {
this.download(data, "application/pdf", "NPGroupReportDeck_LNIndiaTracker.pdf");
});
// ADD PAGE BREAK
} else {
content[content.length - 1].pageBreak = "after";
}
});
});
}
}
答案 0 :(得分:0)
我联系了amchart支持团队,他们告诉我,在他们的下一个版本中,这个问题将得到解决。我们所要做的就是等待。 :)