我想根据点击给定网址右侧的导出菜单设置文件类型。例如,如果单击pdf,则应将filetype设置为application / pdf。 var defaultTitle =" Kalar&#34 ;; var drilldownTitle ="&#34 ;; var ydrillupTitle ="#Kalar&#34 ;; var ydrilldownTitle ="&#34 ;;
var chart = new Highcharts.Chart({
chart: {
type: 'column',
renderTo: 'upendra',
events: {
drilldown: function(e) {
chart.setTitle({ text: drilldownTitle + e.point.title });
chart.yAxis[0].axisTitle.attr({
text: ydrilldownTitle
});
},
drillup: function(e) {
chart.setTitle({ text: defaultTitle });
chart.yAxis[0].axisTitle.attr({
text: ydrillupTitle
});
},
click: function(e) {
chart.exportChart({
filename: chart.options.title.text
});
}
}
},
title: {
text: defaultTitle
},
subtitle: {
text: ''
},
credits: {
enabled: false
},
xAxis: {
categories: ['one', 'two']
},
yAxis: {
allowDecimals: false,
min: 0,
title: {
text: ydrillupTitle
}
},
plotOptions: {
column: {
stacking: 'normal',
showInLegend: true
}
},
series:[
{
name:'A',
color:'#E9ECEE',
tooltip: {
headerFormat: '',
pointFormat: '{point.name}:<br/><b>{point.y}</b> Bookings (<b>{point.percentage:, .1f} %</b>)<br/>'
},
data:[
{
name: "A",
title: "A by Company",
x:0, y:2
}, {
name: "",
x:1, y:0
}
]
},
{
name:'Arrived',
color:'#B3E5C4',
tooltip: {
headerFormat: '',
pointFormat: '{point.name}:<br/><b>{point.y}</b> Bookings (<b>{point.percentage:, .1f} %</b>)<br/>'
},
data:[
{
name: "Arrived",
title: "Planned Bookings by Goods Type",
x:0, y:10
}, {
name: "",
x:1, y:0
}
]
},
{
name:'Unscheduled',
color:'#A9ABAD',
tooltip: {
headerFormat: '',
pointFormat: '{point.name}:<br/><b>{point.y}</b> Deliveries (<b>{point.percentage:, .1f} %</b>)<br/>'
},
data:[
{
name: "",
x:0, y:0
},
{
name: "Unscheduled",
title: "Unscheduled Deliveries by Company",
x:1, y:8
}
]
},
{
name:'Rejected',
color:'#FF838F',
tooltip: {
headerFormat: '',
pointFormat: '{point.name}:<br/><b>{point.y}</b> Deliveries (<b>{point.percentage:, .1f} %</b>)<br/>'
},
data:[
{
name: "",
x:0, y:0
},
{
name: "Rejected",
title: "Rejected Deliveries Reasons",
x:1, y:7
}
]
},
{
name:'Complete',
color:'#B3E5C4',
tooltip: {
headerFormat: '',
pointFormat: '{point.name}:<br/><b>{point.y}</b> Deliveries (<b>{point.percentage:, .1f} %</b>)<br/>'
},
data:[
{
name: "",
x:0, y:0
},
{
name: "Complete",
title: "Actual Deliveries by Goods Type",
x:1, y:6
}
]
}
]
});
});
答案 0 :(得分:1)
您可以在导出选项中编辑menuItem,然后设置文件名,从标题中提取该信息。
exporting: {
buttons: {
contextButton: {
menuItems: [{
textKey: 'printChart',
onclick: function () {
this.print();
}
}, {
separator: true
}, {
textKey: 'downloadPNG',
onclick: function () {
var title = this.title.textStr;
this.exportChart({
type: 'image/png',
filename: title
});
}
}, {
textKey: 'downloadJPEG',
onclick: function () {
var title = this.title.textStr;
this.exportChart({
type: 'image/jpeg',
filename: title
});
}
}, {
textKey: 'downloadPDF',
onclick: function () {
var title = this.title.textStr;
this.exportChart({
type: 'application/pdf',
filename: title
});
}
}, {
textKey: 'downloadSVG',
onclick: function () {
var title = this.title.textStr;
this.exportChart({
type: 'image/svg+xml',
filename: title
});
}
}]
}
}
},