嗨,我正在使用highhchart并坚持一个听起来非常简单但无法找到任何答案的点。
我在定义highcharts
时将图表标题设置为null但在导出时添加图表标题,如
exporting: {
filename: '<?php echo $description ; ?>',
buttons: {
exportButton: {
menuItems: [{
text: 'Export Chart',
onclick: function () {
this.exportChart({}, {
title: {
text: '<?php echo $description ; ?>',
style: {
width: '450px'
}
}
});
}
},
null,
null,
null]
}
}
}
我无法配置如何在导出图表时添加图表标题和其他参数。
这是我输出图表的工作小提琴 http://jsfiddle.net/4SwvV/
当图表设置为空时,导出时带有标题的导出
我没有得到如何在印刷中实现这一点。打印允许设置这样的选项导出图表标题/
答案 0 :(得分:1)
您可以在导出
中设置此选项,而不是捕获menuitemclickchartOphttp://api.highcharts.com/highcharts#exporting.chartOptions
因此,它看起来像http://jsfiddle.net/4SwvV/:
exporting: {
filename: 'Export chart',
chartOptions:{
title:{
text:'Exported chart'
}
},
buttons: {
exportButton: {
menuItems: [{
text: 'Export Chart'
},
null,
null,
null]
}
}
},
编辑:
您可以使用不完美的解决方案http://jsfiddle.net/4SwvV/4/:
title: {
useHTML: true,
text: '<div id="title">Example title</div>',
style: {
width: '300px'
}
},
按钮:
onclick: function () {
$('#title').hide();
chart.print();
$('#title').show();
}