为了账号安全,请及时绑定邮箱和手机立即绑定

在 Angular Highcharts 折线图中添加自定义按钮

在 Angular Highcharts 折线图中添加自定义按钮

慕桂英3389331 2022-06-09 18:26:32
我正在尝试在导出属性的 Angular Highcharts 折线图中添加 2 个自定义按钮exporting: {    enabled: true,    buttons: {        customButton: {            text: 'Custom Button',            click: () => {                alert('You pressed the button!');            },        },        anotherButton: {            text: 'Another Button',            click: () => {                alert('You pressed another button!');            },        },    },}但是这两个按钮没有显示。这里可能缺少什么逻辑?
查看完整描述

2 回答

?
郎朗坤

TA贡献1921条经验 获得超9个赞

您好,认为下面的代码片段会对您有所帮助:


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。


查看完整回答
反对 回复 2022-06-09
?
www说

TA贡献1775条经验 获得超8个赞

exporting.buttons是仅在导出菜单中编辑按钮的选项:https ://api.highcharts.com/highcharts/exporting.buttons

要呈现自定义按钮,请使用SVGRenderer功能:https ://api.highcharts.com/class-reference/Highcharts.SVGRenderer#button

您可以在渲染回调中添加这些按钮- 在初始加载后和每次重绘后调用:https ://api.highcharts.com/highcharts/chart.events.render


查看完整回答
反对 回复 2022-06-09
  • 2 回答
  • 0 关注
  • 235 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信