我在我的网络应用程序中使用了Highcharts v4.0.3和exports.js,我希望能够为最终用户提供以下下载选项:
但是,标准选项是:
如何自定义它以便为用户提供JPG和PNG选项?
Hal*_*and 26
您可以手动设置exporting.buttons.contextButton.menuItems(API)以包含所需的任何按钮.
您将要将其设置为仅包含JPG和PNG(textKey仅限简短形式):
menuItems: ['downloadPNG','downloadJPEG']
Run Code Online (Sandbox Code Playgroud)
或者更明确的函数调用(带有对象的长格式onclick):
menuItems: [{
textKey: 'downloadPNG',
onclick: function () {
this.exportChart();
}
}, {
textKey: 'downloadJPEG',
onclick: function () {
this.exportChart({
type: 'image/jpeg'
});
}
}]
Run Code Online (Sandbox Code Playgroud)
默认exporting.js值为:
menuItems: [{
textKey: 'printChart',
onclick: function () {
this.print();
}
}, {
separator: true
}, {
textKey: 'downloadPNG',
onclick: function () {
this.exportChart();
}
}, {
textKey: 'downloadJPEG',
onclick: function () {
this.exportChart({
type: 'image/jpeg'
});
}
}, {
textKey: 'downloadPDF',
onclick: function () {
this.exportChart({
type: 'application/pdf'
});
}
}, {
textKey: 'downloadSVG',
onclick: function () {
this.exportChart({
type: 'image/svg+xml'
});
}
}]
Run Code Online (Sandbox Code Playgroud)
其他的export-data.js是:
menuItems: [{
textKey: 'downloadCSV',
onclick: function () {
this.downloadCSV();
}
}, {
textKey: 'downloadXLS',
onclick: function () {
this.downloadXLS();
}
},{
textKey: 'viewData',
onclick: function () {
this.viewData();
}
},{
textKey: 'openInCloud',
onclick: function () {
this.openInCloud();
}
}]
Run Code Online (Sandbox Code Playgroud)