Javascript 在角度高度图和折线图中添加自定义按钮
我正在尝试在导出属性的角度海图折线图中添加2个自定义按钮Javascript 在角度高度图和折线图中添加自定义按钮,javascript,angular,highcharts,angular-highcharts,Javascript,Angular,Highcharts,Angular Highcharts,我正在尝试在导出属性的角度海图折线图中添加2个自定义按钮 exporting: { enabled: true, buttons: { customButton: { text: 'Custom Button', click: () => { alert('You pressed the button!'); }, }, a
exporting: {
enabled: true,
buttons: {
customButton: {
text: 'Custom Button',
click: () => {
alert('You pressed the button!');
},
},
anotherButton: {
text: 'Another Button',
click: () => {
alert('You pressed another button!');
},
},
},
}
但这两个按钮不显示。这里缺少的逻辑是什么?
导出。按钮仅用于编辑导出菜单中的按钮: 要渲染自定义按钮,请使用svgrender功能:
您可以在初始加载后和每次重画后的渲染回调调用中添加这些按钮:您好,我认为下面的代码片段将对您有所帮助:
chart: {
type: "line",
renderTo: "chart",
events: {
render(events) {
let chart = this;
if (chart.customButton) {
chart.customButton.destroy();
}
chart.customButton = chart.renderer
.button("custom button", 100, 40, () => {
console.log("clicked.....");
chart.exportChart({
type: "application/pdf",
filename: "line-chart"
});
})
.add();
}
}
}
点击这里的按钮,可以实现导出。这里的示例导出PDF
演示:
希望这能有所帮助。Typescript有这样的例子吗?下面是一个使用角度的示例。您应该能够根据自己的需求轻松地对其进行定制。