![](/img/trans.png)
[英]How to export rendered Highchart chart as a pdf/png/jpeg in a Phonegap application?
[英]How to export a Highchart chart to PDF thanks to a button outside the chart?
我想button outside a Highchart chart
有一個button outside a Highchart chart
,用PDF
export
圖表。
<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; margin-top: 1em"></div>
<button id="export2pdf">Export to PDF</button>
$(function () {
window.chart = new Highcharts.Chart({
chart: {renderTo : 'container'},
title: {
text: 'Exporting module is loaded but buttons are disabled'
},
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]
}],
exporting: {
enabled: true
}
});
$("#export2pdf").click(function(){
// Export method ?
// Ajax call ?
});
});
這是我想要的JsFiddle 。
請參閱API。 這將在exportChart
。 基本上這樣做:
var chart = $('#container').highcharts();
chart.exportChart({
type: 'application/pdf',
filename: 'my-pdf'
});
查看Highcharts的導出屬性。 您需要將type
設置為application/pdf
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.