當我打印右下框架時,文本some text
部分被高圖覆蓋,因爲它們在打印前不調整大小。有沒有一種解決方案可以爲網站配置@media print
的打印佈局,並在打印網站時強制highcharts重新繪製/調整容器大小?打印網站時重繪/調整高度圖
HTML
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="height: 400px"></div>
<div id="container" style="height: 400px"></div>
的JavaScript
$(function() {
Highcharts.setOptions({ // Apply to all charts
chart: {
events: {
beforePrint: function() {
this.oldhasUserSize = this.hasUserSize;
this.resetParams = [this.chartWidth, this.chartHeight, false];
this.setSize(600, 400, false);
},
afterPrint: function() {
this.setSize.apply(this, this.resetParams);
this.hasUserSize = this.oldhasUserSize;
}
}
}
});
$('#container').highcharts({
title: {
text: 'Rescale to print'
},
subtitle: {
text: 'Click the context menu and choose "Print chart".<br>The chart size is set to 600x400 and restored after print.'
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
});
歡迎StackOverflow上。我編輯了您的帖子,以包含來自JSFiddle內聯的代碼。如果鏈接曾經死亡,那麼問題將變得毫無用處,因此將內聯代碼包括在內的問題更適合。 – IKavanagh
非常感謝您 – user3665396