Đây là giải pháp thay thế thực hiện in trực tiếp. Nó dựa trên chức năng biểu đồ.print(), nhưng nó hoạt động trên nhiều biểu đồ.
Xem bản demo đây: http://jsfiddle.net/jim31415/q5Rzu/150/
//--------------------------------------------------------------------
$("#print").click(function() {
printCharts([chart1, chart2, chart3]);
});
//--------------------------------------------------------------------
function printCharts(charts) {
var origDisplay = [],
origParent = [],
body = document.body,
childNodes = body.childNodes;
// hide all body content
Highcharts.each(childNodes, function (node, i) {
if (node.nodeType === 1) {
origDisplay[i] = node.style.display;
node.style.display = "none";
}
});
// put the charts back in
$.each(charts, function (i, chart) {
origParent[i] = chart.container.parentNode;
body.appendChild(chart.container);
});
// print
window.print();
// allow the browser to prepare before reverting
setTimeout(function() {
// put the charts back in
$.each(charts, function (i, chart) {
origParent[i].appendChild(chart.container);
});
// restore all body content
Highcharts.each(childNodes, function (node, i) {
if (node.nodeType === 1) {
node.style.display = origDisplay[i];
}
});
}, 500);
}
});
Tôi sẽ xem xét nó, nhưng nó có vẻ tốt từ những gì tôi thấy trong jsFiddle! –
Highcharts đã xóa các tệp, bạn có thể sử dụng nó thay vì liên kết đầu tiên tốt hơn http://jsfiddle.net/q5Rzu/147/ – fcortes
Bạn có thể giúp tôi không? Tôi muốn in 5 biểu đồ cùng một lúc. Nhưng tôi muốn cung cấp cho một tittle trên đầu trang đầu tiên. Làm thế nào để làm điều đó ? –