我正在使用Highcharts库创建图表,想知道如何删除右上角的两个小按钮,其中一个可以打印和下载图表,我想添加一个新按钮。也许有人可以帮我吗?
尝试在生成图表时添加exporting: { enabled: false }
。
onClick
属性进行调整。 - dgw点击这个链接可以创建一个新的按钮:
示例: http://jsfiddle.net/fXHB5/3496/
exporting: {
buttons: [
{
symbol: 'diamond',
x: -62,
symbolFill: '#B5C9DF',
hoverSymbolFill: '#779ABF',
_titleKey: 'printButtonTitle',
onclick: function() {
alert('click!')
}
}
]
}
exporting: {
buttons: {
contextButton: {
enabled: false
}
}
}
navigation: {
buttonOptions: {
enabled: false
}
}
$('#print').click(function() {
chart.print();
});
$('#pdf').click(function() {
chart.exportChart({
type: 'application/pdf',
filename: 'my-pdf'
});
});
$('#png').click(function() {
chart.exportChart({
type: 'image/png',
filename: 'my-png'
});
});
$('#jpeg').click(function() {
chart.exportChart({
type: 'image/jpeg',
filename: 'my-jpeg'
});
});
$('#svg').click(function() {
chart.exportChart({
type: 'image/svg+xml',
filename: 'my-svg'
});
});
{{链接1:jsfiddle}}
exporting:false,
@dgw的想法是正确的,可以删除导出按钮,但我对“我想添加一个新按钮”的建议并不满意,直到我意识到我应该将按钮放在图形外面。除非您的数据是静态的,否则您真的不知道是否有足够的空间来显示控件。
<div id="container" style="height: 400px; min-width: 600px"></div>
<button id="button" class="autocompare">new button</button>
exporting.buttons.contextButton.menuItems
数组,只包括您想要的菜单项。以下是一个示例,排除了“打印图表”和“查看全屏”选项。exporting: {
buttons: {
contextButton: {
menuItems: ["downloadPNG", "downloadJPEG", "downloadPDF", "downloadSVG"]
}
}
}